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

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

Issue 2447083003: Move fail on suspend logic from URLRequestJob to TcpClientSocket.
Patch Set: Fix connect error case Created 4 years, 1 month 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // Create a |SocketPerformanceWatcher|, and pass the ownership. 293 // Create a |SocketPerformanceWatcher|, and pass the ownership.
294 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher; 294 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher;
295 if (socket_performance_watcher_factory_) { 295 if (socket_performance_watcher_factory_) {
296 socket_performance_watcher = 296 socket_performance_watcher =
297 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( 297 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher(
298 SocketPerformanceWatcherFactory::PROTOCOL_TCP); 298 SocketPerformanceWatcherFactory::PROTOCOL_TCP);
299 } 299 }
300 transport_socket_ = client_socket_factory_->CreateTransportClientSocket( 300 transport_socket_ = client_socket_factory_->CreateTransportClientSocket(
301 addresses_, std::move(socket_performance_watcher), net_log().net_log(), 301 addresses_, std::move(socket_performance_watcher), net_log().net_log(),
302 net_log().source()); 302 net_log().source());
303 transport_socket_->SetFailOnSuspend(true);
303 304
304 // If the list contains IPv6 and IPv4 addresses, the first address will 305 // If the list contains IPv6 and IPv4 addresses, the first address will
305 // be IPv6, and the IPv4 addresses will be tried as fallback addresses, 306 // be IPv6, and the IPv4 addresses will be tried as fallback addresses,
306 // per "Happy Eyeballs" (RFC 6555). 307 // per "Happy Eyeballs" (RFC 6555).
307 bool try_ipv6_connect_with_ipv4_fallback = 308 bool try_ipv6_connect_with_ipv4_fallback =
308 addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV6 && 309 addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV6 &&
309 !AddressListOnlyContainsIPv6(addresses_); 310 !AddressListOnlyContainsIPv6(addresses_);
310 311
311 // Enable TCP FastOpen if indicated by transport socket params. 312 // Enable TCP FastOpen if indicated by transport socket params.
312 // Note: We currently do not turn on TCP FastOpen for destinations where 313 // Note: We currently do not turn on TCP FastOpen for destinations where
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( 384 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher(
384 SocketPerformanceWatcherFactory::PROTOCOL_TCP); 385 SocketPerformanceWatcherFactory::PROTOCOL_TCP);
385 } 386 }
386 387
387 fallback_addresses_.reset(new AddressList(addresses_)); 388 fallback_addresses_.reset(new AddressList(addresses_));
388 MakeAddressListStartWithIPv4(fallback_addresses_.get()); 389 MakeAddressListStartWithIPv4(fallback_addresses_.get());
389 fallback_transport_socket_ = 390 fallback_transport_socket_ =
390 client_socket_factory_->CreateTransportClientSocket( 391 client_socket_factory_->CreateTransportClientSocket(
391 *fallback_addresses_, std::move(socket_performance_watcher), 392 *fallback_addresses_, std::move(socket_performance_watcher),
392 net_log().net_log(), net_log().source()); 393 net_log().net_log(), net_log().source());
394 fallback_transport_socket_->SetFailOnSuspend(true);
393 fallback_connect_start_time_ = base::TimeTicks::Now(); 395 fallback_connect_start_time_ = base::TimeTicks::Now();
394 int rv = fallback_transport_socket_->Connect( 396 int rv = fallback_transport_socket_->Connect(
395 base::Bind( 397 base::Bind(
396 &TransportConnectJob::DoIPv6FallbackTransportConnectComplete, 398 &TransportConnectJob::DoIPv6FallbackTransportConnectComplete,
397 base::Unretained(this))); 399 base::Unretained(this)));
398 if (rv != ERR_IO_PENDING) 400 if (rv != ERR_IO_PENDING)
399 DoIPv6FallbackTransportConnectComplete(rv); 401 DoIPv6FallbackTransportConnectComplete(rv);
400 } 402 }
401 403
402 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) { 404 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 HigherLayeredPool* higher_pool) { 596 HigherLayeredPool* higher_pool) {
595 base_.AddHigherLayeredPool(higher_pool); 597 base_.AddHigherLayeredPool(higher_pool);
596 } 598 }
597 599
598 void TransportClientSocketPool::RemoveHigherLayeredPool( 600 void TransportClientSocketPool::RemoveHigherLayeredPool(
599 HigherLayeredPool* higher_pool) { 601 HigherLayeredPool* higher_pool) {
600 base_.RemoveHigherLayeredPool(higher_pool); 602 base_.RemoveHigherLayeredPool(higher_pool);
601 } 603 }
602 604
603 } // namespace net 605 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698