diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 22:50:25 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 22:50:25 +0000 |
commit | 730fb13db106c6e9b29314b10221959bc4706650 (patch) | |
tree | 40801770d2db9afe260134b3ad4a93edf0b7b804 /base/nss_init.cc | |
parent | d1f2e93ff399c077d58e02c3799bb2bd817735fa (diff) | |
download | chromium_src-730fb13db106c6e9b29314b10221959bc4706650.zip chromium_src-730fb13db106c6e9b29314b10221959bc4706650.tar.gz chromium_src-730fb13db106c6e9b29314b10221959bc4706650.tar.bz2 |
linux: call PR_Init on UI thread
It complains about being shutdown on the wrong thread otherwise.
BUG=18410
Review URL: http://codereview.chromium.org/178062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/nss_init.cc')
-rw-r--r-- | base/nss_init.cc | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/base/nss_init.cc b/base/nss_init.cc index e25232c..7fed04c 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. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -56,9 +56,27 @@ SECMODModule *InitDefaultRootCerts() { return NULL; } +// A singleton to initialize/deinitialize NSPR. +// Separate from the NSS singleton because we initialize NSPR on the UI thread. +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; was NSPR initialized on wrong thread?"; + } + } +}; + class NSSInitSingleton { public: NSSInitSingleton() { + base::EnsureNSPRInit(); + SECStatus status; std::string database_dir = GetDefaultConfigDirectory(); if (!database_dir.empty()) { @@ -139,14 +157,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 +167,10 @@ class NSSInitSingleton { namespace base { +void EnsureNSPRInit() { + Singleton<NSPRInitSingleton>::get(); +} + void EnsureNSSInit() { Singleton<NSSInitSingleton>::get(); } |