| OLD | NEW |
| 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 Loading... |
| 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 // Asynchronously get a list of certificates in the certificate database of |
| 114 // the given slot. Note that the callback may be run even after the database |
| 115 // is deleted. |
| 116 virtual void ListCertsInSlot(const ListCertsCallback& callback, |
| 117 PK11SlotInfo* slot); |
| 118 |
| 112 // Get the default slot for public key data. | 119 // Get the default slot for public key data. |
| 113 virtual crypto::ScopedPK11Slot GetPublicSlot() const; | 120 virtual crypto::ScopedPK11Slot GetPublicSlot() const; |
| 114 | 121 |
| 115 // Get the default slot for private key or mixed private/public key data. | 122 // Get the default slot for private key or mixed private/public key data. |
| 116 virtual crypto::ScopedPK11Slot GetPrivateSlot() const; | 123 virtual crypto::ScopedPK11Slot GetPrivateSlot() const; |
| 117 | 124 |
| 118 // Get the default module for public key data. | 125 // Get the default module for public key data. |
| 119 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. | 126 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. |
| 120 // DEPRECATED: use GetPublicSlot instead. | 127 // DEPRECATED: use GetPublicSlot instead. |
| 121 // TODO(mattm): remove usage of this method and remove it. | 128 // TODO(mattm): remove usage of this method and remove it. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 void RemoveObserver(Observer* observer); | 228 void RemoveObserver(Observer* observer); |
| 222 | 229 |
| 223 // Overrides task runner that's used for running slow tasks. | 230 // Overrides task runner that's used for running slow tasks. |
| 224 void SetSlowTaskRunnerForTest( | 231 void SetSlowTaskRunnerForTest( |
| 225 const scoped_refptr<base::TaskRunner>& task_runner); | 232 const scoped_refptr<base::TaskRunner>& task_runner); |
| 226 | 233 |
| 227 protected: | 234 protected: |
| 228 NSSCertDatabase(); | 235 NSSCertDatabase(); |
| 229 virtual ~NSSCertDatabase(); | 236 virtual ~NSSCertDatabase(); |
| 230 | 237 |
| 238 static void ListCertsInSlotImpl(crypto::ScopedPK11Slot slot, |
| 239 CertificateList* certs); |
| 240 |
| 231 // Certificate listing implementation used by |ListCerts| and |ListCertsSync|. | 241 // Certificate listing implementation used by |ListCerts| and |ListCertsSync|. |
| 232 // Static so it may safely be used on the worker thread. | 242 // Static so it may safely be used on the worker thread. |
| 233 static void ListCertsImpl(CertificateList* certs); | 243 static void ListCertsImpl(CertificateList* certs); |
| 234 | 244 |
| 235 // Gets task runner that should be used for slow tasks like certificate | 245 // Gets task runner that should be used for slow tasks like certificate |
| 236 // listing. Defaults to a base::WorkerPool runner, but may be overriden | 246 // listing. Defaults to a base::WorkerPool runner, but may be overriden |
| 237 // in tests (see SetSlowTaskRunnerForTest). | 247 // in tests (see SetSlowTaskRunnerForTest). |
| 238 scoped_refptr<base::TaskRunner> GetSlowTaskRunner() const; | 248 scoped_refptr<base::TaskRunner> GetSlowTaskRunner() const; |
| 239 | 249 |
| 240 private: | 250 private: |
| 241 friend struct base::DefaultLazyInstanceTraits<NSSCertDatabase>; | 251 friend struct base::DefaultLazyInstanceTraits<NSSCertDatabase>; |
| 242 | 252 |
| 243 // Broadcasts notifications to all registered observers. | 253 // Broadcasts notifications to all registered observers. |
| 244 void NotifyObserversOfCertAdded(const X509Certificate* cert); | 254 void NotifyObserversOfCertAdded(const X509Certificate* cert); |
| 245 void NotifyObserversOfCertRemoved(const X509Certificate* cert); | 255 void NotifyObserversOfCertRemoved(const X509Certificate* cert); |
| 246 void NotifyObserversOfCACertChanged(const X509Certificate* cert); | 256 void NotifyObserversOfCACertChanged(const X509Certificate* cert); |
| 247 | 257 |
| 248 // Task runner that should be used in tests if set. | 258 // Task runner that should be used in tests if set. |
| 249 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; | 259 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; |
| 250 | 260 |
| 251 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 261 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
| 252 | 262 |
| 253 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); | 263 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); |
| 254 }; | 264 }; |
| 255 | 265 |
| 256 } // namespace net | 266 } // namespace net |
| 257 | 267 |
| 258 #endif // NET_CERT_NSS_CERT_DATABASE_H_ | 268 #endif // NET_CERT_NSS_CERT_DATABASE_H_ |
| OLD | NEW |