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

Side by Side Diff: base/nss_util.h

Issue 2838010: Add a unit test to check KeygenHandler's thread-safety (Closed)
Patch Set: Another revision Created 10 years, 6 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
« no previous file with comments | « no previous file | base/nss_util.cc » ('j') | base/nss_util.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef BASE_NSS_UTIL_H_ 5 #ifndef BASE_NSS_UTIL_H_
6 #define BASE_NSS_UTIL_H_ 6 #define BASE_NSS_UTIL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 9
10 #if defined(USE_NSS)
11 class Lock;
12 #endif // defined(USE_NSS)
wtc 2010/06/21 22:40:53 Nit: two spaces before the comment. See the Style
davidben 2010/06/22 02:54:56 Done.
13
10 // This file specifically doesn't depend on any NSS or NSPR headers because it 14 // This file specifically doesn't depend on any NSS or NSPR headers because it
11 // is included by various (non-crypto) parts of chrome to call the 15 // is included by various (non-crypto) parts of chrome to call the
12 // initialization functions. 16 // initialization functions.
13 namespace base { 17 namespace base {
14 18
15 class Time; 19 class Time;
16 20
17 // Initialize NRPR if it isn't already initialized. This function is 21 // Initialize NRPR if it isn't already initialized. This function is
18 // thread-safe, and NSPR will only ever be initialized once. NSPR will be 22 // thread-safe, and NSPR will only ever be initialized once. NSPR will be
19 // properly shut down on program exit. 23 // properly shut down on program exit.
20 void EnsureNSPRInit(); 24 void EnsureNSPRInit();
21 25
22 // Initialize NSS if it isn't already initialized. This must be called before 26 // Initialize NSS if it isn't already initialized. This must be called before
23 // any other NSS functions. This function is thread-safe, and NSS will only 27 // any other NSS functions. This function is thread-safe, and NSS will only
24 // ever be initialized once. NSS will be properly shut down on program exit. 28 // ever be initialized once. NSS will be properly shut down on program exit.
25 void EnsureNSSInit(); 29 void EnsureNSSInit();
26 30
27 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
28 // Open the r/w nssdb that's stored inside the user's encrypted home directory. 32 // Open the r/w nssdb that's stored inside the user's encrypted home directory.
29 void OpenPersistentNSSDB(); 33 void OpenPersistentNSSDB();
30 #endif 34 #endif
31 35
32 // Convert a NSS PRTime value into a base::Time object. 36 // Convert a NSS PRTime value into a base::Time object.
33 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. 37 // We use a int64 instead of PRTime here to avoid depending on NSPR headers.
34 Time PRTimeToBaseTime(int64 prtime); 38 Time PRTimeToBaseTime(int64 prtime);
35 39
40 #if defined(USE_NSS)
41 // NSS has a bug which can cause a deadlock or stall in some cases when writing
42 // to the certDB. It also has a bug which causes concurrent key pair
43 // generations to scribble over each other. To work around this, we synchronize
44 // writes to the NSS databases with a global lock. The lock is hidden beneath a
45 // function for easy disabling when the bug is fixed. Callers should allow for
46 // it to return NULL in the future.
47 //
48 // See https://bugzilla.mozilla.org/show_bug.cgi?id=564011
49 Lock* GetNSSWriteLock();
50
51 // A helper class that acquires the NSS write Lock while the AutoNSSWriteLock
52 // is in scope.
53 class AutoNSSWriteLock {
54 public:
55 AutoNSSWriteLock();
56 ~AutoNSSWriteLock();
57 private:
58 Lock *lock_;
59 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock);
60 };
61
62 #endif // defined(USE_NSS)
davidben 2010/06/22 02:54:56 Also added a space here.
63
36 } // namespace base 64 } // namespace base
37 65
38 #endif // BASE_NSS_UTIL_H_ 66 #endif // BASE_NSS_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/nss_util.cc » ('j') | base/nss_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698