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
3 // found in the LICENSE file.
5 #include "net/cert/cert_database.h"
7 #include "base/memory/singleton.h"
8 #include "base/observer_list_threadsafe.h"
13 CertDatabase
* CertDatabase::GetInstance() {
14 // Leaky so it can be initialized on worker threads, and because there is no
15 // useful cleanup to do.
16 return base::Singleton
<CertDatabase
,
17 base::LeakySingletonTraits
<CertDatabase
>>::get();
20 void CertDatabase::AddObserver(Observer
* observer
) {
21 observer_list_
->AddObserver(observer
);
24 void CertDatabase::RemoveObserver(Observer
* observer
) {
25 observer_list_
->RemoveObserver(observer
);
28 void CertDatabase::NotifyObserversOfCertAdded(const X509Certificate
* cert
) {
29 observer_list_
->Notify(FROM_HERE
, &Observer::OnCertAdded
,
30 make_scoped_refptr(cert
));
33 void CertDatabase::NotifyObserversOfCertRemoved(const X509Certificate
* cert
) {
34 observer_list_
->Notify(FROM_HERE
, &Observer::OnCertRemoved
,
35 make_scoped_refptr(cert
));
38 void CertDatabase::NotifyObserversOfCACertChanged(
39 const X509Certificate
* cert
) {
40 observer_list_
->Notify(FROM_HERE
, &Observer::OnCACertChanged
,
41 make_scoped_refptr(cert
));