| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "crypto/nss_util.h" | 5 #include "crypto/nss_util.h" |
| 6 #include "crypto/nss_util_internal.h" | 6 #include "crypto/nss_util_internal.h" |
| 7 | 7 |
| 8 #include <nss.h> | 8 #include <nss.h> |
| 9 #include <plarena.h> | 9 #include <plarena.h> |
| 10 #include <prerror.h> | 10 #include <prerror.h> |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // down. | 210 // down. |
| 211 ~NSPRInitSingleton() { | 211 ~NSPRInitSingleton() { |
| 212 PL_ArenaFinish(); | 212 PL_ArenaFinish(); |
| 213 PRStatus prstatus = PR_Cleanup(); | 213 PRStatus prstatus = PR_Cleanup(); |
| 214 if (prstatus != PR_SUCCESS) { | 214 if (prstatus != PR_SUCCESS) { |
| 215 LOG(ERROR) << "PR_Cleanup failed; was NSPR initialized on wrong thread?"; | 215 LOG(ERROR) << "PR_Cleanup failed; was NSPR initialized on wrong thread?"; |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 base::LazyInstance<NSPRInitSingleton, | 220 base::LazyInstance<NSPRInitSingleton>::Leaky |
| 221 base::LeakyLazyInstanceTraits<NSPRInitSingleton> > | |
| 222 g_nspr_singleton = LAZY_INSTANCE_INITIALIZER; | 221 g_nspr_singleton = LAZY_INSTANCE_INITIALIZER; |
| 223 | 222 |
| 224 class NSSInitSingleton { | 223 class NSSInitSingleton { |
| 225 public: | 224 public: |
| 226 #if defined(OS_CHROMEOS) | 225 #if defined(OS_CHROMEOS) |
| 227 void OpenPersistentNSSDB() { | 226 void OpenPersistentNSSDB() { |
| 228 if (!chromeos_user_logged_in_) { | 227 if (!chromeos_user_logged_in_) { |
| 229 // GetDefaultConfigDirectory causes us to do blocking IO on UI thread. | 228 // GetDefaultConfigDirectory causes us to do blocking IO on UI thread. |
| 230 // Temporarily allow it until we fix http://crbug.com/70119 | 229 // Temporarily allow it until we fix http://crbug.com/70119 |
| 231 base::ThreadRestrictions::ScopedAllowIO allow_io; | 230 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 #if defined(USE_NSS) | 604 #if defined(USE_NSS) |
| 606 // TODO(davidben): When https://bugzilla.mozilla.org/show_bug.cgi?id=564011 | 605 // TODO(davidben): When https://bugzilla.mozilla.org/show_bug.cgi?id=564011 |
| 607 // is fixed, we will no longer need the lock. | 606 // is fixed, we will no longer need the lock. |
| 608 base::Lock write_lock_; | 607 base::Lock write_lock_; |
| 609 #endif // defined(USE_NSS) | 608 #endif // defined(USE_NSS) |
| 610 }; | 609 }; |
| 611 | 610 |
| 612 // static | 611 // static |
| 613 bool NSSInitSingleton::force_nodb_init_ = false; | 612 bool NSSInitSingleton::force_nodb_init_ = false; |
| 614 | 613 |
| 615 base::LazyInstance<NSSInitSingleton, | 614 base::LazyInstance<NSSInitSingleton>::Leaky |
| 616 base::LeakyLazyInstanceTraits<NSSInitSingleton> > | |
| 617 g_nss_singleton = LAZY_INSTANCE_INITIALIZER; | 615 g_nss_singleton = LAZY_INSTANCE_INITIALIZER; |
| 618 | 616 |
| 619 } // namespace | 617 } // namespace |
| 620 | 618 |
| 621 #if defined(USE_NSS) | 619 #if defined(USE_NSS) |
| 622 void EarlySetupForNSSInit() { | 620 void EarlySetupForNSSInit() { |
| 623 FilePath database_dir = GetInitialConfigDirectory(); | 621 FilePath database_dir = GetInitialConfigDirectory(); |
| 624 if (!database_dir.empty()) | 622 if (!database_dir.empty()) |
| 625 UseLocalCacheOfNSSDatabaseIfNFS(database_dir); | 623 UseLocalCacheOfNSSDatabaseIfNFS(database_dir); |
| 626 } | 624 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 | 778 |
| 781 PK11SlotInfo* GetPublicNSSKeySlot() { | 779 PK11SlotInfo* GetPublicNSSKeySlot() { |
| 782 return g_nss_singleton.Get().GetPublicNSSKeySlot(); | 780 return g_nss_singleton.Get().GetPublicNSSKeySlot(); |
| 783 } | 781 } |
| 784 | 782 |
| 785 PK11SlotInfo* GetPrivateNSSKeySlot() { | 783 PK11SlotInfo* GetPrivateNSSKeySlot() { |
| 786 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); | 784 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); |
| 787 } | 785 } |
| 788 | 786 |
| 789 } // namespace crypto | 787 } // namespace crypto |
| OLD | NEW |