summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 23:51:22 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 23:51:22 +0000
commita2255c5a52ca788ff105b3cb31da68bb5d61c885 (patch)
tree8c07d35d7b18340f922259c63c27a7a665894b4b /chrome/browser
parent3ada41b2341303941e4f01b8986bee567bfde14d (diff)
downloadchromium_src-a2255c5a52ca788ff105b3cb31da68bb5d61c885.zip
chromium_src-a2255c5a52ca788ff105b3cb31da68bb5d61c885.tar.gz
chromium_src-a2255c5a52ca788ff105b3cb31da68bb5d61c885.tar.bz2
Fixes leak of CertStore on shutdown.
BUG=none TEST=none Review URL: http://codereview.chromium.org/18568 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_main.cc4
-rw-r--r--chrome/browser/cert_store.cc14
-rw-r--r--chrome/browser/cert_store.h8
3 files changed, 4 insertions, 22 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index b492380..4a7258a 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -61,7 +61,6 @@
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_trial.h"
-#include "chrome/browser/cert_store.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/extensions/extension_protocols.h"
#include "chrome/browser/first_run.h"
@@ -473,9 +472,6 @@ int BrowserMain(const MainFunctionParams& parameters) {
PluginService::GetInstance()->SetChromePluginDataDir(profile->GetPath());
#if defined(OS_WIN)
- // Initialize the CertStore.
- CertStore::Initialize();
-
// Prepare for memory caching of SDCH dictionaries.
SdchManager sdch_manager; // Construct singleton database.
sdch_manager.set_sdch_fetcher(new SdchDictionaryFetcher);
diff --git a/chrome/browser/cert_store.cc b/chrome/browser/cert_store.cc
index a2fdd7a..36c5257 100644
--- a/chrome/browser/cert_store.cc
+++ b/chrome/browser/cert_store.cc
@@ -23,19 +23,9 @@ struct MatchSecond {
T value;
};
-// static
-CertStore* CertStore::instance_ = NULL;
-
-// static
-void CertStore::Initialize() {
- DCHECK(!instance_);
- instance_ = new CertStore();
-}
-
// static
CertStore* CertStore::GetSharedInstance() {
- DCHECK(instance_);
- return instance_;
+ return Singleton<CertStore>::get();
}
CertStore::CertStore() : next_cert_id_(1) {
@@ -52,8 +42,6 @@ CertStore::CertStore() : next_cert_id_(1) {
}
CertStore::~CertStore() {
- NotificationService::current()->RemoveObserver(this,
- NOTIFY_RENDERER_PROCESS_TERMINATED, NotificationService::AllSources());
}
int CertStore::StoreCert(net::X509Certificate* cert, int process_id) {
diff --git a/chrome/browser/cert_store.h b/chrome/browser/cert_store.h
index 48b53ef..8c793b2 100644
--- a/chrome/browser/cert_store.h
+++ b/chrome/browser/cert_store.h
@@ -9,6 +9,7 @@
#include <map>
#include "base/lock.h"
+#include "base/singleton.h"
#include "chrome/common/notification_service.h"
#include "net/base/x509_certificate.h"
@@ -24,9 +25,6 @@
class CertStore : public NotificationObserver {
public:
- // Creates the singleton instance. Should be called from the UI thread.
- static void Initialize();
-
// Returns the singleton instance of the CertStore.
static CertStore* GetSharedInstance();
@@ -48,6 +46,8 @@ class CertStore : public NotificationObserver {
const NotificationDetails& details);
private:
+ friend struct DefaultSingletonTraits<CertStore>;
+
CertStore();
~CertStore();
@@ -58,8 +58,6 @@ class CertStore : public NotificationObserver {
// Removes all the certs associated with the specified process from the store.
void RemoveCertsForRenderProcesHost(int render_process_host_id);
- static CertStore* instance_;
-
typedef std::multimap<int, int> IDMap;
typedef std::map<int, scoped_refptr<net::X509Certificate> > CertMap;
typedef std::map<net::X509Certificate*, int, net::X509Certificate::LessThan>