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

Side by Side Diff: crypto/nss_util.h

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CRYPTO_NSS_UTIL_H_
6 #define BASE_NSS_UTIL_H_ 6 #define CRYPTO_NSS_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 10
11 #if defined(USE_NSS) 11 #if defined(USE_NSS)
12 class FilePath; 12 class FilePath;
13 #endif // defined(USE_NSS) 13 #endif // defined(USE_NSS)
14 14
15 namespace base {
16 class Lock;
17 class Time;
18 } // namespace base
19
15 // This file specifically doesn't depend on any NSS or NSPR headers because it 20 // This file specifically doesn't depend on any NSS or NSPR headers because it
16 // is included by various (non-crypto) parts of chrome to call the 21 // is included by various (non-crypto) parts of chrome to call the
17 // initialization functions. 22 // initialization functions.
18 namespace base { 23 namespace crypto {
19
20 class Lock;
21 class Time;
22 24
23 #if defined(USE_NSS) 25 #if defined(USE_NSS)
24 // EarlySetupForNSSInit performs lightweight setup which must occur before the 26 // EarlySetupForNSSInit performs lightweight setup which must occur before the
25 // process goes multithreaded. This does not initialise NSS. For test, see 27 // process goes multithreaded. This does not initialise NSS. For test, see
26 // EnsureNSSInit. 28 // EnsureNSSInit.
27 void EarlySetupForNSSInit(); 29 void EarlySetupForNSSInit();
28 #endif 30 #endif
29 31
30 // Initialize NRPR if it isn't already initialized. This function is 32 // Initialize NRPR if it isn't already initialized. This function is
31 // thread-safe, and NSPR will only ever be initialized once. NSPR will be 33 // thread-safe, and NSPR will only ever be initialized once. NSPR will be
32 // properly shut down on program exit. 34 // properly shut down on program exit.
33 void EnsureNSPRInit(); 35 void EnsureNSPRInit();
34 36
35 // Initialize NSS if it isn't already initialized. This must be called before 37 // Initialize NSS if it isn't already initialized. This must be called before
36 // any other NSS functions. This function is thread-safe, and NSS will only 38 // any other NSS functions. This function is thread-safe, and NSS will only
37 // ever be initialized once. NSS will be properly shut down on program exit. 39 // ever be initialized once. NSS will be properly shut down on program exit.
wtc 2011/04/07 05:35:53 I believe EnsureNSSInit() no longer shuts down NSS
rvargas (doing something else) 2011/04/08 21:04:07 Done.
38 void EnsureNSSInit(); 40 void EnsureNSSInit();
39 41
40 // Call this before calling EnsureNSSInit() will force NSS to initialize 42 // Call this before calling EnsureNSSInit() will force NSS to initialize
41 // without a persistent DB. This is used for the special case where access of 43 // without a persistent DB. This is used for the special case where access of
42 // persistent DB is prohibited. 44 // persistent DB is prohibited.
43 // 45 //
44 // TODO(hclam): Isolate loading default root certs. 46 // TODO(hclam): Isolate loading default root certs.
45 // 47 //
46 // NSS will be initialized without loading any user security modules, including 48 // NSS will be initialized without loading any user security modules, including
47 // the built-in root certificates module. User security modules need to be 49 // the built-in root certificates module. User security modules need to be
(...skipping 30 matching lines...) Expand all
78 // A sample version string is "3.12.3". 80 // A sample version string is "3.12.3".
79 bool CheckNSSVersion(const char* version); 81 bool CheckNSSVersion(const char* version);
80 82
81 #if defined(OS_CHROMEOS) 83 #if defined(OS_CHROMEOS)
82 // Open the r/w nssdb that's stored inside the user's encrypted home directory. 84 // Open the r/w nssdb that's stored inside the user's encrypted home directory.
83 void OpenPersistentNSSDB(); 85 void OpenPersistentNSSDB();
84 #endif 86 #endif
85 87
86 // Convert a NSS PRTime value into a base::Time object. 88 // Convert a NSS PRTime value into a base::Time object.
87 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. 89 // We use a int64 instead of PRTime here to avoid depending on NSPR headers.
88 Time PRTimeToBaseTime(int64 prtime); 90 base::Time PRTimeToBaseTime(int64 prtime);
89 91
90 #if defined(USE_NSS) 92 #if defined(USE_NSS)
91 // Exposed for unittests only. |path| should be an existing directory under 93 // Exposed for unittests only. |path| should be an existing directory under
92 // which the DB files will be placed. |description| is a user-visible name for 94 // which the DB files will be placed. |description| is a user-visible name for
93 // the DB, as a utf8 string, which will be truncated at 32 bytes. 95 // the DB, as a utf8 string, which will be truncated at 32 bytes.
94 bool OpenTestNSSDB(const FilePath& path, const char* description); 96 bool OpenTestNSSDB(const FilePath& path, const char* description);
95 void CloseTestNSSDB(); 97 void CloseTestNSSDB();
96 98
97 // NSS has a bug which can cause a deadlock or stall in some cases when writing 99 // NSS has a bug which can cause a deadlock or stall in some cases when writing
98 // to the certDB and keyDB. It also has a bug which causes concurrent key pair 100 // to the certDB and keyDB. It also has a bug which causes concurrent key pair
(...skipping 11 matching lines...) Expand all
110 public: 112 public:
111 AutoNSSWriteLock(); 113 AutoNSSWriteLock();
112 ~AutoNSSWriteLock(); 114 ~AutoNSSWriteLock();
113 private: 115 private:
114 Lock *lock_; 116 Lock *lock_;
115 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); 117 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock);
116 }; 118 };
117 119
118 #endif // defined(USE_NSS) 120 #endif // defined(USE_NSS)
119 121
120 } // namespace base 122 } // namespace crypto
121 123
122 #endif // BASE_NSS_UTIL_H_ 124 #endif // CRYPTO_NSS_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698