From b39e7a88bd6d2cbe16754ebca13af1a0ca837fb1 Mon Sep 17 00:00:00 2001 From: "jam@chromium.org" Date: Tue, 10 Jan 2012 21:43:17 +0000 Subject: 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 --- chrome/browser/download/download_browsertest.cc | 8 +++++--- chrome/browser/download/download_extension_api.cc | 3 ++- chrome/browser/download/download_manager_unittest.cc | 4 ++-- chrome/browser/download/download_service.cc | 4 ++-- chrome/browser/download/download_throttling_resource_handler.cc | 1 + 5 files changed, 12 insertions(+), 8 deletions(-) (limited to 'chrome/browser/download') diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index 22ffa5c..b0828e1 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -97,7 +97,9 @@ class CancelTestDataCollector : public base::RefCountedThreadSafe { public: CancelTestDataCollector() - : slow_download_job_pending_requests_(0), + : resource_dispatcher_host_( + g_browser_process->resource_dispatcher_host()), + slow_download_job_pending_requests_(0), dfm_pending_downloads_(0) { } void WaitForDataCollected() { @@ -122,8 +124,7 @@ class CancelTestDataCollector private: void IOInfoCollector() { - download_file_manager_ = - ResourceDispatcherHost::Get()->download_file_manager(); + download_file_manager_ = resource_dispatcher_host_->download_file_manager(); slow_download_job_pending_requests_ = URLRequestSlowDownloadJob::NumberOutstandingRequests(); BrowserThread::PostTask( @@ -137,6 +138,7 @@ class CancelTestDataCollector BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); } + ResourceDispatcherHost* resource_dispatcher_host_; DownloadFileManager* download_file_manager_; int slow_download_job_pending_requests_; int dfm_pending_downloads_; diff --git a/chrome/browser/download/download_extension_api.cc b/chrome/browser/download/download_extension_api.cc index 3a38259..7f9effc 100644 --- a/chrome/browser/download/download_extension_api.cc +++ b/chrome/browser/download/download_extension_api.cc @@ -33,6 +33,7 @@ #include "chrome/browser/renderer_host/chrome_render_message_filter.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/webui/web_ui_util.h" +#include "content/browser/download/download_file_manager.h" #include "content/browser/download/download_id.h" #include "content/browser/download/download_state_info.h" #include "content/browser/download/download_types.h" @@ -232,7 +233,7 @@ bool DownloadsDownloadFunction::ParseArgs() { } } } - iodata_->rdh = ResourceDispatcherHost::Get(); + iodata_->rdh = g_browser_process->resource_dispatcher_host(); iodata_->resource_context = &profile()->GetResourceContext(); iodata_->render_process_host_id = render_view_host()->process()->GetID(); iodata_->render_view_host_routing_id = render_view_host()->routing_id(); diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc index 3f2c669..42e6a2c 100644 --- a/chrome/browser/download/download_manager_unittest.cc +++ b/chrome/browser/download/download_manager_unittest.cc @@ -29,13 +29,13 @@ #include "content/browser/download/download_file_impl.h" #include "content/browser/download/download_file_manager.h" #include "content/browser/download/download_id_factory.h" +#include "content/browser/download/download_manager_impl.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/download/interrupt_reasons.h" #include "content/browser/download/mock_download_file.h" #include "content/browser/download/mock_download_manager.h" #include "content/public/browser/download_item.h" -#include "content/public/browser/download_manager.h" #include "content/test/test_browser_thread.h" #include "grit/generated_resources.h" #include "net/base/io_buffer.h" @@ -167,7 +167,7 @@ class DownloadManagerTest : public testing::Test { download_manager_delegate_(new TestDownloadManagerDelegate( profile_.get())), id_factory_(new DownloadIdFactory(kValidIdDomain)), - download_manager_(DownloadManager::Create( + download_manager_(new DownloadManagerImpl( download_manager_delegate_, id_factory_, &download_status_updater_)), diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc index 98031ec..833949a 100644 --- a/chrome/browser/download/download_service.cc +++ b/chrome/browser/download/download_service.cc @@ -11,7 +11,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/browser/download/download_id_factory.h" -#include "content/public/browser/download_manager.h" +#include "content/browser/download/download_manager_impl.h" using content::DownloadManager; @@ -47,7 +47,7 @@ DownloadManager* DownloadService::GetDownloadManager() { // SetDownloadManagerDelegateForTesting. if (!manager_delegate_.get()) manager_delegate_ = new ChromeDownloadManagerDelegate(profile_); - manager_ = DownloadManager::Create( + manager_ = new DownloadManagerImpl( manager_delegate_.get(), id_factory_.get(), g_browser_process->download_status_updater()); diff --git a/chrome/browser/download/download_throttling_resource_handler.cc b/chrome/browser/download/download_throttling_resource_handler.cc index 98a9fb5..7f4ba73 100644 --- a/chrome/browser/download/download_throttling_resource_handler.cc +++ b/chrome/browser/download/download_throttling_resource_handler.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "content/browser/download/download_id.h" +#include "content/browser/download/download_resource_handler.h" #include "content/browser/download/download_stats.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" -- cgit v1.1