| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // NetLog::TYPE_TCP_CONNECT. | 77 // NetLog::TYPE_TCP_CONNECT. |
| 78 // | 78 // |
| 79 // TODO(yzshen): Change logging format and let TCPClientSocket log the | 79 // TODO(yzshen): Change logging format and let TCPClientSocket log the |
| 80 // start/end of a series of connect attempts itself. | 80 // start/end of a series of connect attempts itself. |
| 81 void StartLoggingMultipleConnectAttempts(const AddressList& addresses); | 81 void StartLoggingMultipleConnectAttempts(const AddressList& addresses); |
| 82 void EndLoggingMultipleConnectAttempts(int net_error); | 82 void EndLoggingMultipleConnectAttempts(int net_error); |
| 83 | 83 |
| 84 const BoundNetLog& net_log() const { return net_log_; } | 84 const BoundNetLog& net_log() const { return net_log_; } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 // States that a fast open socket attempt can result in. | 87 // States that using a socket with TCP FastOpen can lead to. |
| 88 enum FastOpenStatus { | 88 enum FastOpenStatus { |
| 89 FAST_OPEN_STATUS_UNKNOWN, | 89 FAST_OPEN_STATUS_UNKNOWN, |
| 90 | 90 |
| 91 // The initial fast open connect attempted returned synchronously, | 91 // The initial TCP FastOpen connect attempted returned synchronously, |
| 92 // indicating that we had and sent a cookie along with the initial data. | 92 // indicating that we had and sent a cookie along with the initial data. |
| 93 FAST_OPEN_FAST_CONNECT_RETURN, | 93 FAST_OPEN_FAST_CONNECT_RETURN, |
| 94 | 94 |
| 95 // The initial fast open connect attempted returned asynchronously, | 95 // The initial TCP FastOpen connect attempted returned asynchronously, |
| 96 // indicating that we did not have a cookie for the server. | 96 // indicating that we did not have a cookie for the server. |
| 97 FAST_OPEN_SLOW_CONNECT_RETURN, | 97 FAST_OPEN_SLOW_CONNECT_RETURN, |
| 98 | 98 |
| 99 // Some other error occurred on connection, so we couldn't tell if | 99 // Some other error occurred on connection, so we couldn't tell if |
| 100 // fast open would have worked. | 100 // TCP FastOpen would have worked. |
| 101 FAST_OPEN_ERROR, | 101 FAST_OPEN_ERROR, |
| 102 | 102 |
| 103 // An attempt to do a fast open succeeded immediately | 103 // An attempt to do a TCP FastOpen succeeded immediately |
| 104 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server | 104 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
| 105 // had acked the data we sent. | 105 // had acked the data we sent. |
| 106 FAST_OPEN_SYN_DATA_ACK, | 106 FAST_OPEN_SYN_DATA_ACK, |
| 107 | 107 |
| 108 // An attempt to do a fast open succeeded immediately | 108 // An attempt to do a TCP FastOpen succeeded immediately |
| 109 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server | 109 // (FAST_OPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
| 110 // had nacked the data we sent. | 110 // had nacked the data we sent. |
| 111 FAST_OPEN_SYN_DATA_NACK, | 111 FAST_OPEN_SYN_DATA_NACK, |
| 112 | 112 |
| 113 // An attempt to do a fast open succeeded immediately | 113 // An attempt to do a TCP FastOpen succeeded immediately |
| 114 // (FAST_OPEN_FAST_CONNECT_RETURN) and our probe to determine if the | 114 // (FAST_OPEN_FAST_CONNECT_RETURN) and our probe to determine if the |
| 115 // socket was using fast open failed. | 115 // socket was using TCP FastOpen failed. |
| 116 FAST_OPEN_SYN_DATA_FAILED, | 116 FAST_OPEN_SYN_DATA_FAILED, |
| 117 | 117 |
| 118 // An attempt to do a fast open failed (FAST_OPEN_SLOW_CONNECT_RETURN) | 118 // An attempt to do a TCP FastOpen failed (FAST_OPEN_SLOW_CONNECT_RETURN) |
| 119 // and we later confirmed that the server had acked initial data. This | 119 // and we later confirmed that the server had acked initial data. This |
| 120 // should never happen (we didn't send data, so it shouldn't have | 120 // should never happen (we didn't send data, so it shouldn't have |
| 121 // been acked). | 121 // been acked). |
| 122 FAST_OPEN_NO_SYN_DATA_ACK, | 122 FAST_OPEN_NO_SYN_DATA_ACK, |
| 123 | 123 |
| 124 // An attempt to do a fast open failed (FAST_OPEN_SLOW_CONNECT_RETURN) | 124 // An attempt to do a TCP FastOpen failed (FAST_OPEN_SLOW_CONNECT_RETURN) |
| 125 // and we later discovered that the server had nacked initial data. This | 125 // and we later discovered that the server had nacked initial data. This |
| 126 // is the expected case results for FAST_OPEN_SLOW_CONNECT_RETURN. | 126 // is the expected case results for FAST_OPEN_SLOW_CONNECT_RETURN. |
| 127 FAST_OPEN_NO_SYN_DATA_NACK, | 127 FAST_OPEN_NO_SYN_DATA_NACK, |
| 128 | 128 |
| 129 // An attempt to do a fast open failed (FAST_OPEN_SLOW_CONNECT_RETURN) | 129 // An attempt to do a TCP FastOpen failed (FAST_OPEN_SLOW_CONNECT_RETURN) |
| 130 // and our later probe for ack/nack state failed. | 130 // and our later probe for ack/nack state failed. |
| 131 FAST_OPEN_NO_SYN_DATA_FAILED, | 131 FAST_OPEN_NO_SYN_DATA_FAILED, |
| 132 | 132 |
| 133 FAST_OPEN_MAX_VALUE | 133 FAST_OPEN_MAX_VALUE |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 void AcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket, | 136 void AcceptCompleted(scoped_ptr<TCPSocketLibevent>* tcp_socket, |
| 137 IPEndPoint* address, | 137 IPEndPoint* address, |
| 138 const CompletionCallback& callback, | 138 const CompletionCallback& callback, |
| 139 int rv); | 139 int rv); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 bool logging_multiple_connect_attempts_; | 178 bool logging_multiple_connect_attempts_; |
| 179 | 179 |
| 180 BoundNetLog net_log_; | 180 BoundNetLog net_log_; |
| 181 | 181 |
| 182 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent); | 182 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent); |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 } // namespace net | 185 } // namespace net |
| 186 | 186 |
| 187 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ | 187 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ |
| OLD | NEW |