summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 04:16:25 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 04:16:25 +0000
commit62635c758fce2b22a1cf5acdc57579bb5801b2e3 (patch)
tree4085d65bbf01078b722cbcef5930e157d7f793be /net/socket
parentd7f6e73fb05992d784e55df2a1ed25924b5d79f3 (diff)
downloadchromium_src-62635c758fce2b22a1cf5acdc57579bb5801b2e3.zip
chromium_src-62635c758fce2b22a1cf5acdc57579bb5801b2e3.tar.gz
chromium_src-62635c758fce2b22a1cf5acdc57579bb5801b2e3.tar.bz2
Define a new CertDatabase::Observer abstract class which can be implemented by classes which wish to be notified when a new ssl client cert is added.
Register SpdySessionPool, SocketPoolManager and SSLClientAuthCache as observers. Notify observers in CertDatabase::AddUserCert(); BUG=75326 Review URL: http://codereview.chromium.org/6588014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket_factory.cc18
-rw-r--r--net/socket/client_socket_pool_manager.cc17
-rw-r--r--net/socket/client_socket_pool_manager.h7
3 files changed, 37 insertions, 5 deletions
diff --git a/net/socket/client_socket_factory.cc b/net/socket/client_socket_factory.cc
index 2eb90e5..e8e6f2f 100644
--- a/net/socket/client_socket_factory.cc
+++ b/net/socket/client_socket_factory.cc
@@ -6,6 +6,7 @@
#include "base/lazy_instance.h"
#include "build/build_config.h"
+#include "net/base/cert_database.h"
#include "net/socket/client_socket_handle.h"
#if defined(OS_WIN)
#include "net/socket/ssl_client_socket_nss.h"
@@ -23,12 +24,27 @@
namespace net {
+class X509Certificate;
+
namespace {
bool g_use_system_ssl = false;
-class DefaultClientSocketFactory : public ClientSocketFactory {
+class DefaultClientSocketFactory : public ClientSocketFactory,
+ public CertDatabase::Observer {
public:
+ DefaultClientSocketFactory() {
+ CertDatabase::AddObserver(this);
+ }
+
+ virtual ~DefaultClientSocketFactory() {
+ CertDatabase::RemoveObserver(this);
+ }
+
+ virtual void OnUserCertAdded(X509Certificate* cert) {
+ ClearSSLSessionCache();
+ }
+
virtual ClientSocket* CreateTCPClientSocket(
const AddressList& addresses,
NetLog* net_log,
diff --git a/net/socket/client_socket_pool_manager.cc b/net/socket/client_socket_pool_manager.cc
index 999b4e6..3d12256 100644
--- a/net/socket/client_socket_pool_manager.cc
+++ b/net/socket/client_socket_pool_manager.cc
@@ -8,12 +8,15 @@
#include "net/socket/client_socket_pool_manager.h"
+#include <string>
+
#include "base/logging.h"
#include "base/values.h"
#include "net/base/ssl_config_service.h"
#include "net/http/http_proxy_client_socket_pool.h"
-#include "net/socket/client_socket_pool_histograms.h"
#include "net/proxy/proxy_service.h"
+#include "net/socket/client_socket_factory.h"
+#include "net/socket/client_socket_pool_histograms.h"
#include "net/socket/socks_client_socket_pool.h"
#include "net/socket/ssl_client_socket_pool.h"
#include "net/socket/tcp_client_socket_pool.h"
@@ -98,9 +101,13 @@ ClientSocketPoolManager::ClientSocketPoolManager(
tcp_for_https_proxy_pool_histograms_("TCPforHTTPSProxy"),
ssl_for_https_proxy_pool_histograms_("SSLforHTTPSProxy"),
http_proxy_pool_histograms_("HTTPProxy"),
- ssl_socket_pool_for_proxies_histograms_("SSLForProxies") {}
+ ssl_socket_pool_for_proxies_histograms_("SSLForProxies") {
+ CertDatabase::AddObserver(this);
+}
-ClientSocketPoolManager::~ClientSocketPoolManager() {}
+ClientSocketPoolManager::~ClientSocketPoolManager() {
+ CertDatabase::RemoveObserver(this);
+}
void ClientSocketPoolManager::FlushSocketPools() {
// Flush the highest level pools first, since higher level pools may release
@@ -392,4 +399,8 @@ Value* ClientSocketPoolManager::SocketPoolInfoToValue() const {
return list;
}
+void ClientSocketPoolManager::OnUserCertAdded(X509Certificate* cert) {
+ FlushSocketPools();
+}
+
} // namespace net
diff --git a/net/socket/client_socket_pool_manager.h b/net/socket/client_socket_pool_manager.h
index 7d610a9..45a0c23 100644
--- a/net/socket/client_socket_pool_manager.h
+++ b/net/socket/client_socket_pool_manager.h
@@ -17,6 +17,7 @@
#include "base/stl_util-inl.h"
#include "base/template_util.h"
#include "base/threading/non_thread_safe.h"
+#include "net/base/cert_database.h"
#include "net/socket/client_socket_pool_histograms.h"
class Value;
@@ -57,7 +58,8 @@ class OwnedPoolMap : public std::map<Key, Value> {
} // namespace internal
-class ClientSocketPoolManager : public base::NonThreadSafe {
+class ClientSocketPoolManager : public base::NonThreadSafe,
+ public CertDatabase::Observer {
public:
ClientSocketPoolManager(NetLog* net_log,
ClientSocketFactory* socket_factory,
@@ -94,6 +96,9 @@ class ClientSocketPoolManager : public base::NonThreadSafe {
// responsible for deleting the returned value.
Value* SocketPoolInfoToValue() const;
+ // CertDatabase::Observer methods:
+ virtual void OnUserCertAdded(X509Certificate* cert);
+
private:
friend class HttpNetworkSessionPeer;