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

Side by Side Diff: crypto/nss_util.cc

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: Created 3 years, 9 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
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 6
7 #include <nss.h> 7 #include <nss.h>
8 #include <pk11pub.h> 8 #include <pk11pub.h>
9 #include <plarena.h> 9 #include <plarena.h>
10 #include <prerror.h> 10 #include <prerror.h>
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 env->SetVar(kUseCacheEnvVar, "yes"); 165 env->SetVar(kUseCacheEnvVar, "yes");
166 } 166 }
167 } 167 }
168 168
169 // A singleton to initialize/deinitialize NSPR. 169 // A singleton to initialize/deinitialize NSPR.
170 // Separate from the NSS singleton because we initialize NSPR on the UI thread. 170 // Separate from the NSS singleton because we initialize NSPR on the UI thread.
171 // Now that we're leaking the singleton, we could merge back with the NSS 171 // Now that we're leaking the singleton, we could merge back with the NSS
172 // singleton. 172 // singleton.
173 class NSPRInitSingleton { 173 class NSPRInitSingleton {
174 private: 174 private:
175 friend struct base::DefaultLazyInstanceTraits<NSPRInitSingleton>; 175 friend struct base::LazyInstanceTraitsBase<NSPRInitSingleton>;
176 176
177 NSPRInitSingleton() { 177 NSPRInitSingleton() {
178 PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); 178 PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
179 } 179 }
180 180
181 // NOTE(willchan): We don't actually execute this code since we leak NSS to 181 // NOTE(willchan): We don't actually execute this code since we leak NSS to
182 // prevent non-joinable threads from using NSS after it's already been shut 182 // prevent non-joinable threads from using NSS after it's already been shut
183 // down. 183 // down.
184 ~NSPRInitSingleton() { 184 ~NSPRInitSingleton() {
185 PL_ArenaFinish(); 185 PL_ArenaFinish();
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 return ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_.get())); 650 return ScopedPK11Slot(PK11_ReferenceSlot(tpm_slot_.get()));
651 return ScopedPK11Slot(); 651 return ScopedPK11Slot();
652 } 652 }
653 #endif 653 #endif
654 654
655 base::Lock* write_lock() { 655 base::Lock* write_lock() {
656 return &write_lock_; 656 return &write_lock_;
657 } 657 }
658 658
659 private: 659 private:
660 friend struct base::DefaultLazyInstanceTraits<NSSInitSingleton>; 660 friend struct base::LazyInstanceTraitsBase<NSSInitSingleton>;
661 661
662 NSSInitSingleton() 662 NSSInitSingleton()
663 : tpm_token_enabled_for_nss_(false), 663 : tpm_token_enabled_for_nss_(false),
664 initializing_tpm_token_(false), 664 initializing_tpm_token_(false),
665 chaps_module_(nullptr), 665 chaps_module_(nullptr),
666 root_(nullptr) { 666 root_(nullptr) {
667 // It's safe to construct on any thread, since LazyInstance will prevent any 667 // It's safe to construct on any thread, since LazyInstance will prevent any
668 // other threads from accessing until the constructor is done. 668 // other threads from accessing until the constructor is done.
669 thread_checker_.DetachFromThread(); 669 thread_checker_.DetachFromThread();
670 670
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); 975 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue();
976 } 976 }
977 977
978 #if !defined(OS_CHROMEOS) 978 #if !defined(OS_CHROMEOS)
979 PK11SlotInfo* GetPersistentNSSKeySlot() { 979 PK11SlotInfo* GetPersistentNSSKeySlot() {
980 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); 980 return g_nss_singleton.Get().GetPersistentNSSKeySlot();
981 } 981 }
982 #endif 982 #endif
983 983
984 } // namespace crypto 984 } // namespace crypto
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698