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

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

Issue 451383002: Plumbing for TCP FastOpen for SSL sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests now working as intended. Created 6 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_TRANSPORT_CLIENT_SOCKET_POOL_H_ 5 #ifndef NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
6 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ 6 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 11 matching lines...) Expand all
22 namespace net { 22 namespace net {
23 23
24 class ClientSocketFactory; 24 class ClientSocketFactory;
25 25
26 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)> 26 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)>
27 OnHostResolutionCallback; 27 OnHostResolutionCallback;
28 28
29 class NET_EXPORT_PRIVATE TransportSocketParams 29 class NET_EXPORT_PRIVATE TransportSocketParams
30 : public base::RefCounted<TransportSocketParams> { 30 : public base::RefCounted<TransportSocketParams> {
31 public: 31 public:
32 // CombineConnectAndWrite currently translates to using TCP FastOpen.
33 // TCP FastOpen should not be used if the first write to the socket may
34 // be non-idempotent, as the underlying socket could retransmit the data
35 // on failure of the first transmission.
36 // NOTE: Currently, COMBINE_CONNECT_AND_WRITE_DESIRED is used if the data in
37 // the write is known to be idempotent, and COMBINE_CONNECT_AND_WRITE_DEFAULT
38 // is used as a default for other cases (including non-idempotent writes).
39 enum CombineConnectAndWritePolicy {
40 COMBINE_CONNECT_AND_WRITE_DEFAULT, // Default policy, implemented in
41 // TransportSocketParams constructor.
42 COMBINE_CONNECT_AND_WRITE_DESIRED, // Combine if supported by socket.
43 COMBINE_CONNECT_AND_WRITE_PROHIBITED // Do not combine.
44 };
45
32 // |host_resolution_callback| will be invoked after the the hostname is 46 // |host_resolution_callback| will be invoked after the the hostname is
33 // resolved. If |host_resolution_callback| does not return OK, then the 47 // resolved. If |host_resolution_callback| does not return OK, then the
34 // connection will be aborted with that value. 48 // connection will be aborted with that value. |combine_connect_and_write|
49 // defines the policy for use of TCP FastOpen on this socket.
35 TransportSocketParams( 50 TransportSocketParams(
36 const HostPortPair& host_port_pair, 51 const HostPortPair& host_port_pair,
37 bool disable_resolver_cache, 52 bool disable_resolver_cache,
38 bool ignore_limits, 53 bool ignore_limits,
39 const OnHostResolutionCallback& host_resolution_callback); 54 const OnHostResolutionCallback& host_resolution_callback,
55 CombineConnectAndWritePolicy combine_connect_and_write);
40 56
41 const HostResolver::RequestInfo& destination() const { return destination_; } 57 const HostResolver::RequestInfo& destination() const { return destination_; }
42 bool ignore_limits() const { return ignore_limits_; } 58 bool ignore_limits() const { return ignore_limits_; }
43 const OnHostResolutionCallback& host_resolution_callback() const { 59 const OnHostResolutionCallback& host_resolution_callback() const {
44 return host_resolution_callback_; 60 return host_resolution_callback_;
45 } 61 }
46 62
63 CombineConnectAndWritePolicy combine_connect_and_write() const {
64 return combine_connect_and_write_;
65 }
66
47 private: 67 private:
68 friend class TransportSocketParamsPeer;
48 friend class base::RefCounted<TransportSocketParams>; 69 friend class base::RefCounted<TransportSocketParams>;
49 ~TransportSocketParams(); 70 ~TransportSocketParams();
50 71
51 HostResolver::RequestInfo destination_; 72 HostResolver::RequestInfo destination_;
52 bool ignore_limits_; 73 bool ignore_limits_;
53 const OnHostResolutionCallback host_resolution_callback_; 74 const OnHostResolutionCallback host_resolution_callback_;
75 CombineConnectAndWritePolicy combine_connect_and_write_;
54 76
55 DISALLOW_COPY_AND_ASSIGN(TransportSocketParams); 77 DISALLOW_COPY_AND_ASSIGN(TransportSocketParams);
56 }; 78 };
57 79
58 // Common data and logic shared between TransportConnectJob and 80 // Common data and logic shared between TransportConnectJob and
59 // WebSocketTransportConnectJob. 81 // WebSocketTransportConnectJob.
60 class NET_EXPORT_PRIVATE TransportConnectJobHelper { 82 class NET_EXPORT_PRIVATE TransportConnectJobHelper {
61 public: 83 public:
62 enum State { 84 enum State {
63 STATE_RESOLVE_HOST, 85 STATE_RESOLVE_HOST,
(...skipping 19 matching lines...) Expand all
83 ~TransportConnectJobHelper(); 105 ~TransportConnectJobHelper();
84 106
85 ClientSocketFactory* client_socket_factory() { 107 ClientSocketFactory* client_socket_factory() {
86 return client_socket_factory_; 108 return client_socket_factory_;
87 } 109 }
88 110
89 const AddressList& addresses() const { return addresses_; } 111 const AddressList& addresses() const { return addresses_; }
90 State next_state() const { return next_state_; } 112 State next_state() const { return next_state_; }
91 void set_next_state(State next_state) { next_state_ = next_state; } 113 void set_next_state(State next_state) { next_state_ = next_state; }
92 CompletionCallback on_io_complete() const { return on_io_complete_; } 114 CompletionCallback on_io_complete() const { return on_io_complete_; }
115 const TransportSocketParams* params() { return params_.get(); }
93 116
94 int DoResolveHost(RequestPriority priority, const BoundNetLog& net_log); 117 int DoResolveHost(RequestPriority priority, const BoundNetLog& net_log);
95 int DoResolveHostComplete(int result, const BoundNetLog& net_log); 118 int DoResolveHostComplete(int result, const BoundNetLog& net_log);
96 119
97 template <class T> 120 template <class T>
98 int DoConnectInternal(T* job); 121 int DoConnectInternal(T* job);
99 122
100 template <class T> 123 template <class T>
101 void SetOnIOComplete(T* job); 124 void SetOnIOComplete(T* job);
102 125
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 break; 356 break;
334 } 357 }
335 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); 358 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
336 359
337 return rv; 360 return rv;
338 } 361 }
339 362
340 } // namespace net 363 } // namespace net
341 364
342 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ 365 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698