| 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/client_socket_pool_manager_impl.h" | 5 #include "net/socket/client_socket_pool_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "net/http/http_network_session.h" | 9 #include "net/http/http_network_session.h" |
| 10 #include "net/http/http_proxy_client_socket_pool.h" | 10 #include "net/http/http_proxy_client_socket_pool.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 ClientSocketFactory* socket_factory, | 39 ClientSocketFactory* socket_factory, |
| 40 HostResolver* host_resolver, | 40 HostResolver* host_resolver, |
| 41 CertVerifier* cert_verifier, | 41 CertVerifier* cert_verifier, |
| 42 ChannelIDService* channel_id_service, | 42 ChannelIDService* channel_id_service, |
| 43 TransportSecurityState* transport_security_state, | 43 TransportSecurityState* transport_security_state, |
| 44 CTVerifier* cert_transparency_verifier, | 44 CTVerifier* cert_transparency_verifier, |
| 45 CertPolicyEnforcer* cert_policy_enforcer, | 45 CertPolicyEnforcer* cert_policy_enforcer, |
| 46 const std::string& ssl_session_cache_shard, | 46 const std::string& ssl_session_cache_shard, |
| 47 SSLConfigService* ssl_config_service, | 47 SSLConfigService* ssl_config_service, |
| 48 bool enable_ssl_connect_job_waiting, | 48 bool enable_ssl_connect_job_waiting, |
| 49 HttpNetworkSession::SocketPoolType pool_type) | 49 HttpNetworkSession::SocketPoolType pool_type, |
| 50 SSLSocketConfigService* ssl_socket_config_service) |
| 50 : net_log_(net_log), | 51 : net_log_(net_log), |
| 51 socket_factory_(socket_factory), | 52 socket_factory_(socket_factory), |
| 52 host_resolver_(host_resolver), | 53 host_resolver_(host_resolver), |
| 53 cert_verifier_(cert_verifier), | 54 cert_verifier_(cert_verifier), |
| 54 channel_id_service_(channel_id_service), | 55 channel_id_service_(channel_id_service), |
| 55 transport_security_state_(transport_security_state), | 56 transport_security_state_(transport_security_state), |
| 56 cert_transparency_verifier_(cert_transparency_verifier), | 57 cert_transparency_verifier_(cert_transparency_verifier), |
| 57 cert_policy_enforcer_(cert_policy_enforcer), | 58 cert_policy_enforcer_(cert_policy_enforcer), |
| 58 ssl_session_cache_shard_(ssl_session_cache_shard), | 59 ssl_session_cache_shard_(ssl_session_cache_shard), |
| 59 ssl_config_service_(ssl_config_service), | 60 ssl_config_service_(ssl_config_service), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 transport_security_state, | 85 transport_security_state, |
| 85 cert_transparency_verifier, | 86 cert_transparency_verifier, |
| 86 cert_policy_enforcer, | 87 cert_policy_enforcer, |
| 87 ssl_session_cache_shard, | 88 ssl_session_cache_shard, |
| 88 socket_factory, | 89 socket_factory, |
| 89 transport_socket_pool_.get(), | 90 transport_socket_pool_.get(), |
| 90 NULL /* no socks proxy */, | 91 NULL /* no socks proxy */, |
| 91 NULL /* no http proxy */, | 92 NULL /* no http proxy */, |
| 92 ssl_config_service, | 93 ssl_config_service, |
| 93 enable_ssl_connect_job_waiting, | 94 enable_ssl_connect_job_waiting, |
| 94 net_log)), | 95 net_log, |
| 96 ssl_socket_config_service)), |
| 95 transport_for_socks_pool_histograms_("TCPforSOCKS"), | 97 transport_for_socks_pool_histograms_("TCPforSOCKS"), |
| 96 socks_pool_histograms_("SOCK"), | 98 socks_pool_histograms_("SOCK"), |
| 97 transport_for_http_proxy_pool_histograms_("TCPforHTTPProxy"), | 99 transport_for_http_proxy_pool_histograms_("TCPforHTTPProxy"), |
| 98 transport_for_https_proxy_pool_histograms_("TCPforHTTPSProxy"), | 100 transport_for_https_proxy_pool_histograms_("TCPforHTTPSProxy"), |
| 99 ssl_for_https_proxy_pool_histograms_("SSLforHTTPSProxy"), | 101 ssl_for_https_proxy_pool_histograms_("SSLforHTTPSProxy"), |
| 100 http_proxy_pool_histograms_("HTTPProxy"), | 102 http_proxy_pool_histograms_("HTTPProxy"), |
| 101 ssl_socket_pool_for_proxies_histograms_("SSLForProxies") { | 103 ssl_socket_pool_for_proxies_histograms_("SSLForProxies"), |
| 104 ssl_socket_config_service_(ssl_socket_config_service) { |
| 102 CertDatabase::GetInstance()->AddObserver(this); | 105 CertDatabase::GetInstance()->AddObserver(this); |
| 103 } | 106 } |
| 104 | 107 |
| 105 ClientSocketPoolManagerImpl::~ClientSocketPoolManagerImpl() { | 108 ClientSocketPoolManagerImpl::~ClientSocketPoolManagerImpl() { |
| 106 CertDatabase::GetInstance()->RemoveObserver(this); | 109 CertDatabase::GetInstance()->RemoveObserver(this); |
| 107 } | 110 } |
| 108 | 111 |
| 109 void ClientSocketPoolManagerImpl::FlushSocketPoolsWithError(int error) { | 112 void ClientSocketPoolManagerImpl::FlushSocketPoolsWithError(int error) { |
| 110 // Flush the highest level pools first, since higher level pools may release | 113 // Flush the highest level pools first, since higher level pools may release |
| 111 // stuff to the lower level pools. | 114 // stuff to the lower level pools. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 http_proxy, new SSLClientSocketPool( | 300 http_proxy, new SSLClientSocketPool( |
| 298 max_sockets_per_proxy_server(pool_type_), | 301 max_sockets_per_proxy_server(pool_type_), |
| 299 max_sockets_per_group(pool_type_), | 302 max_sockets_per_group(pool_type_), |
| 300 &ssl_for_https_proxy_pool_histograms_, cert_verifier_, | 303 &ssl_for_https_proxy_pool_histograms_, cert_verifier_, |
| 301 channel_id_service_, transport_security_state_, | 304 channel_id_service_, transport_security_state_, |
| 302 cert_transparency_verifier_, cert_policy_enforcer_, | 305 cert_transparency_verifier_, cert_policy_enforcer_, |
| 303 ssl_session_cache_shard_, socket_factory_, | 306 ssl_session_cache_shard_, socket_factory_, |
| 304 tcp_https_ret.first->second /* https proxy */, | 307 tcp_https_ret.first->second /* https proxy */, |
| 305 NULL /* no socks proxy */, NULL /* no http proxy */, | 308 NULL /* no socks proxy */, NULL /* no http proxy */, |
| 306 ssl_config_service_.get(), | 309 ssl_config_service_.get(), |
| 307 enable_ssl_connect_job_waiting_, net_log_))); | 310 enable_ssl_connect_job_waiting_, net_log_, |
| 311 ssl_socket_config_service_))); |
| 308 DCHECK(tcp_https_ret.second); | 312 DCHECK(tcp_https_ret.second); |
| 309 | 313 |
| 310 std::pair<HTTPProxySocketPoolMap::iterator, bool> ret = | 314 std::pair<HTTPProxySocketPoolMap::iterator, bool> ret = |
| 311 http_proxy_socket_pools_.insert( | 315 http_proxy_socket_pools_.insert( |
| 312 std::make_pair( | 316 std::make_pair( |
| 313 http_proxy, | 317 http_proxy, |
| 314 new HttpProxyClientSocketPool( | 318 new HttpProxyClientSocketPool( |
| 315 max_sockets_per_proxy_server(pool_type_), | 319 max_sockets_per_proxy_server(pool_type_), |
| 316 max_sockets_per_group(pool_type_), | 320 max_sockets_per_group(pool_type_), |
| 317 &http_proxy_pool_histograms_, | 321 &http_proxy_pool_histograms_, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 331 | 335 |
| 332 SSLClientSocketPool* new_pool = new SSLClientSocketPool( | 336 SSLClientSocketPool* new_pool = new SSLClientSocketPool( |
| 333 max_sockets_per_proxy_server(pool_type_), | 337 max_sockets_per_proxy_server(pool_type_), |
| 334 max_sockets_per_group(pool_type_), &ssl_pool_histograms_, cert_verifier_, | 338 max_sockets_per_group(pool_type_), &ssl_pool_histograms_, cert_verifier_, |
| 335 channel_id_service_, transport_security_state_, | 339 channel_id_service_, transport_security_state_, |
| 336 cert_transparency_verifier_, cert_policy_enforcer_, | 340 cert_transparency_verifier_, cert_policy_enforcer_, |
| 337 ssl_session_cache_shard_, socket_factory_, | 341 ssl_session_cache_shard_, socket_factory_, |
| 338 NULL, /* no tcp pool, we always go through a proxy */ | 342 NULL, /* no tcp pool, we always go through a proxy */ |
| 339 GetSocketPoolForSOCKSProxy(proxy_server), | 343 GetSocketPoolForSOCKSProxy(proxy_server), |
| 340 GetSocketPoolForHTTPProxy(proxy_server), ssl_config_service_.get(), | 344 GetSocketPoolForHTTPProxy(proxy_server), ssl_config_service_.get(), |
| 341 enable_ssl_connect_job_waiting_, net_log_); | 345 enable_ssl_connect_job_waiting_, net_log_, ssl_socket_config_service_); |
| 342 | 346 |
| 343 std::pair<SSLSocketPoolMap::iterator, bool> ret = | 347 std::pair<SSLSocketPoolMap::iterator, bool> ret = |
| 344 ssl_socket_pools_for_proxies_.insert(std::make_pair(proxy_server, | 348 ssl_socket_pools_for_proxies_.insert(std::make_pair(proxy_server, |
| 345 new_pool)); | 349 new_pool)); |
| 346 | 350 |
| 347 return ret.first->second; | 351 return ret.first->second; |
| 348 } | 352 } |
| 349 | 353 |
| 350 base::Value* ClientSocketPoolManagerImpl::SocketPoolInfoToValue() const { | 354 base::Value* ClientSocketPoolManagerImpl::SocketPoolInfoToValue() const { |
| 351 base::ListValue* list = new base::ListValue(); | 355 base::ListValue* list = new base::ListValue(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // We should not flush the socket pools if we added trust to a | 393 // We should not flush the socket pools if we added trust to a |
| 390 // cert. | 394 // cert. |
| 391 // | 395 // |
| 392 // Since the OnCACertChanged method doesn't tell us what | 396 // Since the OnCACertChanged method doesn't tell us what |
| 393 // kind of change it is, we have to flush the socket | 397 // kind of change it is, we have to flush the socket |
| 394 // pools to be safe. | 398 // pools to be safe. |
| 395 FlushSocketPoolsWithError(ERR_NETWORK_CHANGED); | 399 FlushSocketPoolsWithError(ERR_NETWORK_CHANGED); |
| 396 } | 400 } |
| 397 | 401 |
| 398 } // namespace net | 402 } // namespace net |
| OLD | NEW |