Index: net/cert/nss_cert_database.cc |
diff --git a/net/cert/nss_cert_database.cc b/net/cert/nss_cert_database.cc |
index 38e60c6cb4510ff9b71d6fbf8c833323acf380c4..8b69ca53ab0c7c8edafa5ddb3ad6352336440b8f 100644 |
--- a/net/cert/nss_cert_database.cc |
+++ b/net/cert/nss_cert_database.cc |
@@ -12,15 +12,12 @@ |
#include "base/bind.h" |
#include "base/callback.h" |
-#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/observer_list_threadsafe.h" |
#include "base/task_runner.h" |
#include "base/task_runner_util.h" |
#include "base/threading/worker_pool.h" |
-#include "crypto/nss_util.h" |
-#include "crypto/nss_util_internal.h" |
#include "crypto/scoped_nss_types.h" |
#include "net/base/crypto_module.h" |
#include "net/base/net_errors.h" |
@@ -42,6 +39,8 @@ namespace net { |
namespace { |
+// TODO(pneubeck): Move this class out of NSSCertDatabase and to the caller of |
+// the c'tor of NSSCertDatabase, see https://crbug.com/395983 . |
// Helper that observes events from the NSSCertDatabase and forwards them to |
// the given CertDatabase. |
class CertNotificationForwarder : public NSSCertDatabase::Observer { |
@@ -70,9 +69,6 @@ class CertNotificationForwarder : public NSSCertDatabase::Observer { |
DISALLOW_COPY_AND_ASSIGN(CertNotificationForwarder); |
}; |
-base::LazyInstance<NSSCertDatabase>::Leaky |
- g_nss_cert_database = LAZY_INSTANCE_INITIALIZER; |
- |
} // namespace |
NSSCertDatabase::ImportCertFailure::ImportCertFailure( |
@@ -82,20 +78,15 @@ NSSCertDatabase::ImportCertFailure::ImportCertFailure( |
NSSCertDatabase::ImportCertFailure::~ImportCertFailure() {} |
-// static |
-NSSCertDatabase* NSSCertDatabase::GetInstance() { |
- // TODO(mattm): Remove this ifdef guard once the linux impl of |
- // GetNSSCertDatabaseForResourceContext does not call GetInstance. |
-#if defined(OS_CHROMEOS) |
- LOG(ERROR) << "NSSCertDatabase::GetInstance() is deprecated." |
- << "See http://crbug.com/329735."; |
-#endif |
- return &g_nss_cert_database.Get(); |
-} |
- |
-NSSCertDatabase::NSSCertDatabase() |
- : observer_list_(new ObserverListThreadSafe<Observer>), |
+NSSCertDatabase::NSSCertDatabase(crypto::ScopedPK11Slot public_slot, |
+ crypto::ScopedPK11Slot private_slot) |
+ : public_slot_(public_slot.Pass()), |
+ private_slot_(private_slot.Pass()), |
+ observer_list_(new ObserverListThreadSafe<Observer>), |
weak_factory_(this) { |
+ DCHECK(public_slot_); |
+ DCHECK(private_slot_); |
+ |
// This also makes sure that NSS has been initialized. |
CertDatabase* cert_db = CertDatabase::GetInstance(); |
cert_notification_forwarder_.reset(new CertNotificationForwarder(cert_db)); |
@@ -140,11 +131,11 @@ void NSSCertDatabase::ListCertsInSlot(const ListCertsCallback& callback, |
} |
crypto::ScopedPK11Slot NSSCertDatabase::GetPublicSlot() const { |
- return crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot()); |
+ return crypto::ScopedPK11Slot(PK11_ReferenceSlot(public_slot_.get())); |
} |
crypto::ScopedPK11Slot NSSCertDatabase::GetPrivateSlot() const { |
- return crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot()); |
+ return crypto::ScopedPK11Slot(PK11_ReferenceSlot(private_slot_.get())); |
} |
CryptoModule* NSSCertDatabase::GetPublicModule() const { |