| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <winsock2.h> | 9 #include <winsock2.h> |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class Core; | 79 class Core; |
| 80 | 80 |
| 81 // State machine used by Connect(). | 81 // State machine used by Connect(). |
| 82 int DoConnectLoop(int result); | 82 int DoConnectLoop(int result); |
| 83 int DoConnect(); | 83 int DoConnect(); |
| 84 int DoConnectComplete(int result); | 84 int DoConnectComplete(int result); |
| 85 | 85 |
| 86 // Helper used by Disconnect(), which disconnects minus the logging and | 86 // Helper used by Disconnect(), which disconnects minus the logging and |
| 87 // resetting of current_ai_. | 87 // resetting of current_address_index_. |
| 88 void DoDisconnect(); | 88 void DoDisconnect(); |
| 89 | 89 |
| 90 // Returns true if a Connect() is in progress. | 90 // Returns true if a Connect() is in progress. |
| 91 bool waiting_connect() const { | 91 bool waiting_connect() const { |
| 92 return next_connect_state_ != CONNECT_STATE_NONE; | 92 return next_connect_state_ != CONNECT_STATE_NONE; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Called after Connect() has completed with |net_error|. | 95 // Called after Connect() has completed with |net_error|. |
| 96 void LogConnectCompletion(int net_error); | 96 void LogConnectCompletion(int net_error); |
| 97 | 97 |
| 98 void DoReadCallback(int rv); | 98 void DoReadCallback(int rv); |
| 99 void DoWriteCallback(int rv); | 99 void DoWriteCallback(int rv); |
| 100 void DidCompleteConnect(); | 100 void DidCompleteConnect(); |
| 101 void DidCompleteRead(); | 101 void DidCompleteRead(); |
| 102 void DidCompleteWrite(); | 102 void DidCompleteWrite(); |
| 103 | 103 |
| 104 SOCKET socket_; | 104 SOCKET socket_; |
| 105 | 105 |
| 106 // Local IP address and port we are bound to. Set to NULL if Bind() | 106 // Local IP address and port we are bound to. Set to NULL if Bind() |
| 107 // was't called (in that cases OS chooses address/port). | 107 // was't called (in that cases OS chooses address/port). |
| 108 scoped_ptr<IPEndPoint> bind_address_; | 108 scoped_ptr<IPEndPoint> bind_address_; |
| 109 | 109 |
| 110 // Stores bound socket between Bind() and Connect() calls. | 110 // Stores bound socket between Bind() and Connect() calls. |
| 111 SOCKET bound_socket_; | 111 SOCKET bound_socket_; |
| 112 | 112 |
| 113 // The list of addresses we should try in order to establish a connection. | 113 // The list of addresses we should try in order to establish a connection. |
| 114 AddressList addresses_; | 114 AddressList addresses_; |
| 115 | 115 |
| 116 // Where we are in above list, or NULL if all addrinfos have been tried. | 116 // Where we are in above list. Set to -1 if uninitialized. |
| 117 const struct addrinfo* current_ai_; | 117 int current_address_index_; |
| 118 | 118 |
| 119 // The various states that the socket could be in. | 119 // The various states that the socket could be in. |
| 120 bool waiting_read_; | 120 bool waiting_read_; |
| 121 bool waiting_write_; | 121 bool waiting_write_; |
| 122 | 122 |
| 123 // The core of the socket that can live longer than the socket itself. We pass | 123 // The core of the socket that can live longer than the socket itself. We pass |
| 124 // resources to the Windows async IO functions and we have to make sure that | 124 // resources to the Windows async IO functions and we have to make sure that |
| 125 // they are not destroyed while the OS still references them. | 125 // they are not destroyed while the OS still references them. |
| 126 scoped_refptr<Core> core_; | 126 scoped_refptr<Core> core_; |
| 127 | 127 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 149 base::TimeTicks connect_start_time_; | 149 base::TimeTicks connect_start_time_; |
| 150 base::TimeDelta connect_time_micros_; | 150 base::TimeDelta connect_time_micros_; |
| 151 int64 num_bytes_read_; | 151 int64 num_bytes_read_; |
| 152 | 152 |
| 153 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); | 153 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 } // namespace net | 156 } // namespace net |
| 157 | 157 |
| 158 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ | 158 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_WIN_H_ |
| OLD | NEW |