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

Side by Side Diff: crypto/nss_util.h

Issue 11196028: Revert 162327 - Implement ScopedTestNSSDB instead of OpenTestNSSDB() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « crypto/crypto_export.h ('k') | crypto/nss_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CRYPTO_NSS_UTIL_H_ 5 #ifndef CRYPTO_NSS_UTIL_H_
6 #define CRYPTO_NSS_UTIL_H_ 6 #define CRYPTO_NSS_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "crypto/crypto_export.h" 10 #include "crypto/crypto_export.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Convert a NSS PRTime value into a base::Time object. 121 // Convert a NSS PRTime value into a base::Time object.
122 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. 122 // We use a int64 instead of PRTime here to avoid depending on NSPR headers.
123 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime); 123 CRYPTO_EXPORT base::Time PRTimeToBaseTime(int64 prtime);
124 124
125 // Convert a base::Time object into a PRTime value. 125 // Convert a base::Time object into a PRTime value.
126 // We use a int64 instead of PRTime here to avoid depending on NSPR headers. 126 // We use a int64 instead of PRTime here to avoid depending on NSPR headers.
127 CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time); 127 CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time);
128 128
129 #if defined(USE_NSS) 129 #if defined(USE_NSS)
130 // Exposed for unittests only. 130 // Exposed for unittests only.
131 // TODO(mattm): When NSS 3.14 is the minimum version required, 131 // TODO(mattm): when https://bugzilla.mozilla.org/show_bug.cgi?id=588269 is
132 // switch back to using a separate user DB for each test. 132 // fixed, switch back to using a separate userdb for each test. (Maybe refactor
133 // Because of https://bugzilla.mozilla.org/show_bug.cgi?id=588269 , the 133 // to provide a ScopedTestNSSDB instead of open/close methods.)
134 // opened user DB is not automatically closed. 134 CRYPTO_EXPORT bool OpenTestNSSDB();
135 class CRYPTO_EXPORT_PRIVATE ScopedTestNSSDB { 135 // NOTE: due to NSS bug 588269, mentioned above, there is no CloseTestNSSDB.
136 public:
137 ScopedTestNSSDB();
138 ~ScopedTestNSSDB();
139
140 bool is_open() { return is_open_; }
141
142 private:
143 bool is_open_;
144 DISALLOW_COPY_AND_ASSIGN(ScopedTestNSSDB);
145 };
146 136
147 // NSS has a bug which can cause a deadlock or stall in some cases when writing 137 // NSS has a bug which can cause a deadlock or stall in some cases when writing
148 // to the certDB and keyDB. It also has a bug which causes concurrent key pair 138 // to the certDB and keyDB. It also has a bug which causes concurrent key pair
149 // generations to scribble over each other. To work around this, we synchronize 139 // generations to scribble over each other. To work around this, we synchronize
150 // writes to the NSS databases with a global lock. The lock is hidden beneath a 140 // writes to the NSS databases with a global lock. The lock is hidden beneath a
151 // function for easy disabling when the bug is fixed. Callers should allow for 141 // function for easy disabling when the bug is fixed. Callers should allow for
152 // it to return NULL in the future. 142 // it to return NULL in the future.
153 // 143 //
154 // See https://bugzilla.mozilla.org/show_bug.cgi?id=564011 144 // See https://bugzilla.mozilla.org/show_bug.cgi?id=564011
155 base::Lock* GetNSSWriteLock(); 145 base::Lock* GetNSSWriteLock();
156 146
157 // A helper class that acquires the NSS write Lock while the AutoNSSWriteLock 147 // A helper class that acquires the NSS write Lock while the AutoNSSWriteLock
158 // is in scope. 148 // is in scope.
159 class CRYPTO_EXPORT AutoNSSWriteLock { 149 class CRYPTO_EXPORT AutoNSSWriteLock {
160 public: 150 public:
161 AutoNSSWriteLock(); 151 AutoNSSWriteLock();
162 ~AutoNSSWriteLock(); 152 ~AutoNSSWriteLock();
163 private: 153 private:
164 base::Lock *lock_; 154 base::Lock *lock_;
165 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock); 155 DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock);
166 }; 156 };
167 157
168 #endif // defined(USE_NSS) 158 #endif // defined(USE_NSS)
169 159
170 } // namespace crypto 160 } // namespace crypto
171 161
172 #endif // CRYPTO_NSS_UTIL_H_ 162 #endif // CRYPTO_NSS_UTIL_H_
OLDNEW
« no previous file with comments | « crypto/crypto_export.h ('k') | crypto/nss_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698