[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
tfarina | 4eb7aad8 | 2015-09-14 17:10:34 | [diff] [blame] | 5 | #ifndef NET_SOCKET_TCP_SOCKET_POSIX_H_ |
| 6 | #define NET_SOCKET_TCP_SOCKET_POSIX_H_ |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 7 | |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 12 | #include "base/callback.h" |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 13 | #include "base/compiler_specific.h" |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 14 | #include "base/macros.h" |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 15 | #include "net/base/address_family.h" |
| 16 | #include "net/base/completion_callback.h" |
| 17 | #include "net/base/net_export.h" |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 18 | #include "net/log/net_log_with_source.h" |
tbansal | ca83c00 | 2016-04-28 20:56:28 | [diff] [blame] | 19 | #include "net/socket/socket_performance_watcher.h" |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 20 | |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 21 | namespace base { |
tbansal | 180587c | 2017-02-16 15:13:23 | [diff] [blame] | 22 | class TimeDelta; |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 23 | } |
| 24 | |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 25 | namespace net { |
| 26 | |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 27 | class AddressList; |
| 28 | class IOBuffer; |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 29 | class IPEndPoint; |
tfarina | 4eb7aad8 | 2015-09-14 17:10:34 | [diff] [blame] | 30 | class SocketPosix; |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 31 | class NetLog; |
| 32 | struct NetLogSource; |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 33 | |
tfarina | 4eb7aad8 | 2015-09-14 17:10:34 | [diff] [blame] | 34 | class NET_EXPORT TCPSocketPosix { |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 35 | public: |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 36 | // |socket_performance_watcher| is notified of the performance metrics related |
| 37 | // to this socket. |socket_performance_watcher| may be null. |
| 38 | TCPSocketPosix( |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 39 | std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 40 | NetLog* net_log, |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 41 | const NetLogSource& source); |
tfarina | 4eb7aad8 | 2015-09-14 17:10:34 | [diff] [blame] | 42 | virtual ~TCPSocketPosix(); |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 43 | |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 44 | // Opens the socket. |
| 45 | // Returns a net error code. |
[email protected] | c9080d8 | 2013-09-15 15:14:16 | [diff] [blame] | 46 | int Open(AddressFamily family); |
tfarina | a0922c8 | 2017-04-15 11:54:49 | [diff] [blame] | 47 | |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 48 | // Takes ownership of |socket_fd|. |
| 49 | int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 50 | |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 51 | // Binds this socket to |address|. This is generally only used on a server. |
| 52 | // Should be called after Open(). Returns a net error code. |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 53 | int Bind(const IPEndPoint& address); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 54 | |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 55 | // Put this socket on listen state with the given |backlog|. |
| 56 | // Returns a net error code. |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 57 | int Listen(int backlog); |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 58 | |
| 59 | // Accepts incoming connection. |
| 60 | // Returns a net error code. |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 61 | int Accept(std::unique_ptr<TCPSocketPosix>* socket, |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 62 | IPEndPoint* address, |
| 63 | const CompletionCallback& callback); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 64 | |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 65 | // Connects this socket to the given |address|. |
| 66 | // Should be called after Open(). |
| 67 | // Returns a net error code. |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 68 | int Connect(const IPEndPoint& address, const CompletionCallback& callback); |
| 69 | bool IsConnected() const; |
| 70 | bool IsConnectedAndIdle() const; |
| 71 | |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 72 | // IO: |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 73 | // Multiple outstanding requests are not supported. |
| 74 | // Full duplex mode (reading and writing at the same time) is supported. |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 75 | |
| 76 | // Reads from the socket. |
| 77 | // Returns a net error code. |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 78 | int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
xunjieli | 321a96f3 | 2017-03-07 19:42:17 | [diff] [blame] | 79 | int ReadIfReady(IOBuffer* buf, |
| 80 | int buf_len, |
| 81 | const CompletionCallback& callback); |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 82 | |
| 83 | // Writes to the socket. |
| 84 | // Returns a net error code. |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 85 | int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
| 86 | |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 87 | // Copies the local tcp address into |address| and returns a net error code. |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 88 | int GetLocalAddress(IPEndPoint* address) const; |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 89 | |
| 90 | // Copies the remote tcp code into |address| and returns a net error code. |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 91 | int GetPeerAddress(IPEndPoint* address) const; |
| 92 | |
| 93 | // Sets various socket options. |
| 94 | // The commonly used options for server listening sockets: |
tfarina | a0922c8 | 2017-04-15 11:54:49 | [diff] [blame] | 95 | // - AllowAddressReuse(). |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 96 | int SetDefaultOptionsForServer(); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 97 | // The commonly used options for client sockets and accepted sockets: |
| 98 | // - SetNoDelay(true); |
| 99 | // - SetKeepAlive(true, 45). |
| 100 | void SetDefaultOptionsForClient(); |
tfarina | a0922c8 | 2017-04-15 11:54:49 | [diff] [blame] | 101 | int AllowAddressReuse(); |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 102 | int SetReceiveBufferSize(int32_t size); |
| 103 | int SetSendBufferSize(int32_t size); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 104 | bool SetKeepAlive(bool enable, int delay); |
| 105 | bool SetNoDelay(bool no_delay); |
| 106 | |
bmcquade | 8b62f47 | 2015-07-08 16:03:54 | [diff] [blame] | 107 | // Gets the estimated RTT. Returns false if the RTT is |
| 108 | // unavailable. May also return false when estimated RTT is 0. |
| 109 | bool GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const |
| 110 | WARN_UNUSED_RESULT; |
| 111 | |
tfarina | fdec305 | 2017-04-25 13:36:25 | [diff] [blame^] | 112 | // Closes the socket. |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 113 | void Close(); |
| 114 | |
jri | dcb4ae92 | 2014-09-12 23:52:39 | [diff] [blame] | 115 | void EnableTCPFastOpenIfSupported(); |
| 116 | |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 117 | bool IsValid() const; |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 118 | |
svaldez | 58804c40 | 2015-10-06 00:13:47 | [diff] [blame] | 119 | // Detachs from the current thread, to allow the socket to be transferred to |
| 120 | // a new thread. Should only be called when the object is no longer used by |
| 121 | // the old thread. |
| 122 | void DetachFromThread(); |
| 123 | |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 124 | // Marks the start/end of a series of connect attempts for logging purpose. |
| 125 | // |
| 126 | // TCPClientSocket may attempt to connect to multiple addresses until it |
| 127 | // succeeds in establishing a connection. The corresponding log will have |
mikecirone | 8b85c43 | 2016-09-08 19:11:00 | [diff] [blame] | 128 | // multiple NetLogEventType::TCP_CONNECT_ATTEMPT entries nested within a |
| 129 | // NetLogEventType::TCP_CONNECT. These methods set the start/end of |
| 130 | // NetLogEventType::TCP_CONNECT. |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 131 | // |
| 132 | // TODO(yzshen): Change logging format and let TCPClientSocket log the |
| 133 | // start/end of a series of connect attempts itself. |
| 134 | void StartLoggingMultipleConnectAttempts(const AddressList& addresses); |
| 135 | void EndLoggingMultipleConnectAttempts(int net_error); |
| 136 | |
tfarina | 4283411 | 2016-09-22 13:38:20 | [diff] [blame] | 137 | const NetLogWithSource& net_log() const { return net_log_; } |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 138 | |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 139 | private: |
jri | 23fdae2 | 2014-09-16 23:04:09 | [diff] [blame] | 140 | // States that using a socket with TCP FastOpen can lead to. |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 141 | enum TCPFastOpenStatus { |
| 142 | TCP_FASTOPEN_STATUS_UNKNOWN, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 143 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 144 | // The initial FastOpen connect attempted returned synchronously, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 145 | // indicating that we had and sent a cookie along with the initial data. |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 146 | TCP_FASTOPEN_FAST_CONNECT_RETURN, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 147 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 148 | // The initial FastOpen connect attempted returned asynchronously, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 149 | // indicating that we did not have a cookie for the server. |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 150 | TCP_FASTOPEN_SLOW_CONNECT_RETURN, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 151 | |
| 152 | // Some other error occurred on connection, so we couldn't tell if |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 153 | // FastOpen would have worked. |
| 154 | TCP_FASTOPEN_ERROR, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 155 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 156 | // An attempt to do a FastOpen succeeded immediately |
| 157 | // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 158 | // had acked the data we sent. |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 159 | TCP_FASTOPEN_SYN_DATA_ACK, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 160 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 161 | // An attempt to do a FastOpen succeeded immediately |
| 162 | // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and we later confirmed that the server |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 163 | // had nacked the data we sent. |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 164 | TCP_FASTOPEN_SYN_DATA_NACK, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 165 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 166 | // An attempt to do a FastOpen succeeded immediately |
| 167 | // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and our probe to determine if the |
| 168 | // socket was using FastOpen failed. |
| 169 | TCP_FASTOPEN_SYN_DATA_GETSOCKOPT_FAILED, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 170 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 171 | // An attempt to do a FastOpen failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 172 | // and we later confirmed that the server had acked initial data. This |
| 173 | // should never happen (we didn't send data, so it shouldn't have |
| 174 | // been acked). |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 175 | TCP_FASTOPEN_NO_SYN_DATA_ACK, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 176 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 177 | // An attempt to do a FastOpen failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 178 | // and we later discovered that the server had nacked initial data. This |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 179 | // is the expected case results for TCP_FASTOPEN_SLOW_CONNECT_RETURN. |
| 180 | TCP_FASTOPEN_NO_SYN_DATA_NACK, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 181 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 182 | // An attempt to do a FastOpen failed (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 183 | // and our later probe for ack/nack state failed. |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 184 | TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED, |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 185 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 186 | // The initial FastOpen connect+write succeeded immediately |
| 187 | // (TCP_FASTOPEN_FAST_CONNECT_RETURN) and a subsequent attempt to read from |
| 188 | // the connection failed. |
| 189 | TCP_FASTOPEN_FAST_CONNECT_READ_FAILED, |
| 190 | |
| 191 | // The initial FastOpen connect+write failed |
| 192 | // (TCP_FASTOPEN_SLOW_CONNECT_RETURN) |
| 193 | // and a subsequent attempt to read from the connection failed. |
| 194 | TCP_FASTOPEN_SLOW_CONNECT_READ_FAILED, |
| 195 | |
| 196 | // We didn't try FastOpen because it had failed in the past |
| 197 | // (g_tcp_fastopen_has_failed was true.) |
| 198 | // NOTE: This status is currently registered before a connect/write call |
| 199 | // is attempted, and may capture some cases where the status is registered |
| 200 | // but no connect is subsequently attempted. |
| 201 | // TODO(jri): The expectation is that such cases are not the common case |
| 202 | // with TCP FastOpen for SSL sockets however. Change code to be more |
| 203 | // accurate when TCP FastOpen is used for more than just SSL sockets. |
| 204 | TCP_FASTOPEN_PREVIOUSLY_FAILED, |
| 205 | |
| 206 | TCP_FASTOPEN_MAX_VALUE |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 207 | }; |
| 208 | |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 209 | void AcceptCompleted(std::unique_ptr<TCPSocketPosix>* tcp_socket, |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 210 | IPEndPoint* address, |
| 211 | const CompletionCallback& callback, |
| 212 | int rv); |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 213 | int HandleAcceptCompleted(std::unique_ptr<TCPSocketPosix>* tcp_socket, |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 214 | IPEndPoint* address, |
| 215 | int rv); |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 216 | int BuildTcpSocketPosix(std::unique_ptr<TCPSocketPosix>* tcp_socket, |
tfarina | 4eb7aad8 | 2015-09-14 17:10:34 | [diff] [blame] | 217 | IPEndPoint* address); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 218 | |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 219 | void ConnectCompleted(const CompletionCallback& callback, int rv); |
| 220 | int HandleConnectCompleted(int rv); |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 221 | void LogConnectBegin(const AddressList& addresses) const; |
| 222 | void LogConnectEnd(int net_error) const; |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 223 | |
[email protected] | 573e6cc | 2014-07-12 00:33:03 | [diff] [blame] | 224 | void ReadCompleted(const scoped_refptr<IOBuffer>& buf, |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 225 | const CompletionCallback& callback, |
| 226 | int rv); |
xunjieli | 321a96f3 | 2017-03-07 19:42:17 | [diff] [blame] | 227 | void ReadIfReadyCompleted(const CompletionCallback& callback, int rv); |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 228 | int HandleReadCompleted(IOBuffer* buf, int rv); |
xunjieli | 321a96f3 | 2017-03-07 19:42:17 | [diff] [blame] | 229 | void HandleReadCompletedHelper(int rv); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 230 | |
[email protected] | 573e6cc | 2014-07-12 00:33:03 | [diff] [blame] | 231 | void WriteCompleted(const scoped_refptr<IOBuffer>& buf, |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 232 | const CompletionCallback& callback, |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 233 | int rv); |
| 234 | int HandleWriteCompleted(IOBuffer* buf, int rv); |
[email protected] | 2ef2b0e | 2014-07-09 21:12:34 | [diff] [blame] | 235 | int TcpFastOpenWrite(IOBuffer* buf, |
| 236 | int buf_len, |
| 237 | const CompletionCallback& callback); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 238 | |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 239 | // Notifies |socket_performance_watcher_| of the latest RTT estimate available |
| 240 | // from the tcp_info struct for this TCP socket. |
| 241 | void NotifySocketPerformanceWatcher(); |
| 242 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 243 | // Called after the first read completes on a TCP FastOpen socket. |
| 244 | void UpdateTCPFastOpenStatusAfterRead(); |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 245 | |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 246 | std::unique_ptr<SocketPosix> socket_; |
| 247 | std::unique_ptr<SocketPosix> accept_socket_; |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 248 | |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 249 | // Socket performance statistics (such as RTT) are reported to the |
| 250 | // |socket_performance_watcher_|. May be nullptr. |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 251 | std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher_; |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 252 | |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 253 | // Enables experimental TCP FastOpen option. |
jri | dcb4ae92 | 2014-09-12 23:52:39 | [diff] [blame] | 254 | bool use_tcp_fastopen_; |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 255 | |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 256 | // True when TCP FastOpen is in use and we have attempted the |
| 257 | // connect with write. |
| 258 | bool tcp_fastopen_write_attempted_; |
| 259 | |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 260 | // True when TCP FastOpen is in use and we have done the connect. |
| 261 | bool tcp_fastopen_connected_; |
jri | 76442544 | 2014-10-02 01:53:41 | [diff] [blame] | 262 | |
| 263 | TCPFastOpenStatus tcp_fastopen_status_; |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 264 | |
[email protected] | 659fd67c | 2013-09-18 21:50:26 | [diff] [blame] | 265 | bool logging_multiple_connect_attempts_; |
| 266 | |
tfarina | 4283411 | 2016-09-22 13:38:20 | [diff] [blame] | 267 | NetLogWithSource net_log_; |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 268 | |
tfarina | 4eb7aad8 | 2015-09-14 17:10:34 | [diff] [blame] | 269 | DISALLOW_COPY_AND_ASSIGN(TCPSocketPosix); |
[email protected] | 21160f0 | 2013-09-01 23:04:27 | [diff] [blame] | 270 | }; |
| 271 | |
| 272 | } // namespace net |
| 273 | |
tfarina | 4eb7aad8 | 2015-09-14 17:10:34 | [diff] [blame] | 274 | #endif // NET_SOCKET_TCP_SOCKET_POSIX_H_ |