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

Unified Diff: base/nss_init.cc

Issue 178062: linux: call PR_Init on UI thread (Closed)
Patch Set: copyrights Created 11 years, 4 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 side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698