OLD | NEW |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const CompletionCallback& callback); | 63 const CompletionCallback& callback); |
64 virtual int Write(IOBuffer* buf, int buf_len, | 64 virtual int Write(IOBuffer* buf, int buf_len, |
65 const CompletionCallback& callback); | 65 const CompletionCallback& callback); |
66 | 66 |
67 virtual bool SetReceiveBufferSize(int32 size); | 67 virtual bool SetReceiveBufferSize(int32 size); |
68 virtual bool SetSendBufferSize(int32 size); | 68 virtual bool SetSendBufferSize(int32 size); |
69 | 69 |
70 virtual bool SetKeepAlive(bool enable, int delay); | 70 virtual bool SetKeepAlive(bool enable, int delay); |
71 virtual bool SetNoDelay(bool no_delay); | 71 virtual bool SetNoDelay(bool no_delay); |
72 | 72 |
73 // Perform reads in non-blocking mode instead of overlapped mode. | |
74 // Used for experiments. | |
75 static void DisableOverlappedReads(); | |
76 | |
77 private: | 73 private: |
78 // State machine for connecting the socket. | 74 // State machine for connecting the socket. |
79 enum ConnectState { | 75 enum ConnectState { |
80 CONNECT_STATE_CONNECT, | 76 CONNECT_STATE_CONNECT, |
81 CONNECT_STATE_CONNECT_COMPLETE, | 77 CONNECT_STATE_CONNECT_COMPLETE, |
82 CONNECT_STATE_NONE, | 78 CONNECT_STATE_NONE, |
83 }; | 79 }; |
84 | 80 |
85 class Core; | 81 class Core; |
86 | 82 |
(...skipping 11 matching lines...) Expand all Loading... |
98 return next_connect_state_ != CONNECT_STATE_NONE; | 94 return next_connect_state_ != CONNECT_STATE_NONE; |
99 } | 95 } |
100 | 96 |
101 // Called after Connect() has completed with |net_error|. | 97 // Called after Connect() has completed with |net_error|. |
102 void LogConnectCompletion(int net_error); | 98 void LogConnectCompletion(int net_error); |
103 | 99 |
104 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 100 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
105 void DoReadCallback(int rv); | 101 void DoReadCallback(int rv); |
106 void DoWriteCallback(int rv); | 102 void DoWriteCallback(int rv); |
107 void DidCompleteConnect(); | 103 void DidCompleteConnect(); |
108 void DidCompleteRead(); | |
109 void DidCompleteWrite(); | 104 void DidCompleteWrite(); |
110 void DidSignalRead(); | 105 void DidSignalRead(); |
111 | 106 |
112 SOCKET socket_; | 107 SOCKET socket_; |
113 | 108 |
114 // Local IP address and port we are bound to. Set to NULL if Bind() | 109 // Local IP address and port we are bound to. Set to NULL if Bind() |
115 // was't called (in that cases OS chooses address/port). | 110 // was't called (in that cases OS chooses address/port). |
116 scoped_ptr<IPEndPoint> bind_address_; | 111 scoped_ptr<IPEndPoint> bind_address_; |
117 | 112 |
118 // Stores bound socket between Bind() and Connect() calls. | 113 // Stores bound socket between Bind() and Connect() calls. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Record of connectivity and transmissions, for use in speculative connection | 148 // Record of connectivity and transmissions, for use in speculative connection |
154 // histograms. | 149 // histograms. |
155 UseHistory use_history_; | 150 UseHistory use_history_; |
156 | 151 |
157 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); | 152 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); |
158 }; | 153 }; |
159 | 154 |
160 } // namespace net | 155 } // namespace net |
161 | 156 |
162 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ | 157 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ |
OLD | NEW |