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 <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
11 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
12 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
15 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
16 #include "net/http/http_proxy_client_socket.h" | 18 #include "net/http/http_proxy_client_socket.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // |connect_start| doesn't include dns times, and it adjusts the time so | 314 // |connect_start| doesn't include dns times, and it adjusts the time so |
313 // as not to include time spent waiting for an idle socket. | 315 // as not to include time spent waiting for an idle socket. |
314 connect_timing_.connect_start = socket_connect_timing.connect_start; | 316 connect_timing_.connect_start = socket_connect_timing.connect_start; |
315 connect_timing_.dns_start = socket_connect_timing.dns_start; | 317 connect_timing_.dns_start = socket_connect_timing.dns_start; |
316 connect_timing_.dns_end = socket_connect_timing.dns_end; | 318 connect_timing_.dns_end = socket_connect_timing.dns_end; |
317 } | 319 } |
318 | 320 |
319 connect_timing_.ssl_start = base::TimeTicks::Now(); | 321 connect_timing_.ssl_start = base::TimeTicks::Now(); |
320 | 322 |
321 ssl_socket_ = client_socket_factory_->CreateSSLClientSocket( | 323 ssl_socket_ = client_socket_factory_->CreateSSLClientSocket( |
322 transport_socket_handle_.Pass(), | 324 std::move(transport_socket_handle_), params_->host_and_port(), |
323 params_->host_and_port(), | 325 params_->ssl_config(), context_); |
324 params_->ssl_config(), | |
325 context_); | |
326 return ssl_socket_->Connect(callback_); | 326 return ssl_socket_->Connect(callback_); |
327 } | 327 } |
328 | 328 |
329 int SSLConnectJob::DoSSLConnectComplete(int result) { | 329 int SSLConnectJob::DoSSLConnectComplete(int result) { |
330 // TODO(rvargas): Remove ScopedTracker below once crbug.com/462784 is fixed. | 330 // TODO(rvargas): Remove ScopedTracker below once crbug.com/462784 is fixed. |
331 tracked_objects::ScopedTracker tracking_profile( | 331 tracked_objects::ScopedTracker tracking_profile( |
332 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 332 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
333 "462784 SSLConnectJob::DoSSLConnectComplete")); | 333 "462784 SSLConnectJob::DoSSLConnectComplete")); |
334 | 334 |
335 connect_timing_.ssl_end = base::TimeTicks::Now(); | 335 connect_timing_.ssl_end = base::TimeTicks::Now(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 base::TimeDelta::FromMilliseconds(1), | 433 base::TimeDelta::FromMilliseconds(1), |
434 base::TimeDelta::FromMinutes(1), | 434 base::TimeDelta::FromMinutes(1), |
435 100); | 435 100); |
436 } | 436 } |
437 } | 437 } |
438 } | 438 } |
439 | 439 |
440 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(result)); | 440 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(result)); |
441 | 441 |
442 if (result == OK || IsCertificateError(result)) { | 442 if (result == OK || IsCertificateError(result)) { |
443 SetSocket(ssl_socket_.Pass()); | 443 SetSocket(std::move(ssl_socket_)); |
444 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 444 } else if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
445 error_response_info_.cert_request_info = new SSLCertRequestInfo; | 445 error_response_info_.cert_request_info = new SSLCertRequestInfo; |
446 ssl_socket_->GetSSLCertRequestInfo( | 446 ssl_socket_->GetSSLCertRequestInfo( |
447 error_response_info_.cert_request_info.get()); | 447 error_response_info_.cert_request_info.get()); |
448 } | 448 } |
449 | 449 |
450 return result; | 450 return result; |
451 } | 451 } |
452 | 452 |
453 SSLConnectJob::State SSLConnectJob::GetInitialState( | 453 SSLConnectJob::State SSLConnectJob::GetInitialState( |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 } | 601 } |
602 | 602 |
603 void SSLClientSocketPool::CancelRequest(const std::string& group_name, | 603 void SSLClientSocketPool::CancelRequest(const std::string& group_name, |
604 ClientSocketHandle* handle) { | 604 ClientSocketHandle* handle) { |
605 base_.CancelRequest(group_name, handle); | 605 base_.CancelRequest(group_name, handle); |
606 } | 606 } |
607 | 607 |
608 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name, | 608 void SSLClientSocketPool::ReleaseSocket(const std::string& group_name, |
609 scoped_ptr<StreamSocket> socket, | 609 scoped_ptr<StreamSocket> socket, |
610 int id) { | 610 int id) { |
611 base_.ReleaseSocket(group_name, socket.Pass(), id); | 611 base_.ReleaseSocket(group_name, std::move(socket), id); |
612 } | 612 } |
613 | 613 |
614 void SSLClientSocketPool::FlushWithError(int error) { | 614 void SSLClientSocketPool::FlushWithError(int error) { |
615 base_.FlushWithError(error); | 615 base_.FlushWithError(error); |
616 } | 616 } |
617 | 617 |
618 void SSLClientSocketPool::CloseIdleSockets() { | 618 void SSLClientSocketPool::CloseIdleSockets() { |
619 base_.CloseIdleSockets(); | 619 base_.CloseIdleSockets(); |
620 } | 620 } |
621 | 621 |
(...skipping 28 matching lines...) Expand all Loading... |
650 "socks_pool", | 650 "socks_pool", |
651 true)); | 651 true)); |
652 } | 652 } |
653 if (http_proxy_pool_) { | 653 if (http_proxy_pool_) { |
654 list->Append(http_proxy_pool_->GetInfoAsValue("http_proxy_pool", | 654 list->Append(http_proxy_pool_->GetInfoAsValue("http_proxy_pool", |
655 "http_proxy_pool", | 655 "http_proxy_pool", |
656 true)); | 656 true)); |
657 } | 657 } |
658 dict->Set("nested_pools", list); | 658 dict->Set("nested_pools", list); |
659 } | 659 } |
660 return dict.Pass(); | 660 return dict; |
661 } | 661 } |
662 | 662 |
663 base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const { | 663 base::TimeDelta SSLClientSocketPool::ConnectionTimeout() const { |
664 return base_.ConnectionTimeout(); | 664 return base_.ConnectionTimeout(); |
665 } | 665 } |
666 | 666 |
667 bool SSLClientSocketPool::IsStalled() const { | 667 bool SSLClientSocketPool::IsStalled() const { |
668 return base_.IsStalled(); | 668 return base_.IsStalled(); |
669 } | 669 } |
670 | 670 |
(...skipping 10 matching lines...) Expand all Loading... |
681 if (base_.CloseOneIdleSocket()) | 681 if (base_.CloseOneIdleSocket()) |
682 return true; | 682 return true; |
683 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 683 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
684 } | 684 } |
685 | 685 |
686 void SSLClientSocketPool::OnSSLConfigChanged() { | 686 void SSLClientSocketPool::OnSSLConfigChanged() { |
687 FlushWithError(ERR_NETWORK_CHANGED); | 687 FlushWithError(ERR_NETWORK_CHANGED); |
688 } | 688 } |
689 | 689 |
690 } // namespace net | 690 } // namespace net |
OLD | NEW |