OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/net/nss_context.h" | 5 #include "chrome/browser/net/nss_context.h" |
6 | 6 |
7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
8 #include "crypto/nss_util_internal.h" | 8 #include "crypto/nss_util_internal.h" |
9 #include "net/cert/nss_cert_database.h" | 9 #include "net/cert/nss_cert_database.h" |
10 | 10 |
11 namespace { | |
12 net::NSSCertDatabase* g_nss_cert_database = NULL; | |
13 } // namespace | |
14 | |
11 crypto::ScopedPK11Slot GetPublicNSSKeySlotForResourceContext( | 15 crypto::ScopedPK11Slot GetPublicNSSKeySlotForResourceContext( |
12 content::ResourceContext* context) { | 16 content::ResourceContext* context) { |
13 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 17 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
14 return crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot()); | 18 return crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot()); |
15 } | 19 } |
16 | 20 |
17 crypto::ScopedPK11Slot GetPrivateNSSKeySlotForResourceContext( | 21 crypto::ScopedPK11Slot GetPrivateNSSKeySlotForResourceContext( |
18 content::ResourceContext* context, | 22 content::ResourceContext* context, |
19 const base::Callback<void(crypto::ScopedPK11Slot)>& callback) { | 23 const base::Callback<void(crypto::ScopedPK11Slot)>& callback) { |
20 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 24 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
21 return crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot()); | 25 return crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot()); |
22 } | 26 } |
23 | 27 |
24 net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( | 28 net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( |
25 content::ResourceContext* context, | 29 content::ResourceContext* context, |
26 const base::Callback<void(net::NSSCertDatabase*)>& callback) { | 30 const base::Callback<void(net::NSSCertDatabase*)>& callback) { |
27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 31 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
28 return net::NSSCertDatabase::GetInstance(); | 32 if (!g_nss_cert_database) { |
33 g_nss_cert_database = new net::NSSCertDatabase( | |
34 crypto::ScopedPK11Slot(crypto::GetPersistentNSSKeySlot())); | |
35 } | |
36 return g_nss_cert_database; | |
Ryan Sleevi
2014/07/22 01:18:32
The only reason this is safe is because of the DCH
pneubeck (no reviews)
2014/07/22 08:23:56
The DCHECK indicates that we already don't handle
| |
29 } | 37 } |
OLD | NEW |