OLD | NEW |
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // Create a |SocketPerformanceWatcher|, and pass the ownership. | 296 // Create a |SocketPerformanceWatcher|, and pass the ownership. |
297 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher; | 297 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher; |
298 if (socket_performance_watcher_factory_) { | 298 if (socket_performance_watcher_factory_) { |
299 socket_performance_watcher = | 299 socket_performance_watcher = |
300 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( | 300 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( |
301 SocketPerformanceWatcherFactory::PROTOCOL_TCP); | 301 SocketPerformanceWatcherFactory::PROTOCOL_TCP); |
302 } | 302 } |
303 transport_socket_ = client_socket_factory_->CreateTransportClientSocket( | 303 transport_socket_ = client_socket_factory_->CreateTransportClientSocket( |
304 addresses_, std::move(socket_performance_watcher), net_log().net_log(), | 304 addresses_, std::move(socket_performance_watcher), net_log().net_log(), |
305 net_log().source()); | 305 net_log().source()); |
| 306 transport_socket_->SetFailOnSuspend(true); |
306 | 307 |
307 // If the list contains IPv6 and IPv4 addresses, the first address will | 308 // If the list contains IPv6 and IPv4 addresses, the first address will |
308 // be IPv6, and the IPv4 addresses will be tried as fallback addresses, | 309 // be IPv6, and the IPv4 addresses will be tried as fallback addresses, |
309 // per "Happy Eyeballs" (RFC 6555). | 310 // per "Happy Eyeballs" (RFC 6555). |
310 bool try_ipv6_connect_with_ipv4_fallback = | 311 bool try_ipv6_connect_with_ipv4_fallback = |
311 addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV6 && | 312 addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV6 && |
312 !AddressListOnlyContainsIPv6(addresses_); | 313 !AddressListOnlyContainsIPv6(addresses_); |
313 | 314 |
314 // Enable TCP FastOpen if indicated by transport socket params. | 315 // Enable TCP FastOpen if indicated by transport socket params. |
315 // Note: We currently do not turn on TCP FastOpen for destinations where | 316 // Note: We currently do not turn on TCP FastOpen for destinations where |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( | 387 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( |
387 SocketPerformanceWatcherFactory::PROTOCOL_TCP); | 388 SocketPerformanceWatcherFactory::PROTOCOL_TCP); |
388 } | 389 } |
389 | 390 |
390 fallback_addresses_.reset(new AddressList(addresses_)); | 391 fallback_addresses_.reset(new AddressList(addresses_)); |
391 MakeAddressListStartWithIPv4(fallback_addresses_.get()); | 392 MakeAddressListStartWithIPv4(fallback_addresses_.get()); |
392 fallback_transport_socket_ = | 393 fallback_transport_socket_ = |
393 client_socket_factory_->CreateTransportClientSocket( | 394 client_socket_factory_->CreateTransportClientSocket( |
394 *fallback_addresses_, std::move(socket_performance_watcher), | 395 *fallback_addresses_, std::move(socket_performance_watcher), |
395 net_log().net_log(), net_log().source()); | 396 net_log().net_log(), net_log().source()); |
| 397 fallback_transport_socket_->SetFailOnSuspend(true); |
396 fallback_connect_start_time_ = base::TimeTicks::Now(); | 398 fallback_connect_start_time_ = base::TimeTicks::Now(); |
397 int rv = fallback_transport_socket_->Connect( | 399 int rv = fallback_transport_socket_->Connect( |
398 base::Bind( | 400 base::Bind( |
399 &TransportConnectJob::DoIPv6FallbackTransportConnectComplete, | 401 &TransportConnectJob::DoIPv6FallbackTransportConnectComplete, |
400 base::Unretained(this))); | 402 base::Unretained(this))); |
401 if (rv != ERR_IO_PENDING) | 403 if (rv != ERR_IO_PENDING) |
402 DoIPv6FallbackTransportConnectComplete(rv); | 404 DoIPv6FallbackTransportConnectComplete(rv); |
403 } | 405 } |
404 | 406 |
405 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) { | 407 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 HigherLayeredPool* higher_pool) { | 610 HigherLayeredPool* higher_pool) { |
609 base_.AddHigherLayeredPool(higher_pool); | 611 base_.AddHigherLayeredPool(higher_pool); |
610 } | 612 } |
611 | 613 |
612 void TransportClientSocketPool::RemoveHigherLayeredPool( | 614 void TransportClientSocketPool::RemoveHigherLayeredPool( |
613 HigherLayeredPool* higher_pool) { | 615 HigherLayeredPool* higher_pool) { |
614 base_.RemoveHigherLayeredPool(higher_pool); | 616 base_.RemoveHigherLayeredPool(higher_pool); |
615 } | 617 } |
616 | 618 |
617 } // namespace net | 619 } // namespace net |
OLD | NEW |