Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: net/socket/tcp_client_socket_win.h

Issue 10916016: Switch the TCP reads on Windows to use non-blocking/non-async I/O. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/page_load_histograms.cc ('k') | net/socket/tcp_client_socket_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_
6 #define NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_
7 7
8 #include <winsock2.h> 8 #include <winsock2.h>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 const CompletionCallback& callback); 65 const CompletionCallback& callback);
66 virtual int Write(IOBuffer* buf, int buf_len, 66 virtual int Write(IOBuffer* buf, int buf_len,
67 const CompletionCallback& callback); 67 const CompletionCallback& callback);
68 68
69 virtual bool SetReceiveBufferSize(int32 size); 69 virtual bool SetReceiveBufferSize(int32 size);
70 virtual bool SetSendBufferSize(int32 size); 70 virtual bool SetSendBufferSize(int32 size);
71 71
72 virtual bool SetKeepAlive(bool enable, int delay); 72 virtual bool SetKeepAlive(bool enable, int delay);
73 virtual bool SetNoDelay(bool no_delay); 73 virtual bool SetNoDelay(bool no_delay);
74 74
75 // Perform reads in non-blocking mode instead of overlapped mode.
76 // Used for experiments.
77 static void DisableOverlappedReads();
78
75 private: 79 private:
76 // State machine for connecting the socket. 80 // State machine for connecting the socket.
77 enum ConnectState { 81 enum ConnectState {
78 CONNECT_STATE_CONNECT, 82 CONNECT_STATE_CONNECT,
79 CONNECT_STATE_CONNECT_COMPLETE, 83 CONNECT_STATE_CONNECT_COMPLETE,
80 CONNECT_STATE_NONE, 84 CONNECT_STATE_NONE,
81 }; 85 };
82 86
83 class Core; 87 class Core;
84 88
85 // State machine used by Connect(). 89 // State machine used by Connect().
86 int DoConnectLoop(int result); 90 int DoConnectLoop(int result);
87 int DoConnect(); 91 int DoConnect();
88 int DoConnectComplete(int result); 92 int DoConnectComplete(int result);
89 93
90 // Helper used by Disconnect(), which disconnects minus the logging and 94 // Helper used by Disconnect(), which disconnects minus the logging and
91 // resetting of current_address_index_. 95 // resetting of current_address_index_.
92 void DoDisconnect(); 96 void DoDisconnect();
93 97
94 // Returns true if a Connect() is in progress. 98 // Returns true if a Connect() is in progress.
95 bool waiting_connect() const { 99 bool waiting_connect() const {
96 return next_connect_state_ != CONNECT_STATE_NONE; 100 return next_connect_state_ != CONNECT_STATE_NONE;
97 } 101 }
98 102
99 // Called after Connect() has completed with |net_error|. 103 // Called after Connect() has completed with |net_error|.
100 void LogConnectCompletion(int net_error); 104 void LogConnectCompletion(int net_error);
101 105
106 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
102 void DoReadCallback(int rv); 107 void DoReadCallback(int rv);
103 void DoWriteCallback(int rv); 108 void DoWriteCallback(int rv);
104 void DidCompleteConnect(); 109 void DidCompleteConnect();
105 void DidCompleteRead(); 110 void DidCompleteRead();
106 void DidCompleteWrite(); 111 void DidCompleteWrite();
112 void DidSignalRead();
107 113
108 SOCKET socket_; 114 SOCKET socket_;
109 115
110 // Local IP address and port we are bound to. Set to NULL if Bind() 116 // Local IP address and port we are bound to. Set to NULL if Bind()
111 // was't called (in that cases OS chooses address/port). 117 // was't called (in that cases OS chooses address/port).
112 scoped_ptr<IPEndPoint> bind_address_; 118 scoped_ptr<IPEndPoint> bind_address_;
113 119
114 // Stores bound socket between Bind() and Connect() calls. 120 // Stores bound socket between Bind() and Connect() calls.
115 SOCKET bound_socket_; 121 SOCKET bound_socket_;
116 122
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 base::TimeTicks connect_start_time_; 159 base::TimeTicks connect_start_time_;
154 base::TimeDelta connect_time_micros_; 160 base::TimeDelta connect_time_micros_;
155 int64 num_bytes_read_; 161 int64 num_bytes_read_;
156 162
157 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); 163 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin);
158 }; 164 };
159 165
160 } // namespace net 166 } // namespace net
161 167
162 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ 168 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_
OLDNEW
« no previous file with comments | « chrome/renderer/page_load_histograms.cc ('k') | net/socket/tcp_client_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698