From efb8bc81fd2d43607bf50cfa4cc12317d1a4c986 Mon Sep 17 00:00:00 2001 From: "wtc@google.com" Date: Mon, 29 Sep 2008 17:42:29 +0000 Subject: Don't use cert_lock_ as a reentrant lock. RemoveCert is renamed RemoveCertInternal to stress the fact that it should be called with the lock held. Fix miscellaneous nits complained by cpplint. R=jcampan Review URL: http://codereview.chromium.org/5024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2677 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cert_store.cc | 26 ++++++++++++-------------- chrome/browser/cert_store.h | 3 ++- 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'chrome/browser') diff --git a/chrome/browser/cert_store.cc b/chrome/browser/cert_store.cc index 53d71fb..542b3d8 100644 --- a/chrome/browser/cert_store.cc +++ b/chrome/browser/cert_store.cc @@ -13,7 +13,7 @@ template struct MatchSecond { - MatchSecond(const T& t) : value(t) {} + explicit MatchSecond(const T& t) : value(t) {} template bool operator()(const Pair& p) const { @@ -40,9 +40,9 @@ CertStore* CertStore::GetSharedInstance() { CertStore::CertStore() : next_cert_id_(1) { // We watch for RenderProcess termination, as this is how we clear // certificates for now. - // TODO (jcampan): we should be listening to events such as resource cached/ - // removed from cache, and remove the cert when we know it - // is not used anymore. + // TODO(jcampan): we should be listening to events such as resource cached/ + // removed from cache, and remove the cert when we know it + // is not used anymore. // TODO(tc): This notification observer never gets removed because the // CertStore is never deleted. @@ -93,18 +93,16 @@ int CertStore::StoreCert(net::X509Certificate* cert, int process_id) { bool CertStore::RetrieveCert(int cert_id, scoped_refptr* cert) { - AutoLock autoLock(cert_lock_); + AutoLock autoLock(cert_lock_); - CertMap::iterator iter = id_to_cert_.find(cert_id); - if (iter == id_to_cert_.end()) - return false; - *cert = iter->second; - return true; + CertMap::iterator iter = id_to_cert_.find(cert_id); + if (iter == id_to_cert_.end()) + return false; + *cert = iter->second; + return true; } -void CertStore::RemoveCert(int cert_id) { - AutoLock autoLock(cert_lock_); - +void CertStore::RemoveCertInternal(int cert_id) { CertMap::iterator cert_iter = id_to_cert_.find(cert_id); DCHECK(cert_iter != id_to_cert_.end()); @@ -135,7 +133,7 @@ void CertStore::RemoveCertsForRenderProcesHost(int process_id) { if (cert_id_to_process_id_.count(cert_id) == 0) { // This cert is not referenced by any process, remove it from id_to_cert_ // and cert_to_id_. - RemoveCert(cert_id); + RemoveCertInternal(cert_id); } // Erase the current item but keep the iterator valid. diff --git a/chrome/browser/cert_store.h b/chrome/browser/cert_store.h index ecfab73..742151a 100644 --- a/chrome/browser/cert_store.h +++ b/chrome/browser/cert_store.h @@ -52,7 +52,8 @@ class CertStore : public NotificationObserver { ~CertStore(); // Remove the specified cert from id_to_cert_ and cert_to_id_. - void RemoveCert(int cert_id); + // NOTE: the caller (RemoveCertsForRenderProcesHost) must hold cert_lock_. + void RemoveCertInternal(int cert_id); // Removes all the certs associated with the specified process from the store. void RemoveCertsForRenderProcesHost(int render_process_host_id); -- cgit v1.1