Chromium Code Reviews| Index: net/cert/nss_cert_database.cc |
| diff --git a/net/cert/nss_cert_database.cc b/net/cert/nss_cert_database.cc |
| index d4ece1057454ff70ddb6c27896b9dda6e5513a02..5cad78b1229524270fc4ae3e033ab8c9bbb84b18 100644 |
| --- a/net/cert/nss_cert_database.cc |
| +++ b/net/cert/nss_cert_database.cc |
| @@ -10,9 +10,9 @@ |
| #include <pk11pub.h> |
| #include <secmod.h> |
| +#include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "base/memory/singleton.h" |
| #include "base/observer_list_threadsafe.h" |
| #include "crypto/nss_util.h" |
| #include "crypto/nss_util_internal.h" |
| @@ -35,6 +35,14 @@ namespace psm = mozilla_security_manager; |
| namespace net { |
| +namespace { |
| + |
| +base::LazyInstance<NSSCertDatabase>::Leaky |
| + g_nss_cert_database = LAZY_INSTANCE_INITIALIZER; |
| + |
| +} // namespace |
| + |
| + |
| NSSCertDatabase::ImportCertFailure::ImportCertFailure( |
| const scoped_refptr<X509Certificate>& cert, |
| int err) |
| @@ -44,13 +52,18 @@ NSSCertDatabase::ImportCertFailure::~ImportCertFailure() {} |
| // static |
| NSSCertDatabase* NSSCertDatabase::GetInstance() { |
| - return Singleton<NSSCertDatabase, |
| - LeakySingletonTraits<NSSCertDatabase> >::get(); |
| +#if defined(OS_CHROMEOS) |
| + DVLOG(1) << "Using global NSSCertDatabase. Consider using " |
| + << "NSSCertDatabaseChromeOS instead."; |
|
Ryan Sleevi
2013/12/18 21:28:32
comment nit: Make this a stronger warning.
"NSSCe
mattm
2013/12/19 22:35:00
Done.
|
| +#endif |
| + return &g_nss_cert_database.Get(); |
| } |
| NSSCertDatabase::NSSCertDatabase() |
| : observer_list_(new ObserverListThreadSafe<Observer>) { |
| - crypto::EnsureNSSInit(); |
| + // This also makes sure that NSS has been initialized. |
| + CertDatabase::GetInstance()->ObserveNSSCertDatabase(this); |
| + |
| psm::EnsurePKCS12Init(); |
| } |
| @@ -117,6 +130,9 @@ int NSSCertDatabase::ImportFromPKCS12( |
| const base::string16& password, |
| bool is_extractable, |
| net::CertificateList* imported_certs) { |
| + DVLOG(1) << __func__ << " " |
| + << PK11_GetModuleID(module->os_module_handle()) << ":" |
| + << PK11_GetSlotID(module->os_module_handle()); |
| int result = psm::nsPKCS12Blob_Import(module->os_module_handle(), |
| data.data(), data.size(), |
| password, |
| @@ -154,7 +170,7 @@ X509Certificate* NSSCertDatabase::FindRootInList( |
| &certn_1->os_cert_handle()->subject) == SECEqual) |
| return certn_1; |
| - VLOG(1) << "certificate list is not a hierarchy"; |
| + LOG(WARNING) << "certificate list is not a hierarchy"; |
| return cert0; |
| } |