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 | 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 } else { | 273 } else { |
274 int64 interval = (now - last_connect_time).InMilliseconds(); | 274 int64 interval = (now - last_connect_time).InMilliseconds(); |
275 if (interval <= 10) | 275 if (interval <= 10) |
276 interval_between_connects_ = CONNECT_INTERVAL_LE_10MS; | 276 interval_between_connects_ = CONNECT_INTERVAL_LE_10MS; |
277 else if (interval <= 20) | 277 else if (interval <= 20) |
278 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS; | 278 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS; |
279 else | 279 else |
280 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS; | 280 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS; |
281 } | 281 } |
282 | 282 |
| 283 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. |
| 284 tracked_objects::ScopedTracker tracking_profile1( |
| 285 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 286 "436634 TransportConnectJob::DoTransportConnect1")); |
| 287 |
283 helper_.set_next_state( | 288 helper_.set_next_state( |
284 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE); | 289 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE); |
285 transport_socket_ = | 290 transport_socket_ = |
286 helper_.client_socket_factory()->CreateTransportClientSocket( | 291 helper_.client_socket_factory()->CreateTransportClientSocket( |
287 helper_.addresses(), net_log().net_log(), net_log().source()); | 292 helper_.addresses(), net_log().net_log(), net_log().source()); |
288 | 293 |
289 // If the list contains IPv6 and IPv4 addresses, the first address will | 294 // If the list contains IPv6 and IPv4 addresses, the first address will |
290 // be IPv6, and the IPv4 addresses will be tried as fallback addresses, | 295 // be IPv6, and the IPv4 addresses will be tried as fallback addresses, |
291 // per "Happy Eyeballs" (RFC 6555). | 296 // per "Happy Eyeballs" (RFC 6555). |
292 bool try_ipv6_connect_with_ipv4_fallback = | 297 bool try_ipv6_connect_with_ipv4_fallback = |
293 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 && | 298 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV6 && |
294 !AddressListOnlyContainsIPv6(helper_.addresses()); | 299 !AddressListOnlyContainsIPv6(helper_.addresses()); |
295 | 300 |
296 // Enable TCP FastOpen if indicated by transport socket params. | 301 // Enable TCP FastOpen if indicated by transport socket params. |
297 // Note: We currently do not turn on TCP FastOpen for destinations where | 302 // Note: We currently do not turn on TCP FastOpen for destinations where |
298 // we try a TCP connect over IPv6 with fallback to IPv4. | 303 // we try a TCP connect over IPv6 with fallback to IPv4. |
299 if (!try_ipv6_connect_with_ipv4_fallback && | 304 if (!try_ipv6_connect_with_ipv4_fallback && |
300 helper_.params()->combine_connect_and_write() == | 305 helper_.params()->combine_connect_and_write() == |
301 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DESIRED) { | 306 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DESIRED) { |
302 transport_socket_->EnableTCPFastOpenIfSupported(); | 307 transport_socket_->EnableTCPFastOpenIfSupported(); |
303 } | 308 } |
304 | 309 |
| 310 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. |
| 311 tracked_objects::ScopedTracker tracking_profile2( |
| 312 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 313 "436634 TransportConnectJob::DoTransportConnect2")); |
| 314 |
305 int rv = transport_socket_->Connect(helper_.on_io_complete()); | 315 int rv = transport_socket_->Connect(helper_.on_io_complete()); |
| 316 |
| 317 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. |
| 318 tracked_objects::ScopedTracker tracking_profile3( |
| 319 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 320 "436634 TransportConnectJob::DoTransportConnect3")); |
| 321 |
306 if (rv == ERR_IO_PENDING && try_ipv6_connect_with_ipv4_fallback) { | 322 if (rv == ERR_IO_PENDING && try_ipv6_connect_with_ipv4_fallback) { |
307 fallback_timer_.Start( | 323 fallback_timer_.Start( |
308 FROM_HERE, | 324 FROM_HERE, |
309 base::TimeDelta::FromMilliseconds( | 325 base::TimeDelta::FromMilliseconds( |
310 TransportConnectJobHelper::kIPv6FallbackTimerInMs), | 326 TransportConnectJobHelper::kIPv6FallbackTimerInMs), |
311 this, | 327 this, |
312 &TransportConnectJob::DoIPv6FallbackTransportConnect); | 328 &TransportConnectJob::DoIPv6FallbackTransportConnect); |
313 } | 329 } |
314 return rv; | 330 return rv; |
315 } | 331 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 HigherLayeredPool* higher_pool) { | 595 HigherLayeredPool* higher_pool) { |
580 base_.AddHigherLayeredPool(higher_pool); | 596 base_.AddHigherLayeredPool(higher_pool); |
581 } | 597 } |
582 | 598 |
583 void TransportClientSocketPool::RemoveHigherLayeredPool( | 599 void TransportClientSocketPool::RemoveHigherLayeredPool( |
584 HigherLayeredPool* higher_pool) { | 600 HigherLayeredPool* higher_pool) { |
585 base_.RemoveHigherLayeredPool(higher_pool); | 601 base_.RemoveHigherLayeredPool(higher_pool); |
586 } | 602 } |
587 | 603 |
588 } // namespace net | 604 } // namespace net |
OLD | NEW |