Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: net/cert/nss_cert_database.cc

Issue 370633003: Break cyclic dependency between CertDatabase and NSSCertDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed comments. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/nss_cert_database.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/nss_cert_database.cc
diff --git a/net/cert/nss_cert_database.cc b/net/cert/nss_cert_database.cc
index c1fc4f9d0cca66473b792a447aeb846fd8b15a24..db51321b7642c59ab970d3fe8e2b2b55ed81b801 100644
--- a/net/cert/nss_cert_database.cc
+++ b/net/cert/nss_cert_database.cc
@@ -42,6 +42,34 @@ namespace net {
namespace {
+// Helper that observes events from the NSSCertDatabase and forwards them to
+// the given CertDatabase.
+class CertNotificationForwarder : public NSSCertDatabase::Observer {
+ public:
+ explicit CertNotificationForwarder(CertDatabase* cert_db)
+ : cert_db_(cert_db) {}
+
+ virtual ~CertNotificationForwarder() {}
+
+ // NSSCertDatabase::Observer implementation:
+ virtual void OnCertAdded(const X509Certificate* cert) OVERRIDE {
+ cert_db_->NotifyObserversOfCertAdded(cert);
+ }
+
+ virtual void OnCertRemoved(const X509Certificate* cert) OVERRIDE {
+ cert_db_->NotifyObserversOfCertRemoved(cert);
+ }
+
+ virtual void OnCACertChanged(const X509Certificate* cert) OVERRIDE {
+ cert_db_->NotifyObserversOfCACertChanged(cert);
+ }
+
+ private:
+ CertDatabase* cert_db_;
+
+ DISALLOW_COPY_AND_ASSIGN(CertNotificationForwarder);
+};
+
base::LazyInstance<NSSCertDatabase>::Leaky
g_nss_cert_database = LAZY_INSTANCE_INITIALIZER;
@@ -69,7 +97,9 @@ NSSCertDatabase::NSSCertDatabase()
: observer_list_(new ObserverListThreadSafe<Observer>),
weak_factory_(this) {
// This also makes sure that NSS has been initialized.
- CertDatabase::GetInstance()->ObserveNSSCertDatabase(this);
+ CertDatabase* cert_db = CertDatabase::GetInstance();
+ cert_notification_forwarder_.reset(new CertNotificationForwarder(cert_db));
+ AddObserver(cert_notification_forwarder_.get());
psm::EnsurePKCS12Init();
}
« no previous file with comments | « net/cert/nss_cert_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698