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. 4 5 #include "net/cert/cert_database.h" 6 7 #include "base/memory/singleton.h" 8 #include "base/observer_list_threadsafe.h" 9 10 namespace net { 11 12 // static 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 Singleton<CertDatabase, LeakySingletonTraits<CertDatabase> >::get(); 17 } 18 19 void CertDatabase::AddObserver(Observer* observer) { 20 observer_list_->AddObserver(observer); 21 } 22 23 void CertDatabase::RemoveObserver(Observer* observer) { 24 observer_list_->RemoveObserver(observer); 25 } 26 27 void CertDatabase::NotifyObserversOfCertAdded(const X509Certificate* cert) { 28 observer_list_->Notify(&Observer::OnCertAdded, make_scoped_refptr(cert)); 29 } 30 31 void CertDatabase::NotifyObserversOfCertRemoved(const X509Certificate* cert) { 32 observer_list_->Notify(&Observer::OnCertRemoved, make_scoped_refptr(cert)); 33 } 34 35 void CertDatabase::NotifyObserversOfCACertChanged( 36 const X509Certificate* cert) { 37 observer_list_->Notify( 38 &Observer::OnCACertChanged, make_scoped_refptr(cert)); 39 } 40 41 } // namespace net 42