| 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/ssl_client_socket_pool.h" | 5 #include "net/socket/ssl_client_socket_pool.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 } | 322 } |
| 323 | 323 |
| 324 int SSLConnectJob::DoSSLConnectComplete(int result) { | 324 int SSLConnectJob::DoSSLConnectComplete(int result) { |
| 325 // TODO(rvargas): Remove ScopedTracker below once crbug.com/462784 is fixed. | 325 // TODO(rvargas): Remove ScopedTracker below once crbug.com/462784 is fixed. |
| 326 tracked_objects::ScopedTracker tracking_profile( | 326 tracked_objects::ScopedTracker tracking_profile( |
| 327 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 327 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 328 "462784 SSLConnectJob::DoSSLConnectComplete")); | 328 "462784 SSLConnectJob::DoSSLConnectComplete")); |
| 329 | 329 |
| 330 connect_timing_.ssl_end = base::TimeTicks::Now(); | 330 connect_timing_.ssl_end = base::TimeTicks::Now(); |
| 331 | 331 |
| 332 SSLClientSocket::NextProtoStatus status = | 332 // If we want SPDY over ALPN/NPN, make sure it succeeded. |
| 333 SSLClientSocket::kNextProtoUnsupported; | 333 if (params_->want_spdy_over_npn() && |
| 334 std::string proto; | 334 !NextProtoIsSPDY(ssl_socket_->GetNegotiatedProtocol())) { |
| 335 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket | 335 return ERR_NPN_NEGOTIATION_FAILED; |
| 336 // that hasn't had SSL_ImportFD called on it. If we get a certificate error | |
| 337 // here, then we know that we called SSL_ImportFD. | |
| 338 if (result == OK || IsCertificateError(result)) { | |
| 339 status = ssl_socket_->GetNextProto(&proto); | |
| 340 ssl_socket_->RecordNegotiationExtension(); | |
| 341 } | 336 } |
| 342 | 337 |
| 343 // If we want spdy over npn, make sure it succeeded. | |
| 344 if (status == SSLClientSocket::kNextProtoNegotiated) { | |
| 345 ssl_socket_->set_was_npn_negotiated(true); | |
| 346 NextProto protocol_negotiated = | |
| 347 SSLClientSocket::NextProtoFromString(proto); | |
| 348 ssl_socket_->set_protocol_negotiated(protocol_negotiated); | |
| 349 // If we negotiated a SPDY version, it must have been present in | |
| 350 // SSLConfig::next_protos. | |
| 351 // TODO(mbelshe): Verify this. | |
| 352 if (protocol_negotiated >= kProtoSPDYMinimumVersion && | |
| 353 protocol_negotiated <= kProtoSPDYMaximumVersion) { | |
| 354 ssl_socket_->set_was_spdy_negotiated(true); | |
| 355 } | |
| 356 } | |
| 357 if (params_->want_spdy_over_npn() && !ssl_socket_->was_spdy_negotiated()) | |
| 358 return ERR_NPN_NEGOTIATION_FAILED; | |
| 359 | |
| 360 if (result == OK || | 338 if (result == OK || |
| 361 ssl_socket_->IgnoreCertError(result, params_->load_flags())) { | 339 ssl_socket_->IgnoreCertError(result, params_->load_flags())) { |
| 362 DCHECK(!connect_timing_.ssl_start.is_null()); | 340 DCHECK(!connect_timing_.ssl_start.is_null()); |
| 363 base::TimeDelta connect_duration = | 341 base::TimeDelta connect_duration = |
| 364 connect_timing_.ssl_end - connect_timing_.ssl_start; | 342 connect_timing_.ssl_end - connect_timing_.ssl_start; |
| 365 if (params_->want_spdy_over_npn()) { | 343 if (params_->want_spdy_over_npn()) { |
| 366 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SpdyConnectionLatency_2", | 344 UMA_HISTOGRAM_CUSTOM_TIMES("Net.SpdyConnectionLatency_2", |
| 367 connect_duration, | 345 connect_duration, |
| 368 base::TimeDelta::FromMilliseconds(1), | 346 base::TimeDelta::FromMilliseconds(1), |
| 369 base::TimeDelta::FromMinutes(1), | 347 base::TimeDelta::FromMinutes(1), |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 if (base_.CloseOneIdleSocket()) | 656 if (base_.CloseOneIdleSocket()) |
| 679 return true; | 657 return true; |
| 680 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 658 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 681 } | 659 } |
| 682 | 660 |
| 683 void SSLClientSocketPool::OnSSLConfigChanged() { | 661 void SSLClientSocketPool::OnSSLConfigChanged() { |
| 684 FlushWithError(ERR_NETWORK_CHANGED); | 662 FlushWithError(ERR_NETWORK_CHANGED); |
| 685 } | 663 } |
| 686 | 664 |
| 687 } // namespace net | 665 } // namespace net |
| OLD | NEW |