Chromium Code Reviews| Index: base/nss_init.cc | 
| diff --git a/base/nss_init.cc b/base/nss_init.cc | 
| index e25232c10c40d7529b8db82f0174f9f94deb1ade..64384bca3cbd0f20678db310e005dd83c229b7f4 100644 | 
| --- a/base/nss_init.cc | 
| +++ b/base/nss_init.cc | 
| @@ -1,4 +1,4 @@ | 
| -// Copyright (c) 2008 The Chromium Authors. All rights reserved. | 
| +// Copyright (c) 2009 The Chromium Authors. All rights reserved. | 
| 
 
wtc
2009/09/02 01:17:17
This should be 2008-2009.
 
 | 
| // Use of this source code is governed by a BSD-style license that can be | 
| // found in the LICENSE file. | 
| @@ -56,6 +56,23 @@ SECMODModule *InitDefaultRootCerts() { | 
| return NULL; | 
| } | 
| +// A singleton to initialize/deinitialize NSPR. | 
| +// Separate from the NSS singleton because we initialize it on the UI thread. | 
| 
 
wtc
2009/09/02 01:17:17
Nit: it => NSPR (otherwise it's not clear what "it
 
 | 
| +class NSPRInitSingleton { | 
| + public: | 
| + NSPRInitSingleton() { | 
| + PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); | 
| + } | 
| + | 
| + ~NSPRInitSingleton() { | 
| + PRStatus prstatus = PR_Cleanup(); | 
| + if (prstatus != PR_SUCCESS) { | 
| + LOG(ERROR) << "PR_Cleanup failed; " | 
| + "Is NSPR getting destroyed on wrong thread?"; | 
| 
 
wtc
2009/09/02 01:17:17
Since Singleton destructors run on the main thread
 
 | 
| + } | 
| + } | 
| +}; | 
| + | 
| class NSSInitSingleton { | 
| public: | 
| NSSInitSingleton() { | 
| @@ -139,14 +156,6 @@ class NSSInitSingleton { | 
| } | 
| PL_ArenaFinish(); | 
| - | 
| - PRStatus prstatus = PR_Cleanup(); | 
| - if (prstatus != PR_SUCCESS) { | 
| - // We LOG(ERROR) here because this failure is bad: it indicates | 
| - // NSPR isn't initialized and cleaned up on the same thread. | 
| - LOG(ERROR) << "PR_Cleanup failed; see " | 
| - "http://code.google.com/p/chromium/issues/detail?id=18410"; | 
| - } | 
| } | 
| private: | 
| @@ -157,6 +166,10 @@ class NSSInitSingleton { | 
| namespace base { | 
| +void EnsureNSPRInit() { | 
| + Singleton<NSPRInitSingleton>::get(); | 
| +} | 
| + | 
| void EnsureNSSInit() { | 
| Singleton<NSSInitSingleton>::get(); | 
| } |