| 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/base/ssl_config_service.h" | 9 #include "net/base/ssl_config_service.h" |
| 10 #include "net/http/http_proxy_client_socket_pool.h" | 10 #include "net/http/http_proxy_client_socket_pool.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 ssl_for_https_proxy_pool_histograms_("SSLforHTTPSProxy"), | 83 ssl_for_https_proxy_pool_histograms_("SSLforHTTPSProxy"), |
| 84 http_proxy_pool_histograms_("HTTPProxy"), | 84 http_proxy_pool_histograms_("HTTPProxy"), |
| 85 ssl_socket_pool_for_proxies_histograms_("SSLForProxies") { | 85 ssl_socket_pool_for_proxies_histograms_("SSLForProxies") { |
| 86 CertDatabase::GetInstance()->AddObserver(this); | 86 CertDatabase::GetInstance()->AddObserver(this); |
| 87 } | 87 } |
| 88 | 88 |
| 89 ClientSocketPoolManagerImpl::~ClientSocketPoolManagerImpl() { | 89 ClientSocketPoolManagerImpl::~ClientSocketPoolManagerImpl() { |
| 90 CertDatabase::GetInstance()->RemoveObserver(this); | 90 CertDatabase::GetInstance()->RemoveObserver(this); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ClientSocketPoolManagerImpl::FlushSocketPools() { | 93 void ClientSocketPoolManagerImpl::FlushSocketPoolsWithError(int error) { |
| 94 // Flush the highest level pools first, since higher level pools may release | 94 // Flush the highest level pools first, since higher level pools may release |
| 95 // stuff to the lower level pools. | 95 // stuff to the lower level pools. |
| 96 | 96 |
| 97 for (SSLSocketPoolMap::const_iterator it = | 97 for (SSLSocketPoolMap::const_iterator it = |
| 98 ssl_socket_pools_for_proxies_.begin(); | 98 ssl_socket_pools_for_proxies_.begin(); |
| 99 it != ssl_socket_pools_for_proxies_.end(); | 99 it != ssl_socket_pools_for_proxies_.end(); |
| 100 ++it) | 100 ++it) |
| 101 it->second->Flush(); | 101 it->second->FlushWithError(error); |
| 102 | 102 |
| 103 for (HTTPProxySocketPoolMap::const_iterator it = | 103 for (HTTPProxySocketPoolMap::const_iterator it = |
| 104 http_proxy_socket_pools_.begin(); | 104 http_proxy_socket_pools_.begin(); |
| 105 it != http_proxy_socket_pools_.end(); | 105 it != http_proxy_socket_pools_.end(); |
| 106 ++it) | 106 ++it) |
| 107 it->second->Flush(); | 107 it->second->FlushWithError(error); |
| 108 | 108 |
| 109 for (SSLSocketPoolMap::const_iterator it = | 109 for (SSLSocketPoolMap::const_iterator it = |
| 110 ssl_socket_pools_for_https_proxies_.begin(); | 110 ssl_socket_pools_for_https_proxies_.begin(); |
| 111 it != ssl_socket_pools_for_https_proxies_.end(); | 111 it != ssl_socket_pools_for_https_proxies_.end(); |
| 112 ++it) | 112 ++it) |
| 113 it->second->Flush(); | 113 it->second->FlushWithError(error); |
| 114 | 114 |
| 115 for (TransportSocketPoolMap::const_iterator it = | 115 for (TransportSocketPoolMap::const_iterator it = |
| 116 transport_socket_pools_for_https_proxies_.begin(); | 116 transport_socket_pools_for_https_proxies_.begin(); |
| 117 it != transport_socket_pools_for_https_proxies_.end(); | 117 it != transport_socket_pools_for_https_proxies_.end(); |
| 118 ++it) | 118 ++it) |
| 119 it->second->Flush(); | 119 it->second->FlushWithError(error); |
| 120 | 120 |
| 121 for (TransportSocketPoolMap::const_iterator it = | 121 for (TransportSocketPoolMap::const_iterator it = |
| 122 transport_socket_pools_for_http_proxies_.begin(); | 122 transport_socket_pools_for_http_proxies_.begin(); |
| 123 it != transport_socket_pools_for_http_proxies_.end(); | 123 it != transport_socket_pools_for_http_proxies_.end(); |
| 124 ++it) | 124 ++it) |
| 125 it->second->Flush(); | 125 it->second->FlushWithError(error); |
| 126 | 126 |
| 127 for (SOCKSSocketPoolMap::const_iterator it = | 127 for (SOCKSSocketPoolMap::const_iterator it = |
| 128 socks_socket_pools_.begin(); | 128 socks_socket_pools_.begin(); |
| 129 it != socks_socket_pools_.end(); | 129 it != socks_socket_pools_.end(); |
| 130 ++it) | 130 ++it) |
| 131 it->second->Flush(); | 131 it->second->FlushWithError(error); |
| 132 | 132 |
| 133 for (TransportSocketPoolMap::const_iterator it = | 133 for (TransportSocketPoolMap::const_iterator it = |
| 134 transport_socket_pools_for_socks_proxies_.begin(); | 134 transport_socket_pools_for_socks_proxies_.begin(); |
| 135 it != transport_socket_pools_for_socks_proxies_.end(); | 135 it != transport_socket_pools_for_socks_proxies_.end(); |
| 136 ++it) | 136 ++it) |
| 137 it->second->Flush(); | 137 it->second->FlushWithError(error); |
| 138 | 138 |
| 139 ssl_socket_pool_->Flush(); | 139 ssl_socket_pool_->FlushWithError(error); |
| 140 transport_socket_pool_->Flush(); | 140 transport_socket_pool_->FlushWithError(error); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void ClientSocketPoolManagerImpl::CloseIdleSockets() { | 143 void ClientSocketPoolManagerImpl::CloseIdleSockets() { |
| 144 // Close sockets in the highest level pools first, since higher level pools' | 144 // Close sockets in the highest level pools first, since higher level pools' |
| 145 // sockets may release stuff to the lower level pools. | 145 // sockets may release stuff to the lower level pools. |
| 146 for (SSLSocketPoolMap::const_iterator it = | 146 for (SSLSocketPoolMap::const_iterator it = |
| 147 ssl_socket_pools_for_proxies_.begin(); | 147 ssl_socket_pools_for_proxies_.begin(); |
| 148 it != ssl_socket_pools_for_proxies_.end(); | 148 it != ssl_socket_pools_for_proxies_.end(); |
| 149 ++it) | 149 ++it) |
| 150 it->second->CloseIdleSockets(); | 150 it->second->CloseIdleSockets(); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // Third parameter is false because |ssl_socket_pools_for_proxies_| use | 365 // Third parameter is false because |ssl_socket_pools_for_proxies_| use |
| 366 // socket pools in |http_proxy_socket_pools_| and |socks_socket_pools_|. | 366 // socket pools in |http_proxy_socket_pools_| and |socks_socket_pools_|. |
| 367 AddSocketPoolsToList(list, | 367 AddSocketPoolsToList(list, |
| 368 ssl_socket_pools_for_proxies_, | 368 ssl_socket_pools_for_proxies_, |
| 369 "ssl_socket_pool_for_proxies", | 369 "ssl_socket_pool_for_proxies", |
| 370 false); | 370 false); |
| 371 return list; | 371 return list; |
| 372 } | 372 } |
| 373 | 373 |
| 374 void ClientSocketPoolManagerImpl::OnCertAdded(const X509Certificate* cert) { | 374 void ClientSocketPoolManagerImpl::OnCertAdded(const X509Certificate* cert) { |
| 375 FlushSocketPools(); | 375 FlushSocketPoolsWithError(ERR_NETWORK_CHANGED); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void ClientSocketPoolManagerImpl::OnCertTrustChanged( | 378 void ClientSocketPoolManagerImpl::OnCertTrustChanged( |
| 379 const X509Certificate* cert) { | 379 const X509Certificate* cert) { |
| 380 // We should flush the socket pools if we removed trust from a | 380 // We should flush the socket pools if we removed trust from a |
| 381 // cert, because a previously trusted server may have become | 381 // cert, because a previously trusted server may have become |
| 382 // untrusted. | 382 // untrusted. |
| 383 // | 383 // |
| 384 // We should not flush the socket pools if we added trust to a | 384 // We should not flush the socket pools if we added trust to a |
| 385 // cert. | 385 // cert. |
| 386 // | 386 // |
| 387 // Since the OnCertTrustChanged method doesn't tell us what | 387 // Since the OnCertTrustChanged method doesn't tell us what |
| 388 // kind of trust change it is, we have to flush the socket | 388 // kind of trust change it is, we have to flush the socket |
| 389 // pools to be safe. | 389 // pools to be safe. |
| 390 FlushSocketPools(); | 390 FlushSocketPoolsWithError(ERR_NETWORK_CHANGED); |
| 391 } | 391 } |
| 392 | 392 |
| 393 } // namespace net | 393 } // namespace net |
| OLD | NEW |