Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: chrome/test/base/testing_browser_process.cc

Issue 10693022: Add support for loading user cloud policy on desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaked some comments after self-review. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/testing_browser_process.cc
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 5251c93a76e4623841d8eecaf948fc208fe36cc5..da4fa8920b9098059edad486cd8290800d06c505 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -16,8 +16,8 @@
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "content/public/browser/notification_service.h"
#include "net/url_request/url_request_context_getter.h"
-#include "ui/base/clipboard/clipboard.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/clipboard/clipboard.h"
#if !defined(ENABLE_CONFIGURATION_POLICY)
#include "chrome/browser/policy/policy_service_stub.h"
@@ -73,8 +73,10 @@ chrome_variations::VariationsService*
policy::BrowserPolicyConnector*
TestingBrowserProcess::browser_policy_connector() {
#if defined(ENABLE_CONFIGURATION_POLICY)
- if (!browser_policy_connector_.get())
+ if (!browser_policy_connector_.get()) {
browser_policy_connector_.reset(new policy::BrowserPolicyConnector());
+ browser_policy_connector_->Init();
+ }
#endif
return browser_policy_connector_.get();
}
@@ -82,8 +84,7 @@ policy::BrowserPolicyConnector*
policy::PolicyService* TestingBrowserProcess::policy_service() {
if (!policy_service_.get()) {
#if defined(ENABLE_CONFIGURATION_POLICY)
- policy_service_.reset(
- browser_policy_connector()->CreatePolicyService(NULL));
+ policy_service_ = browser_policy_connector()->CreatePolicyService(NULL);
#else
policy_service_.reset(new policy::PolicyServiceStub());
#endif
@@ -249,8 +250,19 @@ CRLSetFetcher* TestingBrowserProcess::crl_set_fetcher() {
}
void TestingBrowserProcess::SetLocalState(PrefService* local_state) {
- if (!local_state && notification_ui_manager_.get())
- notification_ui_manager_.reset(); // Used local_state_.
+ if (!local_state) {
+ // The local_state_ PrefService is owned outside of TestingBrowserProcess,
+ // but some of the members of TestingBrowserProcess hold references to it
+ // (for example, via PrefNotifier members). But given our test
+ // infrastructure which tears down individual tests before freeing the
+ // TestingBrowserProcess, there's not a good way to make local_state outlive
+ // these dependencies. As a workaround, whenever local_state_ is cleared
+ // (assumedly as part of exiting the test and freeing TestingBrowserProcess)
+ // any components owned by TestingBrowserProcess that depend on local_state
+ // are also freed.
+ notification_ui_manager_.reset();
+ browser_policy_connector_.reset();
+ }
local_state_ = local_state;
}

Powered by Google App Engine
This is Rietveld 408576698