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 "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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "net/base/address_family.h" | 13 #include "net/base/address_family.h" |
14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/base/socket_performance_watcher.h" |
16 #include "net/log/net_log.h" | 17 #include "net/log/net_log.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 class AddressList; | 21 class AddressList; |
21 class IOBuffer; | 22 class IOBuffer; |
22 class IPEndPoint; | 23 class IPEndPoint; |
23 class SocketPosix; | 24 class SocketPosix; |
24 | 25 |
25 class NET_EXPORT TCPSocketPosix { | 26 class NET_EXPORT TCPSocketPosix { |
26 public: | 27 public: |
27 TCPSocketPosix(NetLog* net_log, const NetLog::Source& source); | 28 TCPSocketPosix( |
| 29 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
| 30 NetLog* net_log, |
| 31 const NetLog::Source& source); |
28 virtual ~TCPSocketPosix(); | 32 virtual ~TCPSocketPosix(); |
29 | 33 |
30 int Open(AddressFamily family); | 34 int Open(AddressFamily family); |
31 // Takes ownership of |socket_fd|. | 35 // Takes ownership of |socket_fd|. |
32 int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address); | 36 int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address); |
33 | 37 |
34 int Bind(const IPEndPoint& address); | 38 int Bind(const IPEndPoint& address); |
35 | 39 |
36 int Listen(int backlog); | 40 int Listen(int backlog); |
37 int Accept(scoped_ptr<TCPSocketPosix>* socket, | 41 int Accept(scoped_ptr<TCPSocketPosix>* socket, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 int HandleReadCompleted(IOBuffer* buf, int rv); | 187 int HandleReadCompleted(IOBuffer* buf, int rv); |
184 | 188 |
185 void WriteCompleted(const scoped_refptr<IOBuffer>& buf, | 189 void WriteCompleted(const scoped_refptr<IOBuffer>& buf, |
186 const CompletionCallback& callback, | 190 const CompletionCallback& callback, |
187 int rv); | 191 int rv); |
188 int HandleWriteCompleted(IOBuffer* buf, int rv); | 192 int HandleWriteCompleted(IOBuffer* buf, int rv); |
189 int TcpFastOpenWrite(IOBuffer* buf, | 193 int TcpFastOpenWrite(IOBuffer* buf, |
190 int buf_len, | 194 int buf_len, |
191 const CompletionCallback& callback); | 195 const CompletionCallback& callback); |
192 | 196 |
| 197 void NotifySocketPerformanceWatcher() const; |
| 198 |
193 // Called after the first read completes on a TCP FastOpen socket. | 199 // Called after the first read completes on a TCP FastOpen socket. |
194 void UpdateTCPFastOpenStatusAfterRead(); | 200 void UpdateTCPFastOpenStatusAfterRead(); |
195 | 201 |
196 scoped_ptr<SocketPosix> socket_; | 202 scoped_ptr<SocketPosix> socket_; |
197 scoped_ptr<SocketPosix> accept_socket_; | 203 scoped_ptr<SocketPosix> accept_socket_; |
198 | 204 |
| 205 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher_; |
| 206 |
199 // Enables experimental TCP FastOpen option. | 207 // Enables experimental TCP FastOpen option. |
200 bool use_tcp_fastopen_; | 208 bool use_tcp_fastopen_; |
201 | 209 |
202 // True when TCP FastOpen is in use and we have attempted the | 210 // True when TCP FastOpen is in use and we have attempted the |
203 // connect with write. | 211 // connect with write. |
204 bool tcp_fastopen_write_attempted_; | 212 bool tcp_fastopen_write_attempted_; |
205 | 213 |
206 // True when TCP FastOpen is in use and we have done the connect. | 214 // True when TCP FastOpen is in use and we have done the connect. |
207 bool tcp_fastopen_connected_; | 215 bool tcp_fastopen_connected_; |
208 | 216 |
209 TCPFastOpenStatus tcp_fastopen_status_; | 217 TCPFastOpenStatus tcp_fastopen_status_; |
210 | 218 |
211 bool logging_multiple_connect_attempts_; | 219 bool logging_multiple_connect_attempts_; |
212 | 220 |
213 BoundNetLog net_log_; | 221 BoundNetLog net_log_; |
214 | 222 |
215 DISALLOW_COPY_AND_ASSIGN(TCPSocketPosix); | 223 DISALLOW_COPY_AND_ASSIGN(TCPSocketPosix); |
216 }; | 224 }; |
217 | 225 |
218 } // namespace net | 226 } // namespace net |
219 | 227 |
220 #endif // NET_SOCKET_TCP_SOCKET_POSIX_H_ | 228 #endif // NET_SOCKET_TCP_SOCKET_POSIX_H_ |
OLD | NEW |