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

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

Issue 451383002: Plumbing for TCP FastOpen for SSL sockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added constructor param in TransportSocketParams to enable TFO (and some cleanup) 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 (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 #include "net/socket/transport_client_socket_pool.h" 5 #include "net/socket/transport_client_socket_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 static base::LazyInstance<base::TimeTicks>::Leaky 56 static base::LazyInstance<base::TimeTicks>::Leaky
57 g_last_connect_time = LAZY_INSTANCE_INITIALIZER; 57 g_last_connect_time = LAZY_INSTANCE_INITIALIZER;
58 58
59 TransportSocketParams::TransportSocketParams( 59 TransportSocketParams::TransportSocketParams(
60 const HostPortPair& host_port_pair, 60 const HostPortPair& host_port_pair,
61 bool disable_resolver_cache, 61 bool disable_resolver_cache,
62 bool ignore_limits, 62 bool ignore_limits,
63 const OnHostResolutionCallback& host_resolution_callback) 63 const OnHostResolutionCallback& host_resolution_callback)
64 : destination_(host_port_pair), 64 : destination_(host_port_pair),
65 ignore_limits_(ignore_limits), 65 ignore_limits_(ignore_limits),
66 host_resolution_callback_(host_resolution_callback) { 66 host_resolution_callback_(host_resolution_callback),
67 use_tcp_fastopen_if_supported_(false) {
67 if (disable_resolver_cache) 68 if (disable_resolver_cache)
68 destination_.set_allow_cached_response(false); 69 destination_.set_allow_cached_response(false);
69 } 70 }
71
72 TransportSocketParams::TransportSocketParams(
73 const HostPortPair& host_port_pair,
74 bool disable_resolver_cache,
75 bool ignore_limits,
76 const OnHostResolutionCallback& host_resolution_callback,
77 bool use_tcp_fastopen_if_supported)
78 : destination_(host_port_pair),
79 ignore_limits_(ignore_limits),
80 host_resolution_callback_(host_resolution_callback),
81 use_tcp_fastopen_if_supported_(use_tcp_fastopen_if_supported) {
82 if (disable_resolver_cache)
83 destination_.set_allow_cached_response(false);
84 }
70 85
71 TransportSocketParams::~TransportSocketParams() {} 86 TransportSocketParams::~TransportSocketParams() {}
72 87
73 // TransportConnectJobs will time out after this many seconds. Note this is 88 // TransportConnectJobs will time out after this many seconds. Note this is
74 // the total time, including both host resolution and TCP connect() times. 89 // the total time, including both host resolution and TCP connect() times.
75 // 90 //
76 // TODO(eroman): The use of this constant needs to be re-evaluated. The time 91 // TODO(eroman): The use of this constant needs to be re-evaluated. The time
77 // needed for TCPClientSocketXXX::Connect() can be arbitrarily long, since 92 // needed for TCPClientSocketXXX::Connect() can be arbitrarily long, since
78 // the address list may contain many alternatives, and most of those may 93 // the address list may contain many alternatives, and most of those may
79 // timeout. Even worse, the per-connect timeout threshold varies greatly 94 // timeout. Even worse, the per-connect timeout threshold varies greatly
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS; 269 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS;
255 else 270 else
256 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS; 271 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS;
257 } 272 }
258 273
259 helper_.set_next_state( 274 helper_.set_next_state(
260 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE); 275 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE);
261 transport_socket_ = 276 transport_socket_ =
262 helper_.client_socket_factory()->CreateTransportClientSocket( 277 helper_.client_socket_factory()->CreateTransportClientSocket(
263 helper_.addresses(), net_log().net_log(), net_log().source()); 278 helper_.addresses(), net_log().net_log(), net_log().source());
279
280 if (helper_.params()->use_tcp_fastopen_if_supported())
281 transport_socket_->EnableTCPFastOpen();
282
264 int rv = transport_socket_->Connect(helper_.on_io_complete()); 283 int rv = transport_socket_->Connect(helper_.on_io_complete());
265 if (rv == ERR_IO_PENDING && 284 if (rv == ERR_IO_PENDING &&
266 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 && 285 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 &&
267 !AddressListOnlyContainsIPv6(helper_.addresses())) { 286 !AddressListOnlyContainsIPv6(helper_.addresses())) {
268 fallback_timer_.Start( 287 fallback_timer_.Start(
269 FROM_HERE, 288 FROM_HERE,
270 base::TimeDelta::FromMilliseconds( 289 base::TimeDelta::FromMilliseconds(
271 TransportConnectJobHelper::kIPv6FallbackTimerInMs), 290 TransportConnectJobHelper::kIPv6FallbackTimerInMs),
272 this, 291 this,
273 &TransportConnectJob::DoIPv6FallbackTransportConnect); 292 &TransportConnectJob::DoIPv6FallbackTransportConnect);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 HigherLayeredPool* higher_pool) { 554 HigherLayeredPool* higher_pool) {
536 base_.AddHigherLayeredPool(higher_pool); 555 base_.AddHigherLayeredPool(higher_pool);
537 } 556 }
538 557
539 void TransportClientSocketPool::RemoveHigherLayeredPool( 558 void TransportClientSocketPool::RemoveHigherLayeredPool(
540 HigherLayeredPool* higher_pool) { 559 HigherLayeredPool* higher_pool) {
541 base_.RemoveHigherLayeredPool(higher_pool); 560 base_.RemoveHigherLayeredPool(higher_pool);
542 } 561 }
543 562
544 } // namespace net 563 } // namespace net
OLDNEW
« net/socket/tcp_socket_libevent.cc ('K') | « net/socket/transport_client_socket_pool.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698