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 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // If |slot| is NULL, obtains the certs of all slots, otherwise only of | 256 // If |slot| is NULL, obtains the certs of all slots, otherwise only of |
257 // |slot|. | 257 // |slot|. |
258 static void ListCertsImpl(crypto::ScopedPK11Slot slot, | 258 static void ListCertsImpl(crypto::ScopedPK11Slot slot, |
259 CertificateList* certs); | 259 CertificateList* certs); |
260 | 260 |
261 // Gets task runner that should be used for slow tasks like certificate | 261 // Gets task runner that should be used for slow tasks like certificate |
262 // listing. Defaults to a base::WorkerPool runner, but may be overriden | 262 // listing. Defaults to a base::WorkerPool runner, but may be overriden |
263 // in tests (see SetSlowTaskRunnerForTest). | 263 // in tests (see SetSlowTaskRunnerForTest). |
264 scoped_refptr<base::TaskRunner> GetSlowTaskRunner() const; | 264 scoped_refptr<base::TaskRunner> GetSlowTaskRunner() const; |
265 | 265 |
| 266 protected: |
| 267 // Broadcasts notifications to all registered observers. |
| 268 void NotifyObserversOfCertAdded(const X509Certificate* cert); |
| 269 void NotifyObserversOfCertRemoved(const X509Certificate* cert); |
| 270 void NotifyObserversOfCACertChanged(const X509Certificate* cert); |
| 271 |
266 private: | 272 private: |
267 // Registers |observer| to receive notifications of certificate changes. The | 273 // Registers |observer| to receive notifications of certificate changes. The |
268 // thread on which this is called is the thread on which |observer| will be | 274 // thread on which this is called is the thread on which |observer| will be |
269 // called back with notifications. | 275 // called back with notifications. |
270 // NOTE: Observers registered here will only receive notifications generated | 276 // NOTE: Observers registered here will only receive notifications generated |
271 // directly through the NSSCertDatabase, but not those from the CertDatabase. | 277 // directly through the NSSCertDatabase, but not those from the CertDatabase. |
272 // CertDatabase observers will receive all certificate notifications. | 278 // CertDatabase observers will receive all certificate notifications. |
273 void AddObserver(Observer* observer); | 279 void AddObserver(Observer* observer); |
274 | 280 |
275 // Unregisters |observer| from receiving notifications. This must be called | 281 // Unregisters |observer| from receiving notifications. This must be called |
276 // on the same thread on which AddObserver() was called. | 282 // on the same thread on which AddObserver() was called. |
277 void RemoveObserver(Observer* observer); | 283 void RemoveObserver(Observer* observer); |
278 | 284 |
279 // Notifies observers of the removal of |cert| and calls |callback| with | 285 // Notifies observers of the removal of |cert| and calls |callback| with |
280 // |success| as argument. | 286 // |success| as argument. |
281 void NotifyCertRemovalAndCallBack(scoped_refptr<X509Certificate> cert, | 287 void NotifyCertRemovalAndCallBack(scoped_refptr<X509Certificate> cert, |
282 const DeleteCertCallback& callback, | 288 const DeleteCertCallback& callback, |
283 bool success); | 289 bool success); |
284 | 290 |
285 // Broadcasts notifications to all registered observers. | |
286 void NotifyObserversOfCertAdded(const X509Certificate* cert); | |
287 void NotifyObserversOfCertRemoved(const X509Certificate* cert); | |
288 void NotifyObserversOfCACertChanged(const X509Certificate* cert); | |
289 | |
290 // Certificate removal implementation used by |DeleteCertAndKey*|. Static so | 291 // Certificate removal implementation used by |DeleteCertAndKey*|. Static so |
291 // it may safely be used on the worker thread. | 292 // it may safely be used on the worker thread. |
292 static bool DeleteCertAndKeyImpl(scoped_refptr<X509Certificate> cert); | 293 static bool DeleteCertAndKeyImpl(scoped_refptr<X509Certificate> cert); |
293 | 294 |
294 crypto::ScopedPK11Slot public_slot_; | 295 crypto::ScopedPK11Slot public_slot_; |
295 crypto::ScopedPK11Slot private_slot_; | 296 crypto::ScopedPK11Slot private_slot_; |
296 | 297 |
297 // A helper observer that forwards events from this database to CertDatabase. | 298 // A helper observer that forwards events from this database to CertDatabase. |
298 scoped_ptr<Observer> cert_notification_forwarder_; | 299 scoped_ptr<Observer> cert_notification_forwarder_; |
299 | 300 |
300 // Task runner that should be used in tests if set. | 301 // Task runner that should be used in tests if set. |
301 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; | 302 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; |
302 | 303 |
303 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; | 304 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; |
304 | 305 |
305 base::WeakPtrFactory<NSSCertDatabase> weak_factory_; | 306 base::WeakPtrFactory<NSSCertDatabase> weak_factory_; |
306 | 307 |
307 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); | 308 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); |
308 }; | 309 }; |
309 | 310 |
310 } // namespace net | 311 } // namespace net |
311 | 312 |
312 #endif // NET_CERT_NSS_CERT_DATABASE_H_ | 313 #endif // NET_CERT_NSS_CERT_DATABASE_H_ |
OLD | NEW |