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

Side by Side Diff: crypto/nss_util.cc

Issue 8947021: Destroy all Singletons and LazyInstances between each test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NSS Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <pk11pub.h> 9 #include <pk11pub.h>
10 #include <plarena.h> 10 #include <plarena.h>
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 done: 350 done:
351 if (slot) 351 if (slot)
352 PK11_FreeSlot(slot); 352 PK11_FreeSlot(slot);
353 353
354 return key ? SymmetricKey::CreateFromKey(key) : NULL; 354 return key ? SymmetricKey::CreateFromKey(key) : NULL;
355 } 355 }
356 #endif // defined(OS_CHROMEOS) 356 #endif // defined(OS_CHROMEOS)
357 357
358 358
359 bool OpenTestNSSDB() { 359 bool OpenTestNSSDB() {
Ryan Sleevi 2013/05/22 19:50:59 I'm not fully sure I understood - is this a failur
Robert Sesek 2013/05/23 16:55:16 This is a failure on Linux with GYP_DEFINES=chrome
360 if (test_slot_) 360 if (test_slot_)
361 return true; 361 return true;
362 if (!g_test_nss_db_dir.Get().CreateUniqueTempDir()) 362 if (!g_test_nss_db_dir.Get().CreateUniqueTempDir())
363 return false; 363 return false;
364 test_slot_ = OpenUserDB(g_test_nss_db_dir.Get().path(), "Test DB"); 364 test_slot_ = OpenUserDB(g_test_nss_db_dir.Get().path(), "Test DB");
Ryan Sleevi 2013/05/22 19:50:59 if (test_slot_) PK11_UserEnableSlot(test_slot_);
365 return !!test_slot_; 365 return !!test_slot_;
366 } 366 }
367 367
368 void CloseTestNSSDB() { 368 void CloseTestNSSDB() {
369 if (test_slot_) { 369 if (test_slot_) {
Ryan Sleevi 2013/05/22 19:50:59 if (!test_slot_) return; PK11_UserDisableSlot(t
370 SECStatus status = SECMOD_CloseUserDB(test_slot_); 370 SECStatus status = SECMOD_CloseUserDB(test_slot_);
371 if (status != SECSuccess) 371 if (status != SECSuccess)
372 PLOG(ERROR) << "SECMOD_CloseUserDB failed: " << PORT_GetError(); 372 PLOG(ERROR) << "SECMOD_CloseUserDB failed: " << PORT_GetError();
373 PK11_FreeSlot(test_slot_); 373 PK11_FreeSlot(test_slot_);
374 test_slot_ = NULL; 374 test_slot_ = NULL;
375 ignore_result(g_test_nss_db_dir.Get().Delete()); 375 ignore_result(g_test_nss_db_dir.Get().Delete());
376 } 376 }
377 } 377 }
378 378
379 PK11SlotInfo* GetPublicNSSKeySlot() { 379 PK11SlotInfo* GetPublicNSSKeySlot() {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 bool CheckNSSVersion(const char* version) { 739 bool CheckNSSVersion(const char* version) {
740 return !!NSS_VersionCheck(version); 740 return !!NSS_VersionCheck(version);
741 } 741 }
742 742
743 #if defined(USE_NSS) 743 #if defined(USE_NSS)
744 ScopedTestNSSDB::ScopedTestNSSDB() 744 ScopedTestNSSDB::ScopedTestNSSDB()
745 : is_open_(g_nss_singleton.Get().OpenTestNSSDB()) { 745 : is_open_(g_nss_singleton.Get().OpenTestNSSDB()) {
746 } 746 }
747 747
748 ScopedTestNSSDB::~ScopedTestNSSDB() { 748 ScopedTestNSSDB::~ScopedTestNSSDB() {
749 // TODO(mattm): Close the dababase once NSS 3.14 is required, 749 if (NSS_VersionCheck("3.14"))
750 // which fixes https://bugzilla.mozilla.org/show_bug.cgi?id=588269 750 g_nss_singleton.Get().CloseTestNSSDB();
751 // Resource leaks are suppressed. http://crbug.com/156433 .
752 } 751 }
753 752
754 base::Lock* GetNSSWriteLock() { 753 base::Lock* GetNSSWriteLock() {
755 return g_nss_singleton.Get().write_lock(); 754 return g_nss_singleton.Get().write_lock();
756 } 755 }
757 756
758 AutoNSSWriteLock::AutoNSSWriteLock() : lock_(GetNSSWriteLock()) { 757 AutoNSSWriteLock::AutoNSSWriteLock() : lock_(GetNSSWriteLock()) {
759 // May be NULL if the lock is not needed in our version of NSS. 758 // May be NULL if the lock is not needed in our version of NSS.
760 if (lock_) 759 if (lock_)
761 lock_->Acquire(); 760 lock_->Acquire();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 816
818 PK11SlotInfo* GetPublicNSSKeySlot() { 817 PK11SlotInfo* GetPublicNSSKeySlot() {
819 return g_nss_singleton.Get().GetPublicNSSKeySlot(); 818 return g_nss_singleton.Get().GetPublicNSSKeySlot();
820 } 819 }
821 820
822 PK11SlotInfo* GetPrivateNSSKeySlot() { 821 PK11SlotInfo* GetPrivateNSSKeySlot() {
823 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); 822 return g_nss_singleton.Get().GetPrivateNSSKeySlot();
824 } 823 }
825 824
826 } // namespace crypto 825 } // namespace crypto
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_certificate_importer_unittest.cc ('k') | gpu/command_buffer/service/shader_translator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698