| 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_LIBEVENT_H_ | 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ | 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(WriteWatcher); | 117 DISALLOW_COPY_AND_ASSIGN(WriteWatcher); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 // State machine used by Connect(). | 120 // State machine used by Connect(). |
| 121 int DoConnectLoop(int result); | 121 int DoConnectLoop(int result); |
| 122 int DoConnect(); | 122 int DoConnect(); |
| 123 int DoConnectComplete(int result); | 123 int DoConnectComplete(int result); |
| 124 | 124 |
| 125 // Helper used by Disconnect(), which disconnects minus the logging and | 125 // Helper used by Disconnect(), which disconnects minus the logging and |
| 126 // resetting of current_ai_. | 126 // resetting of current_address_index_. |
| 127 void DoDisconnect(); | 127 void DoDisconnect(); |
| 128 | 128 |
| 129 void DoReadCallback(int rv); | 129 void DoReadCallback(int rv); |
| 130 void DoWriteCallback(int rv); | 130 void DoWriteCallback(int rv); |
| 131 void DidCompleteRead(); | 131 void DidCompleteRead(); |
| 132 void DidCompleteWrite(); | 132 void DidCompleteWrite(); |
| 133 void DidCompleteConnect(); | 133 void DidCompleteConnect(); |
| 134 | 134 |
| 135 // Returns true if a Connect() is in progress. | 135 // Returns true if a Connect() is in progress. |
| 136 bool waiting_connect() const { | 136 bool waiting_connect() const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 148 // Local IP address and port we are bound to. Set to NULL if Bind() | 148 // Local IP address and port we are bound to. Set to NULL if Bind() |
| 149 // was't called (in that cases OS chooses address/port). | 149 // was't called (in that cases OS chooses address/port). |
| 150 scoped_ptr<IPEndPoint> bind_address_; | 150 scoped_ptr<IPEndPoint> bind_address_; |
| 151 | 151 |
| 152 // Stores bound socket between Bind() and Connect() calls. | 152 // Stores bound socket between Bind() and Connect() calls. |
| 153 int bound_socket_; | 153 int bound_socket_; |
| 154 | 154 |
| 155 // The list of addresses we should try in order to establish a connection. | 155 // The list of addresses we should try in order to establish a connection. |
| 156 AddressList addresses_; | 156 AddressList addresses_; |
| 157 | 157 |
| 158 // Where we are in above list, or NULL if all addrinfos have been tried. | 158 // Where we are in above list. Set to -1 if uninitialized. |
| 159 const struct addrinfo* current_ai_; | 159 int current_address_index_; |
| 160 | 160 |
| 161 // The socket's libevent wrappers | 161 // The socket's libevent wrappers |
| 162 MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; | 162 MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; |
| 163 MessageLoopForIO::FileDescriptorWatcher write_socket_watcher_; | 163 MessageLoopForIO::FileDescriptorWatcher write_socket_watcher_; |
| 164 | 164 |
| 165 // The corresponding watchers for reads and writes. | 165 // The corresponding watchers for reads and writes. |
| 166 ReadWatcher read_watcher_; | 166 ReadWatcher read_watcher_; |
| 167 WriteWatcher write_watcher_; | 167 WriteWatcher write_watcher_; |
| 168 | 168 |
| 169 // The buffer used by OnSocketReady to retry Read requests | 169 // The buffer used by OnSocketReady to retry Read requests |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 base::TimeTicks connect_start_time_; | 204 base::TimeTicks connect_start_time_; |
| 205 base::TimeDelta connect_time_micros_; | 205 base::TimeDelta connect_time_micros_; |
| 206 int64 num_bytes_read_; | 206 int64 num_bytes_read_; |
| 207 | 207 |
| 208 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); | 208 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 } // namespace net | 211 } // namespace net |
| 212 | 212 |
| 213 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ | 213 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| OLD | NEW |