Index: crypto/nss_util.cc |
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc |
index 96c13e219dcbe222532d4d683266217b6e47bb2d..3e7ce0c805b818a2ef6b17a0fbb54208264c531b 100644 |
--- a/crypto/nss_util.cc |
+++ b/crypto/nss_util.cc |
@@ -386,11 +386,11 @@ class NSSInitSingleton { |
<< ", got tpm slot: " << !!tpm_args->tpm_slot; |
chaps_module_ = tpm_args->chaps_module; |
- tpm_slot_ = tpm_args->tpm_slot; |
+ tpm_slot_.reset(tpm_args->tpm_slot); |
Ryan Sleevi
2014/07/29 23:43:40
Would be great to either make this a scoped_ptr<>
pneubeck (no reviews)
2014/07/30 08:28:49
Done.
|
if (!chaps_module_ && test_system_slot_) { |
// chromeos_unittests try to test the TPM initialization process. If we |
// have a test DB open, pretend that it is the TPM slot. |
- tpm_slot_ = PK11_ReferenceSlot(test_system_slot_.get()); |
+ tpm_slot_.reset(PK11_ReferenceSlot(test_system_slot_.get())); |
} |
initializing_tpm_token_ = false; |
@@ -419,7 +419,7 @@ class NSSInitSingleton { |
<< base::debug::StackTrace().ToString(); |
} |
- if (tpm_slot_ != NULL) |
+ if (tpm_slot_) |
return true; |
if (!callback.is_null()) |
@@ -596,7 +596,7 @@ class NSSInitSingleton { |
#if defined(OS_CHROMEOS) |
void GetSystemNSSKeySlotCallback( |
const base::Callback<void(ScopedPK11Slot)>& callback) { |
- callback.Run(ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_))); |
+ callback.Run(ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_.get()))); |
} |
ScopedPK11Slot GetSystemNSSKeySlot( |
@@ -615,7 +615,7 @@ class NSSInitSingleton { |
callback); |
} |
if (IsTPMTokenReady(wrapped_callback)) |
- return ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_)); |
+ return ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_.get())); |
return ScopedPK11Slot(); |
} |
#endif |
@@ -639,7 +639,6 @@ class NSSInitSingleton { |
: tpm_token_enabled_for_nss_(false), |
initializing_tpm_token_(false), |
chaps_module_(NULL), |
- tpm_slot_(NULL), |
root_(NULL) { |
base::TimeTicks start_time = base::TimeTicks::Now(); |
@@ -756,10 +755,7 @@ class NSSInitSingleton { |
#if defined(OS_CHROMEOS) |
STLDeleteValues(&chromeos_user_map_); |
#endif |
- if (tpm_slot_) { |
- PK11_FreeSlot(tpm_slot_); |
- tpm_slot_ = NULL; |
- } |
+ tpm_slot_.reset(); |
if (root_) { |
SECMOD_UnloadUserModule(root_); |
SECMOD_DestroyModule(root_); |
@@ -844,7 +840,7 @@ class NSSInitSingleton { |
typedef std::vector<base::Closure> TPMReadyCallbackList; |
TPMReadyCallbackList tpm_ready_callback_list_; |
SECMODModule* chaps_module_; |
- PK11SlotInfo* tpm_slot_; |
+ crypto::ScopedPK11Slot tpm_slot_; |
SECMODModule* root_; |
#if defined(OS_CHROMEOS) |
typedef std::map<std::string, ChromeOSUserData*> ChromeOSUserMap; |