| Index: crypto/nss_util.cc
|
| diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
|
| index 5b8c6f5173bd3dc060b88767755cfaaba164d2e4..571ee1fdcbb5626af04ed1b8d6f74a8a94dd6a4d 100644
|
| --- a/crypto/nss_util.cc
|
| +++ b/crypto/nss_util.cc
|
| @@ -31,7 +31,6 @@
|
| #include "base/environment.h"
|
| #include "base/file_util.h"
|
| #include "base/files/file_path.h"
|
| -#include "base/files/scoped_temp_dir.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| @@ -470,6 +469,14 @@ class NSSInitSingleton {
|
|
|
| return chromeos_user_map_[username_hash]->GetPrivateSlot(callback);
|
| }
|
| +
|
| + void CloseTestChromeOSUser(const std::string& username_hash) {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + ChromeOSUserMap::iterator i = chromeos_user_map_.find(username_hash);
|
| + DCHECK(i != chromeos_user_map_.end());
|
| + delete i->second;
|
| + chromeos_user_map_.erase(i);
|
| + }
|
| #endif // defined(OS_CHROMEOS)
|
|
|
|
|
| @@ -983,6 +990,27 @@ bool InitializeTPMToken(int token_slot_id) {
|
| return g_nss_singleton.Get().InitializeTPMToken(token_slot_id);
|
| }
|
|
|
| +ScopedTestNSSChromeOSUser::ScopedTestNSSChromeOSUser(
|
| + const std::string& username_hash)
|
| + : username_hash_(username_hash), constructed_successfully_(false) {
|
| + if (!temp_dir_.CreateUniqueTempDir())
|
| + return;
|
| + constructed_successfully_ =
|
| + InitializeNSSForChromeOSUser(username_hash,
|
| + username_hash,
|
| + false /* is_primary_user */,
|
| + temp_dir_.path());
|
| +}
|
| +
|
| +ScopedTestNSSChromeOSUser::~ScopedTestNSSChromeOSUser() {
|
| + if (constructed_successfully_)
|
| + g_nss_singleton.Get().CloseTestChromeOSUser(username_hash_);
|
| +}
|
| +
|
| +void ScopedTestNSSChromeOSUser::FinishInit() {
|
| + InitializePrivateSoftwareSlotForChromeOSUser(username_hash_);
|
| +}
|
| +
|
| bool InitializeNSSForChromeOSUser(
|
| const std::string& email,
|
| const std::string& username_hash,
|
|
|