diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 19:15:49 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 19:15:49 +0000 |
commit | 3b19e8e47928c83800a62ef76e38403593685637 (patch) | |
tree | a29e8241cbcc840bb12ab828b8014260423c6ab0 /chrome/test/base/testing_browser_process.cc | |
parent | 9388734eaca551954fe4eb077875cc9f8d0106e3 (diff) | |
download | chromium_src-3b19e8e47928c83800a62ef76e38403593685637.zip chromium_src-3b19e8e47928c83800a62ef76e38403593685637.tar.gz chromium_src-3b19e8e47928c83800a62ef76e38403593685637.tar.bz2 |
Cleanup shutdown of the policy code.
Moved ownership of the global PolicyService to the connector.
ManagedModePolicyProvider isn't a ProfileKeyedService for now, to simplify ownership.
Removed dead code (ProxyPolicyProvider, others).
Removed hacks around ownership issues (OnProviderGoingAway).
BUG=128999
Review URL: https://chromiumcodereview.appspot.com/10958075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/base/testing_browser_process.cc')
-rw-r--r-- | chrome/test/base/testing_browser_process.cc | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc index 91d8169..7b67dbc 100644 --- a/chrome/test/base/testing_browser_process.cc +++ b/chrome/test/base/testing_browser_process.cc @@ -6,8 +6,6 @@ #include "base/string_util.h" #include "chrome/browser/notifications/notification_ui_manager.h" -#include "chrome/browser/policy/browser_policy_connector.h" -#include "chrome/browser/policy/policy_service.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prerender/prerender_tracker.h" #include "chrome/browser/printing/background_printing_manager.h" @@ -19,7 +17,9 @@ #include "net/url_request/url_request_context_getter.h" #include "testing/gtest/include/gtest/gtest.h" -#if !defined(ENABLE_CONFIGURATION_POLICY) +#if defined(ENABLE_CONFIGURATION_POLICY) +#include "chrome/browser/policy/browser_policy_connector.h" +#else #include "chrome/browser/policy/policy_service_stub.h" #endif // defined(ENABLE_CONFIGURATION_POLICY) @@ -34,6 +34,10 @@ TestingBrowserProcess::TestingBrowserProcess() TestingBrowserProcess::~TestingBrowserProcess() { EXPECT_FALSE(local_state_); +#if defined(ENABLE_CONFIGURATION_POLICY) + if (browser_policy_connector_) + browser_policy_connector_->Shutdown(); +#endif } void TestingBrowserProcess::ResourceDispatcherHostCreated() { @@ -74,21 +78,22 @@ chrome_variations::VariationsService* policy::BrowserPolicyConnector* TestingBrowserProcess::browser_policy_connector() { #if defined(ENABLE_CONFIGURATION_POLICY) - if (!browser_policy_connector_.get()) + if (!browser_policy_connector_) browser_policy_connector_.reset(new policy::BrowserPolicyConnector()); -#endif return browser_policy_connector_.get(); +#else + return NULL; +#endif } policy::PolicyService* TestingBrowserProcess::policy_service() { - if (!policy_service_.get()) { #if defined(ENABLE_CONFIGURATION_POLICY) - policy_service_ = browser_policy_connector()->CreatePolicyService(NULL); + return browser_policy_connector()->GetPolicyService(); #else + if (!policy_service_) policy_service_.reset(new policy::PolicyServiceStub()); -#endif - } return policy_service_.get(); +#endif } IconManager* TestingBrowserProcess::icon_manager() { @@ -253,7 +258,9 @@ void TestingBrowserProcess::SetLocalState(PrefService* local_state) { // any components owned by TestingBrowserProcess that depend on local_state // are also freed. notification_ui_manager_.reset(); - browser_policy_connector_.reset(); +#if defined(ENABLE_CONFIGURATION_POLICY) + SetBrowserPolicyConnector(NULL); +#endif } local_state_ = local_state; } @@ -264,7 +271,13 @@ void TestingBrowserProcess::SetIOThread(IOThread* io_thread) { void TestingBrowserProcess::SetBrowserPolicyConnector( policy::BrowserPolicyConnector* connector) { +#if defined(ENABLE_CONFIGURATION_POLICY) + if (browser_policy_connector_) + browser_policy_connector_->Shutdown(); browser_policy_connector_.reset(connector); +#else + CHECK(false); +#endif } void TestingBrowserProcess::SetSafeBrowsingService( |