| 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_LIBEVENT_H_ | 5 #ifndef NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ |
| 6 #define NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ | 6 #define NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // | 81 // |
| 82 // TODO(yzshen): Change logging format and let TCPClientSocket log the | 82 // TODO(yzshen): Change logging format and let TCPClientSocket log the |
| 83 // start/end of a series of connect attempts itself. | 83 // start/end of a series of connect attempts itself. |
| 84 void StartLoggingMultipleConnectAttempts(const AddressList& addresses); | 84 void StartLoggingMultipleConnectAttempts(const AddressList& addresses); |
| 85 void EndLoggingMultipleConnectAttempts(int net_error); | 85 void EndLoggingMultipleConnectAttempts(int net_error); |
| 86 | 86 |
| 87 const BoundNetLog& net_log() const { return net_log_; } | 87 const BoundNetLog& net_log() const { return net_log_; } |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 // States that a fast open socket attempt can result in. | 90 // States that a fast open socket attempt can result in. |
| 91 enum FastOpenStatus { | 91 enum TCPFastOpenStatus { |
| 92 FAST_OPEN_STATUS_UNKNOWN, | 92 FAST_OPEN_STATUS_UNKNOWN, |
| 93 | 93 |
| 94 // The initial fast open connect attempted returned synchronously, | 94 // The initial fast open connect attempted returned synchronously, |
| 95 // indicating that we had and sent a cookie along with the initial data. | 95 // indicating that we had and sent a cookie along with the initial data. |
| 96 FAST_OPEN_FAST_CONNECT_RETURN, | 96 FAST_OPEN_FAST_CONNECT_RETURN, |
| 97 | 97 |
| 98 // The initial fast open connect attempted returned asynchronously, | 98 // The initial fast open connect attempted returned asynchronously, |
| 99 // indicating that we did not have a cookie for the server. | 99 // indicating that we did not have a cookie for the server. |
| 100 FAST_OPEN_SLOW_CONNECT_RETURN, | 100 FAST_OPEN_SLOW_CONNECT_RETURN, |
| 101 | 101 |
| 102 // Some other error occurred on connection, so we couldn't tell if | 102 // Some other error occurred on connection, so we couldn't tell if |
| 103 // fast open would have worked. | 103 // fast open would have worked. |
| 104 FAST_OPEN_ERROR, | 104 FAST_OPEN_ERROR, |
| 105 | 105 |
| 106 // The initial fast open connect succeeded immediately |
| 107 // (FAST_OPEN_FAST_CONNECT_RETURN) and the attempt to write SYN+DATA failed. |
| 108 FAST_OPEN_FAST_CONNECT_FAILED, |
| 109 |
| 110 // The initial fast open connect failed (FAST_OPEN_SLOW_CONNECT_RETURN) |
| 111 // and the first attempt to write data failed. |
| 112 FAST_OPEN_SLOW_CONNECT_FAILED, |
| 113 |
| 106 // An attempt to do a fast open succeeded immediately | 114 // An attempt to do a fast open succeeded immediately |
| 107 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server | 115 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
| 108 // had acked the data we sent. | 116 // had acked the data we sent. |
| 109 FAST_OPEN_SYN_DATA_ACK, | 117 FAST_OPEN_SYN_DATA_ACK, |
| 110 | 118 |
| 111 // An attempt to do a fast open succeeded immediately | 119 // An attempt to do a fast open succeeded immediately |
| 112 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server | 120 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
| 113 // had nacked the data we sent. | 121 // had nacked the data we sent. |
| 114 FAST_OPEN_SYN_DATA_NACK, | 122 FAST_OPEN_SYN_DATA_NACK, |
| 115 | 123 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 166 |
| 159 void WriteCompleted(const scoped_refptr<IOBuffer>& buf, | 167 void WriteCompleted(const scoped_refptr<IOBuffer>& buf, |
| 160 const CompletionCallback& callback, | 168 const CompletionCallback& callback, |
| 161 int rv) const; | 169 int rv) const; |
| 162 int HandleWriteCompleted(IOBuffer* buf, int rv) const; | 170 int HandleWriteCompleted(IOBuffer* buf, int rv) const; |
| 163 int TcpFastOpenWrite(IOBuffer* buf, | 171 int TcpFastOpenWrite(IOBuffer* buf, |
| 164 int buf_len, | 172 int buf_len, |
| 165 const CompletionCallback& callback); | 173 const CompletionCallback& callback); |
| 166 | 174 |
| 167 // Called when the socket is known to be in a connected state. | 175 // Called when the socket is known to be in a connected state. |
| 168 void RecordFastOpenStatus(); | 176 void RecordTCPFastOpenStatus(); |
| 169 | 177 |
| 170 scoped_ptr<SocketLibevent> socket_; | 178 scoped_ptr<SocketLibevent> socket_; |
| 171 scoped_ptr<SocketLibevent> accept_socket_; | 179 scoped_ptr<SocketLibevent> accept_socket_; |
| 172 | 180 |
| 173 // Enables experimental TCP FastOpen option. | 181 // Enables experimental TCP FastOpen option. |
| 174 bool use_tcp_fastopen_; | 182 bool use_tcp_fastopen_; |
| 175 | 183 // True when TCP FastOpen is in use and we have attempted the |
| 184 // connect with write. |
| 185 bool tcp_fastopen_write_attempted_; |
| 176 // True when TCP FastOpen is in use and we have done the connect. | 186 // True when TCP FastOpen is in use and we have done the connect. |
| 177 bool tcp_fastopen_connected_; | 187 bool tcp_fastopen_connected_; |
| 178 FastOpenStatus fast_open_status_; | 188 TCPFastOpenStatus tcp_fastopen_status_; |
| 179 | 189 |
| 180 bool logging_multiple_connect_attempts_; | 190 bool logging_multiple_connect_attempts_; |
| 181 | 191 |
| 182 BoundNetLog net_log_; | 192 BoundNetLog net_log_; |
| 183 | 193 |
| 184 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent); | 194 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent); |
| 185 }; | 195 }; |
| 186 | 196 |
| 187 } // namespace net | 197 } // namespace net |
| 188 | 198 |
| 189 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ | 199 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ |
| OLD | NEW |