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

Unified Diff: crypto/nss_util.cc

Issue 426983002: Make crypto::GetSystemNSSKeySlot asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed typo in comment. 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 | « no previous file | crypto/nss_util_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/nss_util.cc
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index 64489dc3c4a9a3308eb73c4fa71d0935145002d4..96c13e219dcbe222532d4d683266217b6e47bb2d 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -594,18 +594,29 @@ class NSSInitSingleton {
#endif
#if defined(OS_CHROMEOS)
- PK11SlotInfo* GetSystemNSSKeySlot() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ void GetSystemNSSKeySlotCallback(
+ const base::Callback<void(ScopedPK11Slot)>& callback) {
+ callback.Run(ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_)));
+ }
+ ScopedPK11Slot GetSystemNSSKeySlot(
+ const base::Callback<void(ScopedPK11Slot)>& callback) {
+ DCHECK(thread_checker_.CalledOnValidThread());
// TODO(mattm): chromeos::TPMTokenloader always calls
// InitializeTPMTokenAndSystemSlot with slot 0. If the system slot is
// disabled, tpm_slot_ will be the first user's slot instead. Can that be
// detected and return NULL instead?
- if (tpm_token_enabled_for_nss_ && IsTPMTokenReady(base::Closure()))
- return PK11_ReferenceSlot(tpm_slot_);
- // If we were supposed to get the hardware token, but were
- // unable to, return NULL rather than fall back to sofware.
- return NULL;
+
+ base::Closure wrapped_callback;
+ if (!callback.is_null()) {
+ wrapped_callback =
+ base::Bind(&NSSInitSingleton::GetSystemNSSKeySlotCallback,
+ base::Unretained(this) /* singleton is leaky */,
+ callback);
+ }
+ if (IsTPMTokenReady(wrapped_callback))
+ return ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_));
+ return ScopedPK11Slot();
}
#endif
@@ -1000,8 +1011,9 @@ AutoSECMODListReadLock::~AutoSECMODListReadLock() {
#endif // defined(USE_NSS)
#if defined(OS_CHROMEOS)
-PK11SlotInfo* GetSystemNSSKeySlot() {
- return g_nss_singleton.Get().GetSystemNSSKeySlot();
+ScopedPK11Slot GetSystemNSSKeySlot(
+ const base::Callback<void(ScopedPK11Slot)>& callback) {
+ return g_nss_singleton.Get().GetSystemNSSKeySlot(callback);
}
void SetSystemKeySlotForTesting(ScopedPK11Slot slot) {
« no previous file with comments | « no previous file | crypto/nss_util_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698