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_POSIX_H_ | 5 #ifndef NET_SOCKET_TCP_SOCKET_POSIX_H_ |
6 #define NET_SOCKET_TCP_SOCKET_POSIX_H_ | 6 #define NET_SOCKET_TCP_SOCKET_POSIX_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "net/base/address_family.h" | 15 #include "net/base/address_family.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
18 #include "net/base/socket_performance_watcher.h" | |
bengr
2016/02/08 18:51:14
Can this be a forward declaration?
tbansal1
2016/02/08 21:33:26
No, that gives compiler error: gnu/4.6/../../../..
bengr
2016/02/08 23:42:06
Acknowledged.
| |
18 #include "net/log/net_log.h" | 19 #include "net/log/net_log.h" |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 class AddressList; | 23 class AddressList; |
23 class IOBuffer; | 24 class IOBuffer; |
24 class IPEndPoint; | 25 class IPEndPoint; |
25 class SocketPosix; | 26 class SocketPosix; |
26 | 27 |
27 class NET_EXPORT TCPSocketPosix { | 28 class NET_EXPORT TCPSocketPosix { |
28 public: | 29 public: |
29 TCPSocketPosix(NetLog* net_log, const NetLog::Source& source); | 30 TCPSocketPosix( |
31 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, | |
32 NetLog* net_log, | |
33 const NetLog::Source& source); | |
30 virtual ~TCPSocketPosix(); | 34 virtual ~TCPSocketPosix(); |
31 | 35 |
32 int Open(AddressFamily family); | 36 int Open(AddressFamily family); |
33 // Takes ownership of |socket_fd|. | 37 // Takes ownership of |socket_fd|. |
34 int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address); | 38 int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address); |
35 | 39 |
36 int Bind(const IPEndPoint& address); | 40 int Bind(const IPEndPoint& address); |
37 | 41 |
38 int Listen(int backlog); | 42 int Listen(int backlog); |
39 int Accept(scoped_ptr<TCPSocketPosix>* socket, | 43 int Accept(scoped_ptr<TCPSocketPosix>* socket, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 int HandleReadCompleted(IOBuffer* buf, int rv); | 194 int HandleReadCompleted(IOBuffer* buf, int rv); |
191 | 195 |
192 void WriteCompleted(const scoped_refptr<IOBuffer>& buf, | 196 void WriteCompleted(const scoped_refptr<IOBuffer>& buf, |
193 const CompletionCallback& callback, | 197 const CompletionCallback& callback, |
194 int rv); | 198 int rv); |
195 int HandleWriteCompleted(IOBuffer* buf, int rv); | 199 int HandleWriteCompleted(IOBuffer* buf, int rv); |
196 int TcpFastOpenWrite(IOBuffer* buf, | 200 int TcpFastOpenWrite(IOBuffer* buf, |
197 int buf_len, | 201 int buf_len, |
198 const CompletionCallback& callback); | 202 const CompletionCallback& callback); |
199 | 203 |
204 // Notifies |socket_performance_watcher_| of the latest RTT estimate available | |
205 // from the tcp_info struct for this TCP socket. | |
206 void NotifySocketPerformanceWatcher() const; | |
207 | |
200 // Called after the first read completes on a TCP FastOpen socket. | 208 // Called after the first read completes on a TCP FastOpen socket. |
201 void UpdateTCPFastOpenStatusAfterRead(); | 209 void UpdateTCPFastOpenStatusAfterRead(); |
202 | 210 |
203 scoped_ptr<SocketPosix> socket_; | 211 scoped_ptr<SocketPosix> socket_; |
204 scoped_ptr<SocketPosix> accept_socket_; | 212 scoped_ptr<SocketPosix> accept_socket_; |
205 | 213 |
214 // Socket performance statistics (such as RTT) are reported to the | |
215 // |socket_performance_watcher_|. May be nullptr. | |
216 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher_; | |
217 | |
206 // Enables experimental TCP FastOpen option. | 218 // Enables experimental TCP FastOpen option. |
207 bool use_tcp_fastopen_; | 219 bool use_tcp_fastopen_; |
208 | 220 |
209 // True when TCP FastOpen is in use and we have attempted the | 221 // True when TCP FastOpen is in use and we have attempted the |
210 // connect with write. | 222 // connect with write. |
211 bool tcp_fastopen_write_attempted_; | 223 bool tcp_fastopen_write_attempted_; |
212 | 224 |
213 // True when TCP FastOpen is in use and we have done the connect. | 225 // True when TCP FastOpen is in use and we have done the connect. |
214 bool tcp_fastopen_connected_; | 226 bool tcp_fastopen_connected_; |
215 | 227 |
216 TCPFastOpenStatus tcp_fastopen_status_; | 228 TCPFastOpenStatus tcp_fastopen_status_; |
217 | 229 |
218 bool logging_multiple_connect_attempts_; | 230 bool logging_multiple_connect_attempts_; |
219 | 231 |
220 BoundNetLog net_log_; | 232 BoundNetLog net_log_; |
221 | 233 |
222 DISALLOW_COPY_AND_ASSIGN(TCPSocketPosix); | 234 DISALLOW_COPY_AND_ASSIGN(TCPSocketPosix); |
223 }; | 235 }; |
224 | 236 |
225 } // namespace net | 237 } // namespace net |
226 | 238 |
227 #endif // NET_SOCKET_TCP_SOCKET_POSIX_H_ | 239 #endif // NET_SOCKET_TCP_SOCKET_POSIX_H_ |
OLD | NEW |