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

Side by Side Diff: crypto/scoped_test_nss_db.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 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
« no previous file with comments | « crypto/scoped_test_nss_db.h ('k') | crypto/scoped_test_system_nss_key_slot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "crypto/scoped_test_nss_db.h"
6
7 #include "base/logging.h"
8 #include "base/threading/thread_restrictions.h"
9 #include "crypto/nss_util.h"
10 #include "crypto/nss_util_internal.h"
11
12 namespace crypto {
13
14 ScopedTestNSSDB::ScopedTestNSSDB() {
15 EnsureNSSInit();
16 // NSS is allowed to do IO on the current thread since dispatching
17 // to a dedicated thread would still have the affect of blocking
18 // the current thread, due to NSS's internal locking requirements
19 base::ThreadRestrictions::ScopedAllowIO allow_io;
20
21 if (!temp_dir_.CreateUniqueTempDir())
22 return;
23
24 const char kTestDescription[] = "Test DB";
25 slot_ = OpenSoftwareNSSDB(temp_dir_.path(), kTestDescription);
26 }
27
28 ScopedTestNSSDB::~ScopedTestNSSDB() {
29 // Don't close when NSS is < 3.15.1, because it would require an additional
30 // sleep for 1 second after closing the database, due to
31 // http://bugzil.la/875601.
32 if (!NSS_VersionCheck("3.15.1")) {
33 LOG(ERROR) << "NSS version is < 3.15.1, test DB will not be closed.";
34 temp_dir_.Take();
35 return;
36 }
37
38 // NSS is allowed to do IO on the current thread since dispatching
39 // to a dedicated thread would still have the affect of blocking
40 // the current thread, due to NSS's internal locking requirements
41 base::ThreadRestrictions::ScopedAllowIO allow_io;
42
43 if (slot_) {
44 SECStatus status = SECMOD_CloseUserDB(slot_.get());
45 if (status != SECSuccess)
46 PLOG(ERROR) << "SECMOD_CloseUserDB failed: " << PORT_GetError();
47 }
48
49 if (!temp_dir_.Delete())
50 LOG(ERROR) << "Could not delete temporary directory.";
51 }
52
53 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/scoped_test_nss_db.h ('k') | crypto/scoped_test_system_nss_key_slot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698