diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 17:31:55 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 17:31:55 +0000 |
commit | 06b43c8f5218332dd527a7611ca952eb16cdbe1d (patch) | |
tree | e450979fdae8971d6ffe6d4849694bd98603f9b3 | |
parent | 8ecca49c92e69c2061bca6ab28e56d246ca60390 (diff) | |
download | chromium_src-06b43c8f5218332dd527a7611ca952eb16cdbe1d.zip chromium_src-06b43c8f5218332dd527a7611ca952eb16cdbe1d.tar.gz chromium_src-06b43c8f5218332dd527a7611ca952eb16cdbe1d.tar.bz2 |
Clean up uses of static data around singletons.
This is in preparation for destroying singletons between each test.
BUG=110594
TEST=Test suites.
Review URL: http://codereview.chromium.org/9255020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118320 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/profiles/profile_dependency_manager.cc | 67 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_dependency_manager.h | 9 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc | 1 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host_unittest.cc | 10 | ||||
-rw-r--r-- | net/ocsp/nss_ocsp.cc | 9 | ||||
-rw-r--r-- | ui/base/win/window_impl.cc | 7 |
6 files changed, 57 insertions, 46 deletions
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc index f3c13c2..74f00ce 100644 --- a/chrome/browser/profiles/profile_dependency_manager.cc +++ b/chrome/browser/profiles/profile_dependency_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,39 +25,6 @@ class Profile; -namespace { - -bool g_initialized = false; - -// This method gets the instance of each ServiceFactory. We do this so that -// each ServiceFactory initializes iteslf and registers its dependencies with -// the global PreferenceDependencyManager. We need to have a complete -// dependency graph when we create a profile so we can dispatch the profile -// creation message to the services that want to create their services at -// profile creation time. -// -// TODO(erg): This needs to be something else. I don't think putting every -// FooServiceFactory here will scale or is desireable long term. -void AssertFactoriesBuilt() { - if (!g_initialized) { - BackgroundContentsServiceFactory::GetInstance(); - CloudPrintProxyServiceFactory::GetInstance(); - CookieSettings::Factory::GetInstance(); - NetworkActionPredictorFactory::GetInstance(); - PersonalDataManagerFactory::GetInstance(); - PluginPrefsFactory::GetInstance(); - prerender::PrerenderManagerFactory::GetInstance(); - SessionServiceFactory::GetInstance(); - SpeechInputExtensionManager::InitializeFactory(); - TabRestoreServiceFactory::GetInstance(); - TemplateURLServiceFactory::GetInstance(); - - g_initialized = true; - } -} - -} // namespace - void ProfileDependencyManager::AddComponent( ProfileKeyedServiceFactory* component) { all_components_.push_back(component); @@ -160,10 +127,40 @@ ProfileDependencyManager* ProfileDependencyManager::GetInstance() { return Singleton<ProfileDependencyManager>::get(); } -ProfileDependencyManager::ProfileDependencyManager() {} +ProfileDependencyManager::ProfileDependencyManager() + : built_factories_(false) { +} ProfileDependencyManager::~ProfileDependencyManager() {} +// This method gets the instance of each ServiceFactory. We do this so that +// each ServiceFactory initializes iteslf and registers its dependencies with +// the global PreferenceDependencyManager. We need to have a complete +// dependency graph when we create a profile so we can dispatch the profile +// creation message to the services that want to create their services at +// profile creation time. +// +// TODO(erg): This needs to be something else. I don't think putting every +// FooServiceFactory here will scale or is desireable long term. +void ProfileDependencyManager::AssertFactoriesBuilt() { + if (built_factories_) + return; + + BackgroundContentsServiceFactory::GetInstance(); + CloudPrintProxyServiceFactory::GetInstance(); + CookieSettings::Factory::GetInstance(); + NetworkActionPredictorFactory::GetInstance(); + PersonalDataManagerFactory::GetInstance(); + PluginPrefsFactory::GetInstance(); + prerender::PrerenderManagerFactory::GetInstance(); + SessionServiceFactory::GetInstance(); + SpeechInputExtensionManager::InitializeFactory(); + TabRestoreServiceFactory::GetInstance(); + TemplateURLServiceFactory::GetInstance(); + + built_factories_ = true; +} + void ProfileDependencyManager::BuildDestructionOrder() { // Step 1: Build a set of nodes with no incoming edges. std::deque<ProfileKeyedServiceFactory*> queue; diff --git a/chrome/browser/profiles/profile_dependency_manager.h b/chrome/browser/profiles/profile_dependency_manager.h index 6dc5c9f..b0b3ec9 100644 --- a/chrome/browser/profiles/profile_dependency_manager.h +++ b/chrome/browser/profiles/profile_dependency_manager.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -69,6 +69,10 @@ class ProfileDependencyManager { ProfileDependencyManager(); virtual ~ProfileDependencyManager(); + // Ensures that all the factories have been created before building the + // dependency graph. + void AssertFactoriesBuilt(); + // Using the dependency graph defined in |edges_|, fills |destruction_order_| // so that Observe() can notify each ProfileKeyedServiceFactory in order. void BuildDestructionOrder(); @@ -79,6 +83,9 @@ class ProfileDependencyManager { std::vector<ProfileKeyedServiceFactory*> destruction_order_; + // Whether AssertFactoriesBuilt has been done. + bool built_factories_; + #ifndef NDEBUG // A list of profile objects that have gone through the Shutdown() // phase. These pointers are most likely invalid, but we keep track of their diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc index cbc3aa8..fac745d 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc @@ -89,6 +89,7 @@ class SafeBrowsingBlockingPageTest : public ChromeRenderViewHostTestHarness { virtual void SetUp() { ChromeRenderViewHostTestHarness::SetUp(); SafeBrowsingBlockingPage::RegisterFactory(&factory_); + MalwareDetails::RegisterFactory(NULL); // Create it fresh each time. ResetUserResponse(); } diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index 771db38..8867bad 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -408,12 +408,10 @@ class ResourceDispatcherHostTest : public testing::Test, void CompleteStartRequest(int request_id); void EnsureTestSchemeIsAllowed() { - static bool have_white_listed_test_scheme = false; - - if (!have_white_listed_test_scheme) { - ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme("test"); - have_white_listed_test_scheme = true; - } + ChildProcessSecurityPolicy* policy = + ChildProcessSecurityPolicy::GetInstance(); + if (!policy->IsWebSafeScheme("test")) + policy->RegisterWebSafeScheme("test"); } // Sets a particular response for any request from now on. To switch back to diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc index 6c272e2..868f5cd 100644 --- a/net/ocsp/nss_ocsp.cc +++ b/net/ocsp/nss_ocsp.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -568,7 +568,12 @@ OCSPNSSInitialization::OCSPNSSInitialization() { } } -OCSPNSSInitialization::~OCSPNSSInitialization() {} +OCSPNSSInitialization::~OCSPNSSInitialization() { + SECStatus status = CERT_RegisterAlternateOCSPAIAInfoCallBack(NULL, NULL); + if (status != SECSuccess) { + LOG(ERROR) << "Error unregistering OCSP: " << PR_GetError(); + } +} // OCSP Http Client functions. diff --git a/ui/base/win/window_impl.cc b/ui/base/win/window_impl.cc index 7c4a6cd..9422ff3 100644 --- a/ui/base/win/window_impl.cc +++ b/ui/base/win/window_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -50,7 +50,10 @@ class ClassRegistrar { ~ClassRegistrar() { for (RegisteredClasses::iterator i = registered_classes_.begin(); i != registered_classes_.end(); ++i) { - UnregisterClass(i->name.c_str(), NULL); + if (!UnregisterClass(i->name.c_str(), NULL)) { + LOG(ERROR) << "Failed to unregister class " << i->name.c_str() + << ". Error = " << GetLastError(); + } } } |