Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: net/socket/tcp_socket_libevent.h

Issue 451383002: Plumbing for TCP FastOpen for SSL sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved TFO enabling to client_socket_pool_manager and cleaned up tcp_socket.cc (added tcp_socket.cc … Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/address_family.h" 12 #include "net/base/address_family.h"
13 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
14 #include "net/base/net_export.h" 14 #include "net/base/net_export.h"
15 #include "net/base/net_log.h" 15 #include "net/base/net_log.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 class AddressList; 19 class AddressList;
20 class IOBuffer; 20 class IOBuffer;
21 class IPEndPoint; 21 class IPEndPoint;
22 class SocketLibevent; 22 class SocketLibevent;
23 23
24 // Checks if TCP FastOpen is supported by the kernel. Also enables TFO for all
25 // connections if indicated by user.
26 // Not thread safe. Must be called during initialization/startup only.
27 NET_EXPORT void CheckSupportAndMaybeEnableTCPFastOpen(bool user_enabled);
28
24 class NET_EXPORT TCPSocketLibevent { 29 class NET_EXPORT TCPSocketLibevent {
25 public: 30 public:
26 TCPSocketLibevent(NetLog* net_log, const NetLog::Source& source); 31 TCPSocketLibevent(NetLog* net_log, const NetLog::Source& source);
27 virtual ~TCPSocketLibevent(); 32 virtual ~TCPSocketLibevent();
28 33
29 int Open(AddressFamily family); 34 int Open(AddressFamily family);
30 // Takes ownership of |socket_fd|. 35 // Takes ownership of |socket_fd|.
31 int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address); 36 int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address);
32 37
33 int Bind(const IPEndPoint& address); 38 int Bind(const IPEndPoint& address);
(...skipping 24 matching lines...) Expand all
58 // - SetKeepAlive(true, 45). 63 // - SetKeepAlive(true, 45).
59 void SetDefaultOptionsForClient(); 64 void SetDefaultOptionsForClient();
60 int SetAddressReuse(bool allow); 65 int SetAddressReuse(bool allow);
61 int SetReceiveBufferSize(int32 size); 66 int SetReceiveBufferSize(int32 size);
62 int SetSendBufferSize(int32 size); 67 int SetSendBufferSize(int32 size);
63 bool SetKeepAlive(bool enable, int delay); 68 bool SetKeepAlive(bool enable, int delay);
64 bool SetNoDelay(bool no_delay); 69 bool SetNoDelay(bool no_delay);
65 70
66 void Close(); 71 void Close();
67 72
73 // Setter/Getter methods for TCP FastOpen socket option.
68 bool UsingTCPFastOpen() const; 74 bool UsingTCPFastOpen() const;
75 void EnableTCPFastOpen();
76
69 bool IsValid() const; 77 bool IsValid() const;
70 78
71 // Marks the start/end of a series of connect attempts for logging purpose. 79 // Marks the start/end of a series of connect attempts for logging purpose.
72 // 80 //
73 // TCPClientSocket may attempt to connect to multiple addresses until it 81 // TCPClientSocket may attempt to connect to multiple addresses until it
74 // succeeds in establishing a connection. The corresponding log will have 82 // succeeds in establishing a connection. The corresponding log will have
75 // multiple NetLog::TYPE_TCP_CONNECT_ATTEMPT entries nested within a 83 // multiple NetLog::TYPE_TCP_CONNECT_ATTEMPT entries nested within a
76 // NetLog::TYPE_TCP_CONNECT. These methods set the start/end of 84 // NetLog::TYPE_TCP_CONNECT. These methods set the start/end of
77 // NetLog::TYPE_TCP_CONNECT. 85 // NetLog::TYPE_TCP_CONNECT.
78 // 86 //
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 int buf_len, 169 int buf_len,
162 const CompletionCallback& callback); 170 const CompletionCallback& callback);
163 171
164 // Called when the socket is known to be in a connected state. 172 // Called when the socket is known to be in a connected state.
165 void RecordFastOpenStatus(); 173 void RecordFastOpenStatus();
166 174
167 scoped_ptr<SocketLibevent> socket_; 175 scoped_ptr<SocketLibevent> socket_;
168 scoped_ptr<SocketLibevent> accept_socket_; 176 scoped_ptr<SocketLibevent> accept_socket_;
169 177
170 // Enables experimental TCP FastOpen option. 178 // Enables experimental TCP FastOpen option.
171 const bool use_tcp_fastopen_; 179 bool use_tcp_fastopen_;
172 180
173 // True when TCP FastOpen is in use and we have done the connect. 181 // True when TCP FastOpen is in use and we have done the connect.
174 bool tcp_fastopen_connected_; 182 bool tcp_fastopen_connected_;
175 183 FastOpenStatus fast_open_status_;
176 FastOpenStatus fast_open_status_;
177 184
178 bool logging_multiple_connect_attempts_; 185 bool logging_multiple_connect_attempts_;
179 186
180 BoundNetLog net_log_; 187 BoundNetLog net_log_;
181 188
182 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent); 189 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent);
183 }; 190 };
184 191
185 } // namespace net 192 } // namespace net
186 193
187 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ 194 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698