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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 void TransportConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { | 236 void TransportConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { |
237 // If hostname resolution failed, record an empty endpoint and the result. | 237 // If hostname resolution failed, record an empty endpoint and the result. |
238 // If the actual socket Connect call failed, record the result and the last | 238 // If the actual socket Connect call failed, record the result and the last |
239 // address attempted. | 239 // address attempted. |
240 // TODO(ttuttle): Plumb into the socket layer and record *all* attempts. | 240 // TODO(ttuttle): Plumb into the socket layer and record *all* attempts. |
241 ConnectionAttempts attempts; | 241 ConnectionAttempts attempts; |
242 if (resolve_result_ != OK) { | 242 if (resolve_result_ != OK) { |
243 DCHECK_EQ(0u, helper_.addresses().size()); | 243 DCHECK_EQ(0u, helper_.addresses().size()); |
244 attempts.push_back(ConnectionAttempt(IPEndPoint(), resolve_result_)); | 244 attempts.push_back(ConnectionAttempt(IPEndPoint(), resolve_result_)); |
245 } else if (connect_result_ != OK) { | 245 } else if (connect_result_ != OK) { |
246 DCHECK_LT(0u, helper_.addresses().size()); | 246 attempts.insert(attempts.begin(), connection_attempts_.begin(), |
247 attempts.push_back( | 247 connection_attempts_.end()); |
248 ConnectionAttempt(helper_.addresses().back(), connect_result_)); | 248 attempts.insert(attempts.begin(), fallback_connection_attempts_.begin(), |
Randy Smith (Not in Mondays)
2015/05/01 17:39:50
Doesn't this mean we can nuke connect_result_ from
Deprecated (see juliatuttle)
2015/05/04 19:44:50
Why? We're still using it in the new version here.
Randy Smith (Not in Mondays)
2015/05/06 15:30:11
Ah, sorry, missed that.
I do wonder a bit about w
| |
249 fallback_connection_attempts_.end()); | |
Randy Smith (Not in Mondays)
2015/05/01 17:39:49
Is ordering relevant for the ConnectionAttempts ve
Deprecated (see juliatuttle)
2015/05/04 19:44:50
Ordering is approximately "the order the connectio
Randy Smith (Not in Mondays)
2015/05/06 15:30:11
I still feel like this means we should make it cle
| |
249 } | 250 } |
250 handle->set_connection_attempts(attempts); | 251 handle->set_connection_attempts(attempts); |
251 } | 252 } |
252 | 253 |
253 // static | 254 // static |
254 void TransportConnectJob::MakeAddressListStartWithIPv4(AddressList* list) { | 255 void TransportConnectJob::MakeAddressListStartWithIPv4(AddressList* list) { |
255 for (AddressList::iterator i = list->begin(); i != list->end(); ++i) { | 256 for (AddressList::iterator i = list->begin(); i != list->end(); ++i) { |
256 if (i->GetFamily() == ADDRESS_FAMILY_IPV4) { | 257 if (i->GetFamily() == ADDRESS_FAMILY_IPV4) { |
257 std::rotate(list->begin(), i, list->end()); | 258 std::rotate(list->begin(), i, list->end()); |
258 break; | 259 break; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 FROM_HERE, | 323 FROM_HERE, |
323 base::TimeDelta::FromMilliseconds( | 324 base::TimeDelta::FromMilliseconds( |
324 TransportConnectJobHelper::kIPv6FallbackTimerInMs), | 325 TransportConnectJobHelper::kIPv6FallbackTimerInMs), |
325 this, | 326 this, |
326 &TransportConnectJob::DoIPv6FallbackTransportConnect); | 327 &TransportConnectJob::DoIPv6FallbackTransportConnect); |
327 } | 328 } |
328 return rv; | 329 return rv; |
329 } | 330 } |
330 | 331 |
331 int TransportConnectJob::DoTransportConnectComplete(int result) { | 332 int TransportConnectJob::DoTransportConnectComplete(int result) { |
333 transport_socket_->GetConnectionAttempts(&connection_attempts_); | |
334 | |
332 if (result == OK) { | 335 if (result == OK) { |
333 bool is_ipv4 = | 336 bool is_ipv4 = |
334 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV4; | 337 helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV4; |
335 TransportConnectJobHelper::ConnectionLatencyHistogram race_result = | 338 TransportConnectJobHelper::ConnectionLatencyHistogram race_result = |
336 TransportConnectJobHelper::CONNECTION_LATENCY_UNKNOWN; | 339 TransportConnectJobHelper::CONNECTION_LATENCY_UNKNOWN; |
337 if (is_ipv4) { | 340 if (is_ipv4) { |
338 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_NO_RACE; | 341 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_NO_RACE; |
339 } else { | 342 } else { |
340 if (AddressListOnlyContainsIPv6(helper_.addresses())) { | 343 if (AddressListOnlyContainsIPv6(helper_.addresses())) { |
341 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV6_SOLO; | 344 race_result = TransportConnectJobHelper::CONNECTION_LATENCY_IPV6_SOLO; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 *fallback_addresses_, net_log().net_log(), net_log().source()); | 410 *fallback_addresses_, net_log().net_log(), net_log().source()); |
408 fallback_connect_start_time_ = base::TimeTicks::Now(); | 411 fallback_connect_start_time_ = base::TimeTicks::Now(); |
409 int rv = fallback_transport_socket_->Connect( | 412 int rv = fallback_transport_socket_->Connect( |
410 base::Bind( | 413 base::Bind( |
411 &TransportConnectJob::DoIPv6FallbackTransportConnectComplete, | 414 &TransportConnectJob::DoIPv6FallbackTransportConnectComplete, |
412 base::Unretained(this))); | 415 base::Unretained(this))); |
413 if (rv != ERR_IO_PENDING) | 416 if (rv != ERR_IO_PENDING) |
414 DoIPv6FallbackTransportConnectComplete(rv); | 417 DoIPv6FallbackTransportConnectComplete(rv); |
415 } | 418 } |
416 | 419 |
417 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) { | 420 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) { |
Randy Smith (Not in Mondays)
2015/05/01 17:39:50
Just because I'm a paranoid person: What prevents
Deprecated (see juliatuttle)
2015/05/04 19:44:50
Nothing guarantees it, but it's the best I can do
Randy Smith (Not in Mondays)
2015/05/06 15:30:11
Huh. Ok, two follow on question:
* It seems like
| |
418 // This should only happen when we're waiting for the main connect to succeed. | 421 // This should only happen when we're waiting for the main connect to succeed. |
419 if (helper_.next_state() != | 422 if (helper_.next_state() != |
420 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE) { | 423 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE) { |
421 NOTREACHED(); | 424 NOTREACHED(); |
422 return; | 425 return; |
423 } | 426 } |
424 | 427 |
425 DCHECK_NE(ERR_IO_PENDING, result); | 428 DCHECK_NE(ERR_IO_PENDING, result); |
426 DCHECK(fallback_transport_socket_.get()); | 429 DCHECK(fallback_transport_socket_.get()); |
427 DCHECK(fallback_addresses_.get()); | 430 DCHECK(fallback_addresses_.get()); |
428 | 431 |
432 fallback_transport_socket_->GetConnectionAttempts( | |
433 &fallback_connection_attempts_); | |
434 | |
429 if (result == OK) { | 435 if (result == OK) { |
430 DCHECK(!fallback_connect_start_time_.is_null()); | 436 DCHECK(!fallback_connect_start_time_.is_null()); |
431 connect_timing_.connect_start = fallback_connect_start_time_; | 437 connect_timing_.connect_start = fallback_connect_start_time_; |
432 helper_.HistogramDuration( | 438 helper_.HistogramDuration( |
433 TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_WINS_RACE); | 439 TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_WINS_RACE); |
434 SetSocket(fallback_transport_socket_.Pass()); | 440 SetSocket(fallback_transport_socket_.Pass()); |
435 helper_.set_next_state(TransportConnectJobHelper::STATE_NONE); | 441 helper_.set_next_state(TransportConnectJobHelper::STATE_NONE); |
436 transport_socket_.reset(); | 442 transport_socket_.reset(); |
437 } else { | 443 } else { |
438 // Be a bit paranoid and kill off the fallback members to prevent reuse. | 444 // Be a bit paranoid and kill off the fallback members to prevent reuse. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 HigherLayeredPool* higher_pool) { | 594 HigherLayeredPool* higher_pool) { |
589 base_.AddHigherLayeredPool(higher_pool); | 595 base_.AddHigherLayeredPool(higher_pool); |
590 } | 596 } |
591 | 597 |
592 void TransportClientSocketPool::RemoveHigherLayeredPool( | 598 void TransportClientSocketPool::RemoveHigherLayeredPool( |
593 HigherLayeredPool* higher_pool) { | 599 HigherLayeredPool* higher_pool) { |
594 base_.RemoveHigherLayeredPool(higher_pool); | 600 base_.RemoveHigherLayeredPool(higher_pool); |
595 } | 601 } |
596 | 602 |
597 } // namespace net | 603 } // namespace net |
OLD | NEW |