diff options
author | sfeuz@chromium.org <sfeuz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-17 11:57:30 +0000 |
---|---|---|
committer | sfeuz@chromium.org <sfeuz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-17 11:57:30 +0000 |
commit | 8ea5136892902c939a33f8c3aa05dfeb28284f0b (patch) | |
tree | f6de07f81472d7c8a14f9bfba1127fca0c220b71 /chrome | |
parent | e5006b96ad664c9650c3631b4e666147a9c87a91 (diff) | |
download | chromium_src-8ea5136892902c939a33f8c3aa05dfeb28284f0b.zip chromium_src-8ea5136892902c939a33f8c3aa05dfeb28284f0b.tar.gz chromium_src-8ea5136892902c939a33f8c3aa05dfeb28284f0b.tar.bz2 |
Use SystemRequestContext instead of RequestContext from Profile for UserCloudPolicy.
This is an effort towards removing dependencies of the ProfilePolicyConnector on Profile.
BUG=none
TEST=Verify that policies are still fetched correctly.
Review URL: http://codereview.chromium.org/6933049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
9 files changed, 19 insertions, 38 deletions
diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc index 701fa04..830ef73 100644 --- a/chrome/browser/policy/browser_policy_connector.cc +++ b/chrome/browser/policy/browser_policy_connector.cc @@ -191,11 +191,8 @@ void BrowserPolicyConnector::FetchPolicy() { void BrowserPolicyConnector::Initialize() { // TODO(jkummerow, mnissler): Move this out of the browser startup path. - if (cloud_policy_subsystem_.get()) { - cloud_policy_subsystem_->Initialize( - g_browser_process->local_state(), - g_browser_process->system_request_context()); - } + if (cloud_policy_subsystem_.get()) + cloud_policy_subsystem_->Initialize(g_browser_process->local_state()); } } // namespace diff --git a/chrome/browser/policy/cloud_policy_subsystem.cc b/chrome/browser/policy/cloud_policy_subsystem.cc index 5ed979a..578dc5a 100644 --- a/chrome/browser/policy/cloud_policy_subsystem.cc +++ b/chrome/browser/policy/cloud_policy_subsystem.cc @@ -92,14 +92,12 @@ void CloudPolicySubsystem::OnIPAddressChanged() { } } -void CloudPolicySubsystem::Initialize( - PrefService* prefs, - net::URLRequestContextGetter* request_context) { +void CloudPolicySubsystem::Initialize(PrefService* prefs) { DCHECK(!prefs_); prefs_ = prefs; if (device_management_service_.get()) - device_management_service_->Initialize(request_context); + device_management_service_->Initialize(); policy_refresh_rate_.Init(prefs::kPolicyRefreshRate, prefs_, this); UpdatePolicyRefreshRate(); diff --git a/chrome/browser/policy/cloud_policy_subsystem.h b/chrome/browser/policy/cloud_policy_subsystem.h index f15142b..d7e7591 100644 --- a/chrome/browser/policy/cloud_policy_subsystem.h +++ b/chrome/browser/policy/cloud_policy_subsystem.h @@ -13,10 +13,6 @@ class PrefService; -namespace net { -class URLRequestContextGetter; -} - namespace policy { class CloudPolicyCacheBase; @@ -80,8 +76,7 @@ class CloudPolicySubsystem virtual void OnIPAddressChanged() OVERRIDE; // Initializes the subsystem. - void Initialize(PrefService* prefs, - net::URLRequestContextGetter* request_context); + void Initialize(PrefService* prefs); // Shuts the subsystem down. This must be called before threading and network // infrastructure goes away. diff --git a/chrome/browser/policy/device_management_service.cc b/chrome/browser/policy/device_management_service.cc index 698e3a3..ead93a2 100644 --- a/chrome/browser/policy/device_management_service.cc +++ b/chrome/browser/policy/device_management_service.cc @@ -4,6 +4,7 @@ #include "chrome/browser/policy/device_management_service.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/policy/device_management_backend_impl.h" @@ -116,11 +117,10 @@ DeviceManagementBackend* DeviceManagementService::CreateBackend() { return new DeviceManagementBackendImpl(this); } -void DeviceManagementService::Initialize( - net::URLRequestContextGetter* request_context_getter) { +void DeviceManagementService::Initialize() { DCHECK(!request_context_getter_); - request_context_getter_ = - new DeviceManagementRequestContextGetter(request_context_getter); + request_context_getter_ = new DeviceManagementRequestContextGetter( + g_browser_process->system_request_context()); while (!queued_jobs_.empty()) { StartJob(queued_jobs_.front()); queued_jobs_.pop_front(); diff --git a/chrome/browser/policy/device_management_service.h b/chrome/browser/policy/device_management_service.h index 1b8f006..d0515a3 100644 --- a/chrome/browser/policy/device_management_service.h +++ b/chrome/browser/policy/device_management_service.h @@ -57,9 +57,9 @@ class DeviceManagementService : public URLFetcher::Delegate { // Marked virtual for the benefit of tests. virtual DeviceManagementBackend* CreateBackend(); - // Provides the backend with a request context so it can make actual network - // requests. This will also fire any requests queued earlier. - void Initialize(net::URLRequestContextGetter* request_context_getter); + // Initializes the request context based on the system request context. + // This will also fire any requests queued earlier. + void Initialize(); // Makes the service stop all requests and drop the reference to the request // context. diff --git a/chrome/browser/policy/device_management_service_browsertest.cc b/chrome/browser/policy/device_management_service_browsertest.cc index 2a1ae15..a650d65 100644 --- a/chrome/browser/policy/device_management_service_browsertest.cc +++ b/chrome/browser/policy/device_management_service_browsertest.cc @@ -91,7 +91,7 @@ IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest, CannedResponses) { URLFetcher::enable_interception_for_tests(true); DeviceManagementService service(kServiceUrl); - service.Initialize(browser()->profile()->GetRequestContext()); + service.Initialize(); scoped_ptr<DeviceManagementBackend> backend(service.CreateBackend()); { @@ -144,7 +144,7 @@ IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest, ASSERT_TRUE(test_server_.Start()); DeviceManagementService service( test_server_.GetURL("device_management").spec()); - service.Initialize(browser()->profile()->GetRequestContext()); + service.Initialize(); scoped_ptr<DeviceManagementBackend> backend(service.CreateBackend()); { diff --git a/chrome/browser/policy/device_management_service_unittest.cc b/chrome/browser/policy/device_management_service_unittest.cc index 576900d..47da0d4 100644 --- a/chrome/browser/policy/device_management_service_unittest.cc +++ b/chrome/browser/policy/device_management_service_unittest.cc @@ -11,7 +11,6 @@ #include "chrome/browser/policy/device_management_service.h" #include "chrome/browser/policy/proto/device_management_constants.h" #include "chrome/common/net/test_url_fetcher_factory.h" -#include "chrome/test/test_url_request_context_getter.h" #include "content/browser/browser_thread.h" #include "net/base/escape.h" #include "net/url_request/url_request_status.h" @@ -44,10 +43,9 @@ template<typename TESTBASE> class DeviceManagementServiceTestBase : public TESTBASE { protected: DeviceManagementServiceTestBase() - : request_context_(new TestURLRequestContextGetter()), - io_thread_(BrowserThread::IO, &loop_) { + : io_thread_(BrowserThread::IO, &loop_) { ResetService(); - service_->Initialize(request_context_.get()); + service_->Initialize(); } virtual void SetUp() { @@ -58,7 +56,6 @@ class DeviceManagementServiceTestBase : public TESTBASE { URLFetcher::set_factory(NULL); backend_.reset(); service_.reset(); - request_context_ = NULL; loop_.RunAllPending(); } @@ -69,7 +66,6 @@ class DeviceManagementServiceTestBase : public TESTBASE { } TestURLFetcherFactory factory_; - scoped_refptr<TestURLRequestContextGetter> request_context_; scoped_ptr<DeviceManagementService> service_; scoped_ptr<DeviceManagementBackend> backend_; @@ -418,7 +414,7 @@ TEST_F(DeviceManagementServiceTest, JobQueueing) { ASSERT_FALSE(fetcher); // Now initialize the service. That should start the job. - service_->Initialize(request_context_.get()); + service_->Initialize(); fetcher = factory_.GetFetcherByID(0); ASSERT_TRUE(fetcher); factory_.RemoveFetcherFromMap(0); diff --git a/chrome/browser/policy/profile_policy_connector.cc b/chrome/browser/policy/profile_policy_connector.cc index 5a83cb3..83cf233 100644 --- a/chrome/browser/policy/profile_policy_connector.cc +++ b/chrome/browser/policy/profile_policy_connector.cc @@ -17,7 +17,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" -#include "net/url_request/url_request_context_getter.h" namespace { @@ -64,10 +63,8 @@ ProfilePolicyConnector::~ProfilePolicyConnector() { void ProfilePolicyConnector::Initialize() { // TODO(jkummerow, mnissler): Move this out of the browser startup path. - if (cloud_policy_subsystem_.get()) { - cloud_policy_subsystem_->Initialize(profile_->GetPrefs(), - profile_->GetRequestContext()); - } + if (cloud_policy_subsystem_.get()) + cloud_policy_subsystem_->Initialize(profile_->GetPrefs()); } void ProfilePolicyConnector::Shutdown() { diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index c4d3f7a..44872b8 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -409,8 +409,6 @@ void ProfileImpl::DoFinalInit() { media_cache_path, media_cache_max_size, extensions_cookie_path, app_path); - // Initialize the ProfilePolicyConnector after |io_data_| since it requires - // the URLRequestContextGetter to be initialized. policy::ProfilePolicyConnector* policy_connector = policy::ProfilePolicyConnectorFactory::GetForProfile(this); policy_connector->Initialize(); |