summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_resource
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 21:43:17 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 21:43:17 +0000
commitb39e7a88bd6d2cbe16754ebca13af1a0ca837fb1 (patch)
treebbb01564db7c3a79032fdb8dec716c7496c9c9e2 /chrome/browser/web_resource
parent52da2379abbfa18dbc333bb275b7377ad8dce551 (diff)
downloadchromium_src-b39e7a88bd6d2cbe16754ebca13af1a0ca837fb1.zip
chromium_src-b39e7a88bd6d2cbe16754ebca13af1a0ca837fb1.tar.gz
chromium_src-b39e7a88bd6d2cbe16754ebca13af1a0ca837fb1.tar.bz2
Revert 117078 - Move creation and ownership of ResourceDispatcherHost and PluginService to content. This gives a few benefits:
-avoid having each embedder know when to create/destruct these objects, as well as contained objects (i.e. those related to downloads) -avoid having to tell embedders about specifics of BrowserThread startup/shutdown -move ResourceDispatcherHost's getter to content where it belongs Some code (extensions+promos) used the fact that RDH is NULL in unittests as a signal to not use the utility process. I've switches those unittests to set a flag on the objects instead. I've taken out the DnsParallelism field trial (not used anymore, confirmed with jar) as it was the only thing that caused MetricsService to depend on IOThread initialization, which also depended on MetricsService (through FieldTrials). This two-sided dependency always annoyed me and made the code hard to restructure. BUG=98716 Review URL: http://codereview.chromium.org/9150016 TBR=jam@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_resource')
-rw-r--r--chrome/browser/web_resource/promo_resource_service_unittest.cc1
-rw-r--r--chrome/browser/web_resource/web_resource_service.cc19
-rw-r--r--chrome/browser/web_resource/web_resource_service.h7
3 files changed, 11 insertions, 16 deletions
diff --git a/chrome/browser/web_resource/promo_resource_service_unittest.cc b/chrome/browser/web_resource/promo_resource_service_unittest.cc
index c1ba3e1..149a592 100644
--- a/chrome/browser/web_resource/promo_resource_service_unittest.cc
+++ b/chrome/browser/web_resource/promo_resource_service_unittest.cc
@@ -29,7 +29,6 @@ class PromoResourceServiceTest : public testing::Test {
PromoResourceServiceTest()
: local_state_(static_cast<TestingBrowserProcess*>(g_browser_process)),
web_resource_service_(new PromoResourceService(&profile_)) {
- web_resource_service_->set_use_utility_process_for_testing(false);
}
protected:
diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc
index 7688c19..403836f 100644
--- a/chrome/browser/web_resource/web_resource_service.cc
+++ b/chrome/browser/web_resource/web_resource_service.cc
@@ -30,18 +30,21 @@ using content::BrowserThread;
// the WebResourceService.
class WebResourceService::UnpackerClient : public UtilityProcessHost::Client {
public:
- UnpackerClient(WebResourceService* web_resource_service,
- bool use_utility_process)
+ explicit UnpackerClient(WebResourceService* web_resource_service)
: web_resource_service_(web_resource_service),
- use_utility_process_(use_utility_process),
+ resource_dispatcher_host_(g_browser_process->resource_dispatcher_host()),
got_response_(false) {
}
void Start(const std::string& json_data) {
AddRef(); // balanced in Cleanup.
+ // TODO(willchan): Look for a better signal of whether we're in a unit test
+ // or not. Using |resource_dispatcher_host_| for this is pretty lame.
+ // If we don't have a resource_dispatcher_host_, assume we're in
+ // a test and run the unpacker directly in-process.
bool use_utility_process =
- use_utility_process_ &&
+ resource_dispatcher_host_ != NULL &&
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
if (use_utility_process) {
BrowserThread::ID thread_id;
@@ -115,7 +118,8 @@ class WebResourceService::UnpackerClient : public UtilityProcessHost::Client {
scoped_refptr<WebResourceService> web_resource_service_;
- bool use_utility_process_;
+ // Owned by the global browser process.
+ ResourceDispatcherHost* resource_dispatcher_host_;
// True if we got a response from the utility process and have cleaned up
// already.
@@ -136,8 +140,7 @@ WebResourceService::WebResourceService(
apply_locale_to_url_(apply_locale_to_url),
last_update_time_pref_name_(last_update_time_pref_name),
start_fetch_delay_ms_(start_fetch_delay_ms),
- cache_update_delay_ms_(cache_update_delay_ms),
- use_utility_process_(true) {
+ cache_update_delay_ms_(cache_update_delay_ms) {
DCHECK(prefs);
}
@@ -228,7 +231,7 @@ void WebResourceService::OnURLFetchComplete(const content::URLFetcher* source) {
source->GetResponseAsString(&data);
// UnpackerClient releases itself.
- UnpackerClient* client = new UnpackerClient(this, use_utility_process_);
+ UnpackerClient* client = new UnpackerClient(this);
client->Start(data);
Release();
diff --git a/chrome/browser/web_resource/web_resource_service.h b/chrome/browser/web_resource/web_resource_service.h
index 077cec5..2dc28d7 100644
--- a/chrome/browser/web_resource/web_resource_service.h
+++ b/chrome/browser/web_resource/web_resource_service.h
@@ -38,10 +38,6 @@ class WebResourceService
// Then begin updating resources.
void StartAfterDelay();
- void set_use_utility_process_for_testing(bool value) {
- use_utility_process_ = value;
- }
-
protected:
virtual ~WebResourceService();
@@ -93,9 +89,6 @@ class WebResourceService
// different for different builds of Chrome.
int cache_update_delay_ms_;
- // Used by unittests to skip the utility process.
- bool use_utility_process_;
-
DISALLOW_COPY_AND_ASSIGN(WebResourceService);
};