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

Side by Side Diff: net/cert/nss_cert_database.h

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NSS operations now asynchronous. Created 6 years, 7 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) 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 NET_CERT_NSS_CERT_DATABASE_H_ 5 #ifndef NET_CERT_NSS_CERT_DATABASE_H_
6 #define NET_CERT_NSS_CERT_DATABASE_H_ 6 #define NET_CERT_NSS_CERT_DATABASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "crypto/scoped_nss_types.h" 15 #include "crypto/scoped_nss_types.h"
16 #include "net/base/net_errors.h"
16 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
17 #include "net/cert/cert_type.h" 18 #include "net/cert/cert_type.h"
18 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
19 20
20 namespace base { 21 namespace base {
21 template <typename T> struct DefaultLazyInstanceTraits; 22 template <typename T> struct DefaultLazyInstanceTraits;
22 class TaskRunner; 23 class TaskRunner;
23 } 24 }
24 template <class ObserverType> class ObserverListThreadSafe; 25 template <class ObserverType> class ObserverListThreadSafe;
25 26
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Get a list of unique certificates in the certificate database (one 103 // Get a list of unique certificates in the certificate database (one
103 // instance of all certificates). 104 // instance of all certificates).
104 // DEPRECATED by |ListCerts|. See http://crbug.com/340460. 105 // DEPRECATED by |ListCerts|. See http://crbug.com/340460.
105 virtual void ListCertsSync(CertificateList* certs); 106 virtual void ListCertsSync(CertificateList* certs);
106 107
107 // Asynchronously get a list of unique certificates in the certificate 108 // Asynchronously get a list of unique certificates in the certificate
108 // database (one instance of all certificates). Note that the callback may be 109 // database (one instance of all certificates). Note that the callback may be
109 // run even after the database is deleted. 110 // run even after the database is deleted.
110 virtual void ListCerts(const ListCertsCallback& callback); 111 virtual void ListCerts(const ListCertsCallback& callback);
111 112
113 // Get a list of certificates in the certificate database of the given slot.
114 // Note that the callback may be run even after the database is deleted.
115 // This is executed asynchronously on a worker thread, except if called from
116 // the target worker thread. Then it blocks but still posts a task running
117 // callback.
118 virtual void ListCertsInSlot(const ListCertsCallback& callback,
119 PK11SlotInfo* slot);
120
112 // Get the default slot for public key data. 121 // Get the default slot for public key data.
113 virtual crypto::ScopedPK11Slot GetPublicSlot() const; 122 virtual crypto::ScopedPK11Slot GetPublicSlot() const;
114 123
115 // Get the default slot for private key or mixed private/public key data. 124 // Get the default slot for private key or mixed private/public key data.
116 virtual crypto::ScopedPK11Slot GetPrivateSlot() const; 125 virtual crypto::ScopedPK11Slot GetPrivateSlot() const;
117 126
118 // Get the default module for public key data. 127 // Get the default module for public key data.
119 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. 128 // The returned pointer must be stored in a scoped_refptr<CryptoModule>.
120 // DEPRECATED: use GetPublicSlot instead. 129 // DEPRECATED: use GetPublicSlot instead.
121 // TODO(mattm): remove usage of this method and remove it. 130 // TODO(mattm): remove usage of this method and remove it.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 void RemoveObserver(Observer* observer); 230 void RemoveObserver(Observer* observer);
222 231
223 // Overrides task runner that's used for running slow tasks. 232 // Overrides task runner that's used for running slow tasks.
224 void SetSlowTaskRunnerForTest( 233 void SetSlowTaskRunnerForTest(
225 const scoped_refptr<base::TaskRunner>& task_runner); 234 const scoped_refptr<base::TaskRunner>& task_runner);
226 235
227 protected: 236 protected:
228 NSSCertDatabase(); 237 NSSCertDatabase();
229 virtual ~NSSCertDatabase(); 238 virtual ~NSSCertDatabase();
230 239
240 static void ListCertsInSlotImpl(crypto::ScopedPK11Slot slot,
241 CertificateList* certs);
242
231 // Certificate listing implementation used by |ListCerts| and |ListCertsSync|. 243 // Certificate listing implementation used by |ListCerts| and |ListCertsSync|.
232 // Static so it may safely be used on the worker thread. 244 // Static so it may safely be used on the worker thread.
233 static void ListCertsImpl(CertificateList* certs); 245 static void ListCertsImpl(CertificateList* certs);
234 246
235 // Gets task runner that should be used for slow tasks like certificate 247 // Gets task runner that should be used for slow tasks like certificate
236 // listing. Defaults to a base::WorkerPool runner, but may be overriden 248 // listing. Defaults to a base::WorkerPool runner, but may be overriden
237 // in tests (see SetSlowTaskRunnerForTest). 249 // in tests (see SetSlowTaskRunnerForTest).
238 scoped_refptr<base::TaskRunner> GetSlowTaskRunner() const; 250 scoped_refptr<base::TaskRunner> GetSlowTaskRunner() const;
239 251
240 private: 252 private:
241 friend struct base::DefaultLazyInstanceTraits<NSSCertDatabase>; 253 friend struct base::DefaultLazyInstanceTraits<NSSCertDatabase>;
242 254
243 // Broadcasts notifications to all registered observers. 255 // Broadcasts notifications to all registered observers.
244 void NotifyObserversOfCertAdded(const X509Certificate* cert); 256 void NotifyObserversOfCertAdded(const X509Certificate* cert);
245 void NotifyObserversOfCertRemoved(const X509Certificate* cert); 257 void NotifyObserversOfCertRemoved(const X509Certificate* cert);
246 void NotifyObserversOfCACertChanged(const X509Certificate* cert); 258 void NotifyObserversOfCACertChanged(const X509Certificate* cert);
247 259
248 // Task runner that should be used in tests if set. 260 // Task runner that should be used in tests if set.
249 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; 261 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_;
250 262
251 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; 263 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_;
252 264
253 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); 265 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase);
254 }; 266 };
255 267
256 } // namespace net 268 } // namespace net
257 269
258 #endif // NET_CERT_NSS_CERT_DATABASE_H_ 270 #endif // NET_CERT_NSS_CERT_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698