OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SOCKET_WIN_H_ | 5 #ifndef NET_SOCKET_TCP_SOCKET_WIN_H_ |
6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ | 6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <winsock2.h> | 9 #include <winsock2.h> |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 int AcceptInternal(std::unique_ptr<TCPSocketWin>* socket, | 124 int AcceptInternal(std::unique_ptr<TCPSocketWin>* socket, |
125 IPEndPoint* address); | 125 IPEndPoint* address); |
126 | 126 |
127 int DoConnect(); | 127 int DoConnect(); |
128 void DoConnectComplete(int result); | 128 void DoConnectComplete(int result); |
129 | 129 |
130 void LogConnectBegin(const AddressList& addresses); | 130 void LogConnectBegin(const AddressList& addresses); |
131 void LogConnectEnd(int net_error); | 131 void LogConnectEnd(int net_error); |
132 | 132 |
133 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 133 void RetryRead(int rv); |
134 void DidCompleteConnect(); | 134 void DidCompleteConnect(); |
135 void DidCompleteWrite(); | 135 void DidCompleteWrite(); |
136 void DidSignalRead(); | 136 void DidSignalRead(); |
137 | 137 |
138 SOCKET socket_; | 138 SOCKET socket_; |
139 | 139 |
140 // |socket_performance_watcher_| may be nullptr. | 140 // |socket_performance_watcher_| may be nullptr. |
141 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher_; | 141 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher_; |
142 | 142 |
143 HANDLE accept_event_; | 143 HANDLE accept_event_; |
144 base::win::ObjectWatcher accept_watcher_; | 144 base::win::ObjectWatcher accept_watcher_; |
145 | 145 |
146 std::unique_ptr<TCPSocketWin>* accept_socket_; | 146 std::unique_ptr<TCPSocketWin>* accept_socket_; |
147 IPEndPoint* accept_address_; | 147 IPEndPoint* accept_address_; |
148 CompletionCallback accept_callback_; | 148 CompletionCallback accept_callback_; |
149 | 149 |
150 // The various states that the socket could be in. | 150 // The various states that the socket could be in. |
151 bool waiting_connect_; | 151 bool waiting_connect_; |
152 bool waiting_read_; | 152 bool waiting_read_; |
153 bool waiting_write_; | 153 bool waiting_write_; |
154 | 154 |
155 // The core of the socket that can live longer than the socket itself. We pass | 155 // The core of the socket that can live longer than the socket itself. We pass |
156 // resources to the Windows async IO functions and we have to make sure that | 156 // resources to the Windows async IO functions and we have to make sure that |
157 // they are not destroyed while the OS still references them. | 157 // they are not destroyed while the OS still references them. |
158 scoped_refptr<Core> core_; | 158 scoped_refptr<Core> core_; |
159 | 159 |
160 // External callback; called when connect or read is complete. | 160 // External callback; called when connect or read is complete. |
161 CompletionCallback read_callback_; | 161 CompletionCallback read_callback_; |
162 | 162 |
| 163 // Non-null if a ReadIfReady() is to be completed asynchronously. This is an |
| 164 // external callback if user used ReadIfReady() instead of Read(), but a |
| 165 // wrapped callback on top of RetryRead() if Read() is used. |
| 166 CompletionCallback read_if_ready_callback_; |
| 167 |
163 // External callback; called when write is complete. | 168 // External callback; called when write is complete. |
164 CompletionCallback write_callback_; | 169 CompletionCallback write_callback_; |
165 | 170 |
166 std::unique_ptr<IPEndPoint> peer_address_; | 171 std::unique_ptr<IPEndPoint> peer_address_; |
167 // The OS error that a connect attempt last completed with. | 172 // The OS error that a connect attempt last completed with. |
168 int connect_os_error_; | 173 int connect_os_error_; |
169 | 174 |
170 bool logging_multiple_connect_attempts_; | 175 bool logging_multiple_connect_attempts_; |
171 | 176 |
172 NetLogWithSource net_log_; | 177 NetLogWithSource net_log_; |
173 | 178 |
174 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); | 179 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); |
175 }; | 180 }; |
176 | 181 |
177 } // namespace net | 182 } // namespace net |
178 | 183 |
179 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_ | 184 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_ |
OLD | NEW |