summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/DEPS1
-rw-r--r--chrome/browser/browser_process.h1
-rw-r--r--chrome/browser/browser_process_impl.cc12
-rw-r--r--chrome/browser/download/download_browsertest.cc2
-rw-r--r--chrome/browser/download/download_extension_api.cc15
-rw-r--r--chrome/browser/download/download_extension_api.h4
-rw-r--r--chrome/browser/extensions/crx_installer.cc4
-rw-r--r--chrome/browser/extensions/extension_updater.cc10
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.cc12
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.h11
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc2
-rw-r--r--chrome/browser/importer/external_process_importer_client.cc1
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc9
-rw-r--r--chrome/browser/plugin_installer.cc26
-rw-r--r--chrome/browser/prerender/prerender_field_trial.cc10
-rw-r--r--chrome/browser/prerender/prerender_manager.cc13
-rw-r--r--chrome/browser/prerender/prerender_manager.h7
-rw-r--r--chrome/browser/prerender/prerender_tracker.cc1
-rw-r--r--chrome/browser/profiles/profile_io_data.cc5
-rw-r--r--chrome/browser/renderer_host/chrome_render_message_filter.cc1
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc9
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h8
-rw-r--r--chrome/browser/renderer_host/transfer_navigation_resource_throttle.cc23
-rw-r--r--chrome/browser/renderer_host/transfer_navigation_resource_throttle.h2
-rw-r--r--chrome/browser/safe_browsing/client_side_detection_host.cc1
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc2
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc7
-rw-r--r--chrome/browser/ui/login/login_prompt.cc5
-rw-r--r--chrome/browser/ui/login/login_prompt_browsertest.cc9
-rw-r--r--chrome/browser/ui/login/login_prompt_gtk.cc1
-rw-r--r--chrome/browser/ui/login/login_prompt_mac.mm3
-rw-r--r--chrome/browser/ui/login/login_prompt_win.cc1
-rw-r--r--chrome/browser/web_resource/web_resource_service.cc14
-rw-r--r--content/browser/appcache/appcache_dispatcher_host.h3
-rw-r--r--content/browser/browser_main_loop.cc4
-rw-r--r--content/browser/browser_main_loop.h4
-rw-r--r--content/browser/download/download_file_manager.cc6
-rw-r--r--content/browser/download/download_file_manager.h7
-rw-r--r--content/browser/download/download_file_manager_unittest.cc3
-rw-r--r--content/browser/download/download_manager_impl.cc28
-rw-r--r--content/browser/download/download_manager_impl_unittest.cc3
-rw-r--r--content/browser/download/download_request_handle.cc53
-rw-r--r--content/browser/download/download_request_handle.h9
-rw-r--r--content/browser/download/download_resource_handler.cc18
-rw-r--r--content/browser/download/download_resource_handler.h5
-rw-r--r--content/browser/download/save_file_manager.cc27
-rw-r--r--content/browser/download/save_file_manager.h15
-rw-r--r--content/browser/download/save_package.cc5
-rw-r--r--content/browser/indexed_db/idbbindingutilities_browsertest.cc1
-rw-r--r--content/browser/renderer_host/async_resource_handler.cc17
-rw-r--r--content/browser/renderer_host/async_resource_handler.h14
-rw-r--r--content/browser/renderer_host/buffered_resource_handler.cc28
-rw-r--r--content/browser/renderer_host/buffered_resource_handler.h7
-rw-r--r--content/browser/renderer_host/cross_site_resource_handler.cc13
-rw-r--r--content/browser/renderer_host/cross_site_resource_handler.h17
-rw-r--r--content/browser/renderer_host/redirect_to_file_resource_handler.cc4
-rw-r--r--content/browser/renderer_host/redirect_to_file_resource_handler.h7
-rw-r--r--content/browser/renderer_host/render_message_filter.cc15
-rw-r--r--content/browser/renderer_host/render_message_filter.h5
-rw-r--r--content/browser/renderer_host/render_widget_helper.cc5
-rw-r--r--content/browser/renderer_host/render_widget_helper.h9
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_impl.cc (renamed from content/browser/renderer_host/resource_dispatcher_host.cc)801
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_impl.h (renamed from content/browser/renderer_host/resource_dispatcher_host.h)151
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_unittest.cc32
-rw-r--r--content/browser/renderer_host/resource_message_filter.cc9
-rw-r--r--content/browser/renderer_host/resource_request_details.cc4
-rw-r--r--content/browser/renderer_host/resource_request_info_impl.cc20
-rw-r--r--content/browser/renderer_host/resource_request_info_impl.h12
-rw-r--r--content/browser/renderer_host/sync_resource_handler.cc14
-rw-r--r--content/browser/renderer_host/sync_resource_handler.h16
-rw-r--r--content/browser/renderer_host/throttling_resource_handler.cc4
-rw-r--r--content/browser/renderer_host/throttling_resource_handler.h7
-rw-r--r--content/browser/renderer_host/x509_user_cert_resource_handler.cc9
-rw-r--r--content/browser/renderer_host/x509_user_cert_resource_handler.h6
-rw-r--r--content/browser/ssl/ssl_cert_error_handler.cc10
-rw-r--r--content/browser/ssl/ssl_cert_error_handler.h4
-rw-r--r--content/browser/ssl/ssl_client_auth_handler.cc11
-rw-r--r--content/browser/ssl/ssl_error_handler.cc14
-rw-r--r--content/browser/ssl/ssl_error_handler.h13
-rw-r--r--content/browser/ssl/ssl_manager.cc13
-rw-r--r--content/browser/ssl/ssl_manager.h6
-rw-r--r--content/browser/tab_contents/interstitial_page_impl.cc22
-rw-r--r--content/browser/tab_contents/tab_contents.cc5
-rw-r--r--content/content_browser.gypi5
-rw-r--r--content/public/browser/resource_dispatcher_host.h69
-rw-r--r--net/url_request/url_request.h9
86 files changed, 948 insertions, 882 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index fa2c830..99d6b1b 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -45,7 +45,6 @@ include_rules = [
"+content/browser/renderer_host/render_process_host_browsertest.h",
"+content/browser/renderer_host/render_view_host_factory.h",
"+content/browser/renderer_host/render_widget_host_view_mac_delegate.h",
- "+content/browser/renderer_host/resource_dispatcher_host.h",
"+content/browser/renderer_host/resource_request_details.h",
"+content/browser/renderer_host/resource_request_info_impl.h",
"+content/browser/renderer_host/test_render_view_host.h",
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index d5bb939..ecec003 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -35,7 +35,6 @@ class NotificationUIManager;
class PrefService;
class Profile;
class ProfileManager;
-class ResourceDispatcherHost;
class SafeBrowsingService;
class StatusTray;
class TabCloseableStateWatcher;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index aa430fe..0fb1a30 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -67,12 +67,12 @@
#include "chrome/common/switch_utils.h"
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_constants.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "net/socket/client_socket_pool_manager.h"
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/clipboard/clipboard.h"
@@ -112,6 +112,7 @@ static const int kEndSessionTimeoutSeconds = 10;
using content::BrowserThread;
using content::ChildProcessSecurityPolicy;
using content::PluginService;
+using content::ResourceDispatcherHost;
BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
: created_metrics_service_(false),
@@ -636,11 +637,10 @@ CRLSetFetcher* BrowserProcessImpl::crl_set_fetcher() {
}
void BrowserProcessImpl::ResourceDispatcherHostCreated() {
- ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
-
resource_dispatcher_host_delegate_.reset(
- new ChromeResourceDispatcherHostDelegate(rdh, prerender_tracker()));
- rdh->set_delegate(resource_dispatcher_host_delegate_.get());
+ new ChromeResourceDispatcherHostDelegate(prerender_tracker()));
+ ResourceDispatcherHost::Get()->SetDelegate(
+ resource_dispatcher_host_delegate_.get());
pref_change_registrar_.Add(prefs::kAllowCrossOriginAuthPrompt, this);
ApplyAllowCrossOriginAuthPromptPolicy();
@@ -841,7 +841,7 @@ void BrowserProcessImpl::ApplyDefaultBrowserPolicy() {
void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() {
bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt);
- ResourceDispatcherHost::Get()->set_allow_cross_origin_auth_prompt(value);
+ ResourceDispatcherHost::Get()->SetAllowCrossOriginAuthPrompt(value);
}
// Mac is currently not supported.
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index 8f6d762..448ef24 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -43,9 +43,9 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/browser/download/download_types.h"
#include "content/browser/net/url_request_mock_http_job.h"
#include "content/browser/net/url_request_slow_download_job.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/download_persistent_store_info.h"
diff --git a/chrome/browser/download/download_extension_api.cc b/chrome/browser/download/download_extension_api.cc
index 716220c..9ca6e5f 100644
--- a/chrome/browser/download/download_extension_api.cc
+++ b/chrome/browser/download/download_extension_api.cc
@@ -39,11 +39,11 @@
#include "chrome/browser/ui/webui/web_ui_util.h"
#include "content/browser/download/download_state_info.h"
#include "content/browser/download/download_types.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "net/base/load_flags.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
@@ -432,7 +432,7 @@ bool DownloadsDownloadFunction::ParseArgs() {
}
}
}
- iodata_->rdh = ResourceDispatcherHost::Get();
+ iodata_->rdh = content::ResourceDispatcherHost::Get();
iodata_->resource_context = profile()->GetResourceContext();
iodata_->render_process_host_id = render_view_host()->GetProcess()->GetID();
iodata_->render_view_host_routing_id = render_view_host()->GetRoutingID();
@@ -458,8 +458,7 @@ void DownloadsDownloadFunction::BeginDownloadOnIOThread() {
save_info.suggested_name = iodata_->filename;
save_info.prompt_for_save_location = iodata_->save_as;
- scoped_ptr<net::URLRequest> request(
- new net::URLRequest(iodata_->url, iodata_->rdh));
+ scoped_ptr<net::URLRequest> request(new net::URLRequest(iodata_->url, NULL));
request->set_method(iodata_->method);
if (iodata_->extra_headers != NULL) {
for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) {
@@ -495,12 +494,12 @@ void DownloadsDownloadFunction::BeginDownloadOnIOThread() {
net::Error error = iodata_->rdh->BeginDownload(
request.Pass(),
- false, // prefer_cache
- save_info,
- base::Bind(&DownloadsDownloadFunction::OnStarted, this),
+ iodata_->resource_context,
iodata_->render_process_host_id,
iodata_->render_view_host_routing_id,
- iodata_->resource_context);
+ false, // prefer_cache
+ save_info,
+ base::Bind(&DownloadsDownloadFunction::OnStarted, this));
iodata_.reset();
if (error != net::OK) {
diff --git a/chrome/browser/download/download_extension_api.h b/chrome/browser/download/download_extension_api.h
index 3da28e7..b024664 100644
--- a/chrome/browser/download/download_extension_api.h
+++ b/chrome/browser/download/download_extension_api.h
@@ -22,10 +22,10 @@
class DownloadFileIconExtractor;
class DownloadQuery;
-class ResourceDispatcherHost;
namespace content {
class ResourceContext;
+class ResourceDispatcherHost;
}
// Functions in the chrome.experimental.downloads namespace facilitate
@@ -135,7 +135,7 @@ class DownloadsDownloadFunction : public AsyncDownloadsFunction {
base::ListValue* extra_headers;
std::string method;
std::string post_body;
- ResourceDispatcherHost* rdh;
+ content::ResourceDispatcherHost* rdh;
content::ResourceContext* resource_context;
int render_process_host_id;
int render_view_host_routing_id;
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index 2f42cce..17f6e82 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -34,9 +34,9 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_file_util.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/user_metrics.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -172,7 +172,7 @@ void CrxInstaller::InstallCrx(const FilePath& source_file) {
scoped_refptr<SandboxedExtensionUnpacker> unpacker(
new SandboxedExtensionUnpacker(
source_file,
- ResourceDispatcherHost::Get(),
+ content::ResourceDispatcherHost::Get() != NULL,
install_source_,
creation_flags_,
this));
diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc
index 04f5c29..35605a5 100644
--- a/chrome/browser/extensions/extension_updater.cc
+++ b/chrome/browser/extensions/extension_updater.cc
@@ -36,9 +36,9 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/pref_names.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/common/url_fetcher.h"
#include "crypto/sha2.h"
@@ -638,20 +638,18 @@ class SafeManifestParser : public UtilityProcessHostClient {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(
- &SafeManifestParser::ParseInSandbox, this,
- ResourceDispatcherHost::Get()))) {
+ base::Bind(&SafeManifestParser::ParseInSandbox, this))) {
NOTREACHED();
}
}
// Creates the sandboxed utility process and tells it to start parsing.
- void ParseInSandbox(ResourceDispatcherHost* rdh) {
+ void ParseInSandbox() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// TODO(asargent) we shouldn't need to do this branch here - instead
// UtilityProcessHost should handle it for us. (http://crbug.com/19192)
- bool use_utility_process = rdh &&
+ bool use_utility_process = content::ResourceDispatcherHost::Get() &&
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
if (use_utility_process) {
UtilityProcessHost* host = UtilityProcessHost::Create(
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
index 8fa01ae..7f469f8 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
@@ -24,7 +24,6 @@
#include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_l10n_util.h"
#include "chrome/common/extensions/extension_unpacker.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h"
#include "crypto/signature_verifier.h"
@@ -165,14 +164,17 @@ bool FindWritableTempLocation(FilePath* temp_dir) {
SandboxedExtensionUnpacker::SandboxedExtensionUnpacker(
const FilePath& crx_path,
- ResourceDispatcherHost* rdh,
+ bool run_out_of_process,
Extension::Location location,
int creation_flags,
SandboxedExtensionUnpackerClient* client)
: crx_path_(crx_path),
thread_identifier_(BrowserThread::ID_COUNT),
- rdh_(rdh), client_(client), got_response_(false),
- location_(location), creation_flags_(creation_flags) {
+ run_out_of_process_(run_out_of_process),
+ client_(client),
+ got_response_(false),
+ location_(location),
+ creation_flags_(creation_flags) {
}
bool SandboxedExtensionUnpacker::CreateTempDirectory() {
@@ -241,7 +243,7 @@ void SandboxedExtensionUnpacker::Start() {
//
// TODO(asargent) we shouldn't need to do this branch here - instead
// UtilityProcessHost should handle it for us. (http://crbug.com/19192)
- bool use_utility_process = rdh_ &&
+ bool use_utility_process = run_out_of_process_ &&
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
if (use_utility_process) {
// The utility process will have access to the directory passed to
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.h b/chrome/browser/extensions/sandboxed_extension_unpacker.h
index 3461d45..696c4cd 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.h
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.h
@@ -16,7 +16,6 @@
#include "content/public/browser/utility_process_host_client.h"
class Extension;
-class ResourceDispatcherHost;
namespace base {
class DictionaryValue;
@@ -99,10 +98,10 @@ class SandboxedExtensionUnpacker : public content::UtilityProcessHostClient {
static const uint32 kCurrentVersion = 2;
// Unpacks the extension in |crx_path| into a temporary directory and calls
- // |client| with the result. If |rdh| is provided, unpacking is done in a
- // sandboxed subprocess. Otherwise, it is done in-process.
+ // |client| with the result. If |run_out_of_process| is provided, unpacking
+ // is done in a sandboxed subprocess. Otherwise, it is done in-process.
SandboxedExtensionUnpacker(const FilePath& crx_path,
- ResourceDispatcherHost* rdh,
+ bool run_out_of_process,
Extension::Location location,
int creation_flags,
SandboxedExtensionUnpackerClient* client);
@@ -221,8 +220,8 @@ class SandboxedExtensionUnpacker : public content::UtilityProcessHostClient {
// Our client's thread. This is the thread we respond on.
content::BrowserThread::ID thread_identifier_;
- // ResourceDispatcherHost to pass to the utility process.
- ResourceDispatcherHost* rdh_;
+ // True if unpacking should be done by the utility process.
+ bool run_out_of_process_;
// Our client.
scoped_refptr<SandboxedExtensionUnpackerClient> client_;
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
index 81e000a..776fead 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
@@ -101,7 +101,7 @@ class SandboxedExtensionUnpackerTest : public testing::Test {
ASSERT_TRUE(file_util::CreateDirectory(temp_path_));
sandboxed_unpacker_ =
- new SandboxedExtensionUnpacker(crx_path, NULL, Extension::INTERNAL,
+ new SandboxedExtensionUnpacker(crx_path, false, Extension::INTERNAL,
Extension::NO_FLAGS, client_);
// Hack since SandboxedExtensionUnpacker gets its background thread id from
diff --git a/chrome/browser/importer/external_process_importer_client.cc b/chrome/browser/importer/external_process_importer_client.cc
index 19f25bd..c2de9a8 100644
--- a/chrome/browser/importer/external_process_importer_client.cc
+++ b/chrome/browser/importer/external_process_importer_client.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/importer/profile_import_process_messages.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h"
#include "grit/generated_resources.h"
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index ea86b3d..d60517b 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/common/pref_names.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_request_info.h"
@@ -36,6 +35,7 @@
using content::BrowserThread;
using content::RenderViewHost;
+using content::ResourceRequestInfo;
namespace {
@@ -87,9 +87,12 @@ void NotifyEPMRequestStatus(RequestStatus status,
void ForwardRequestStatus(
RequestStatus status, net::URLRequest* request, void* profile_id) {
+ const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
+ if (!info)
+ return;
+
int process_id, render_view_id;
- if (ResourceDispatcherHost::RenderViewForRequest(
- request, &process_id, &render_view_id)) {
+ if (info->GetAssociatedRenderView(&process_id, &render_view_id)) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&NotifyEPMRequestStatus,
status, profile_id, process_id, render_view_id));
diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc
index 7466f6a..0379050 100644
--- a/chrome/browser/plugin_installer.cc
+++ b/chrome/browser/plugin_installer.cc
@@ -16,38 +16,40 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/browser/download/download_types.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_id.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/web_contents.h"
+#include "net/url_request/url_request.h"
using content::BrowserThread;
using content::DownloadItem;
+using content::ResourceDispatcherHost;
namespace {
-void BeginDownload(const GURL& url,
- content::ResourceContext* resource_context,
- int render_process_host_id,
- int render_view_host_routing_id,
- const DownloadResourceHandler::OnStartedCallback& callback) {
+void BeginDownload(
+ const GURL& url,
+ content::ResourceContext* resource_context,
+ int render_process_host_id,
+ int render_view_host_routing_id,
+ const ResourceDispatcherHost::DownloadStartedCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
- scoped_ptr<net::URLRequest> request(
- new net::URLRequest(url, rdh));
+ scoped_ptr<net::URLRequest> request(new net::URLRequest(url, NULL));
net::Error error = rdh->BeginDownload(
request.Pass(),
- true, // prefer_cache
- DownloadSaveInfo(),
- callback,
+ resource_context,
render_process_host_id,
render_view_host_routing_id,
- resource_context);
+ true, // prefer_cache
+ DownloadSaveInfo(),
+ callback);
if (error != net::OK) {
BrowserThread::PostTask(
diff --git a/chrome/browser/prerender/prerender_field_trial.cc b/chrome/browser/prerender/prerender_field_trial.cc
index 5b5f2b0..51cfd93 100644
--- a/chrome/browser/prerender/prerender_field_trial.cc
+++ b/chrome/browser/prerender/prerender_field_trial.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
namespace prerender {
@@ -37,8 +36,7 @@ void SetupPrefetchFieldTrial() {
"ContentPrefetchPrefetchOff", 2012, 6, 30));
const int kPrefetchOnGroup = trial->AppendGroup("ContentPrefetchPrefetchOn",
prefetch_probability);
- ResourceDispatcherHost::set_is_prefetch_enabled(
- trial->group() == kPrefetchOnGroup);
+ PrerenderManager::SetIsPrefetchEnabled(trial->group() == kPrefetchOnGroup);
}
void SetupPrerenderFieldTrial() {
@@ -161,15 +159,15 @@ void ConfigurePrefetchAndPrerender(const CommandLine& command_line) {
SetupPrerenderFieldTrial();
break;
case PRERENDER_OPTION_DISABLED:
- ResourceDispatcherHost::set_is_prefetch_enabled(false);
+ PrerenderManager::SetIsPrefetchEnabled(false);
PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_DISABLED);
break;
case PRERENDER_OPTION_ENABLED:
- ResourceDispatcherHost::set_is_prefetch_enabled(true);
+ PrerenderManager::SetIsPrefetchEnabled(true);
PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_ENABLED);
break;
case PRERENDER_OPTION_PREFETCH_ONLY:
- ResourceDispatcherHost::set_is_prefetch_enabled(true);
+ PrerenderManager::SetIsPrefetchEnabled(true);
PrerenderManager::SetMode(PrerenderManager::PRERENDER_MODE_DISABLED);
break;
default:
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index d10838c..fa9e6a4 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -162,6 +162,9 @@ class PrerenderManager::OnCloseTabContentsDeleter
};
// static
+bool PrerenderManager::is_prefetch_enabled_ = false;
+
+// static
int PrerenderManager::prerenders_per_session_count_ = 0;
// static
@@ -578,6 +581,16 @@ void PrerenderManager::set_enabled(bool enabled) {
}
// static
+bool PrerenderManager::IsPrefetchEnabled() {
+ return is_prefetch_enabled_;
+}
+
+// static
+void PrerenderManager::SetIsPrefetchEnabled(bool value) {
+ is_prefetch_enabled_ = value;
+}
+
+// static
PrerenderManager::PrerenderManagerMode PrerenderManager::GetMode() {
return mode_;
}
diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h
index 7a39614..3ba1d31 100644
--- a/chrome/browser/prerender/prerender_manager.h
+++ b/chrome/browser/prerender/prerender_manager.h
@@ -155,6 +155,11 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// they time out, but new ones will not be generated.
void set_enabled(bool enabled);
+ // Controls if we launch or squash prefetch requests as they arrive from
+ // renderers.
+ static bool IsPrefetchEnabled();
+ static void SetIsPrefetchEnabled(bool enabled);
+
static PrerenderManagerMode GetMode();
static void SetMode(PrerenderManagerMode mode);
static bool IsPrerenderingPossible();
@@ -396,6 +401,8 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// of the PrerenderManager.
bool enabled_;
+ static bool is_prefetch_enabled_;
+
// The profile that owns this PrerenderManager.
Profile* profile_;
diff --git a/chrome/browser/prerender/prerender_tracker.cc b/chrome/browser/prerender/prerender_tracker.cc
index 1eb0b0a..185e967 100644
--- a/chrome/browser/prerender/prerender_tracker.cc
+++ b/chrome/browser/prerender/prerender_tracker.cc
@@ -8,7 +8,6 @@
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/prerender/prerender_manager.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_context.h"
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 305a7f3..1e416a0 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -41,12 +41,12 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/resource_context.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "net/base/origin_bound_cert_service.h"
#include "net/http/http_transaction_factory.h"
#include "net/http/http_util.h"
@@ -66,6 +66,7 @@
using content::BrowserContext;
using content::BrowserThread;
using content::ResourceContext;
+using content::ResourceDispatcherHost;
using content::ResourceRequestInfoImpl;
namespace {
@@ -163,7 +164,7 @@ class ChromeBlobProtocolHandler : public webkit_blob::BlobProtocolHandler {
virtual scoped_refptr<webkit_blob::BlobData>
LookupBlobData(net::URLRequest* request) const {
const ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
+ ResourceRequestInfoImpl::ForRequest(request);
if (!info)
return NULL;
return info->requested_blob_data();
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index 1563b5e..582467a 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -30,7 +30,6 @@
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/process_type.h"
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
index 86eeee2..9322586 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
@@ -29,14 +29,15 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/render_messages.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_context.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_request_info.h"
#include "net/base/load_flags.h"
#include "net/base/ssl_config_service.h"
+#include "net/url_request/url_request.h"
// TODO(oshima): Enable this for other platforms.
#if defined(OS_CHROMEOS)
@@ -80,10 +81,8 @@ void NotifyDownloadInitiatedOnUI(int render_process_id, int render_view_id) {
} // end namespace
ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate(
- ResourceDispatcherHost* resource_dispatcher_host,
prerender::PrerenderTracker* prerender_tracker)
- : resource_dispatcher_host_(resource_dispatcher_host),
- download_request_limiter_(g_browser_process->download_request_limiter()),
+ : download_request_limiter_(g_browser_process->download_request_limiter()),
safe_browsing_(g_browser_process->safe_browsing_service()),
user_script_listener_(new UserScriptListener()),
prerender_tracker_(prerender_tracker) {
@@ -110,7 +109,7 @@ bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest(
return false;
// If prefetch is disabled, kill the request.
- if (!ResourceDispatcherHost::is_prefetch_enabled())
+ if (!prerender::PrerenderManager::IsPrefetchEnabled())
return false;
}
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h
index f6a7328..34ffb27 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h
@@ -14,7 +14,6 @@
class DelayedResourceQueue;
class DownloadRequestLimiter;
-class ResourceDispatcherHost;
class SafeBrowsingService;
class UserScriptListener;
@@ -29,10 +28,8 @@ class ChromeResourceDispatcherHostDelegate
public:
// This class does not take ownership of the tracker but merely holds a
// reference to it to avoid accessing g_browser_process.
- // Both |resource_dispatcher_host| and |prerender_tracker| must outlive
- // |this|.
- ChromeResourceDispatcherHostDelegate(
- ResourceDispatcherHost* resource_dispatcher_host,
+ // |prerender_tracker| must outlive |this|.
+ explicit ChromeResourceDispatcherHostDelegate(
prerender::PrerenderTracker* prerender_tracker);
virtual ~ChromeResourceDispatcherHostDelegate();
@@ -90,7 +87,6 @@ class ChromeResourceDispatcherHostDelegate
ResourceType::Type resource_type,
ScopedVector<content::ResourceThrottle>* throttles);
- ResourceDispatcherHost* resource_dispatcher_host_;
scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
scoped_refptr<SafeBrowsingService> safe_browsing_;
scoped_refptr<UserScriptListener> user_script_listener_;
diff --git a/chrome/browser/renderer_host/transfer_navigation_resource_throttle.cc b/chrome/browser/renderer_host/transfer_navigation_resource_throttle.cc
index d71ef19..c59a19f 100644
--- a/chrome/browser/renderer_host/transfer_navigation_resource_throttle.cc
+++ b/chrome/browser/renderer_host/transfer_navigation_resource_throttle.cc
@@ -8,14 +8,18 @@
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/common/extensions/extension_process_policy.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/public/browser/global_request_id.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_view_host_delegate.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/common/referrer.h"
+#include "net/url_request/url_request.h"
using content::GlobalRequestID;
+using content::Referrer;
using content::RenderViewHostDelegate;
+using content::ResourceDispatcherHost;
using content::ResourceRequestInfo;
namespace {
@@ -23,7 +27,7 @@ namespace {
void RequestTransferURLOnUIThread(int render_process_id,
int render_view_id,
const GURL& new_url,
- const content::Referrer& referrer,
+ const Referrer& referrer,
WindowOpenDisposition window_open_disposition,
int64 frame_id,
const GlobalRequestID& global_request_id) {
@@ -69,19 +73,20 @@ void TransferNavigationResourceThrottle::WillRedirectRequest(
ExtensionURLInfo(request_->url()), ExtensionURLInfo(new_url))) {
int render_process_id, render_view_id;
if (info->GetAssociatedRenderView(&render_process_id, &render_view_id)) {
- GlobalRequestID global_id(info->GetChildID(), info->GetRequestID());
- ResourceDispatcherHost::Get()->MarkAsTransferredNavigation(global_id,
- request_);
+ ResourceDispatcherHost::Get()->MarkAsTransferredNavigation(request_);
+ GlobalRequestID global_id(info->GetChildID(), info->GetRequestID());
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&RequestTransferURLOnUIThread,
- render_process_id, render_view_id,
+ render_process_id,
+ render_view_id,
new_url,
- content::Referrer(GURL(request_->referrer()),
- info->GetReferrerPolicy()),
- CURRENT_TAB, info->GetFrameID(), global_id));
+ Referrer(GURL(request_->referrer()), info->GetReferrerPolicy()),
+ CURRENT_TAB,
+ info->GetFrameID(),
+ global_id));
*defer = true;
}
diff --git a/chrome/browser/renderer_host/transfer_navigation_resource_throttle.h b/chrome/browser/renderer_host/transfer_navigation_resource_throttle.h
index 1ac6046..637314f 100644
--- a/chrome/browser/renderer_host/transfer_navigation_resource_throttle.h
+++ b/chrome/browser/renderer_host/transfer_navigation_resource_throttle.h
@@ -14,8 +14,6 @@ namespace net {
class URLRequest;
}
-class ResourceDispatcherHost;
-
// This ResourceThrottle checks whether a navigation redirect will cause a
// renderer process swap. When that happens, we remember the request so
// that we can transfer it to be handled by the new renderer. This fixes
diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc
index 0c69c6e..916ee72 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host.cc
@@ -21,7 +21,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/safe_browsing/csd.pb.h"
#include "chrome/common/safe_browsing/safebrowsing_messages.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_request_details.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
index 521ce1a..8f873ef9 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc
@@ -20,9 +20,9 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/test/test_browser_thread.h"
diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
index cf7b8a1..d738fe2 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
@@ -25,7 +25,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/test/test_browser_thread.h"
@@ -471,15 +470,15 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, Prefetch) {
class SetPrefetchForTest {
public:
explicit SetPrefetchForTest(bool prefetch)
- : old_prefetch_state_(ResourceDispatcherHost::is_prefetch_enabled()),
+ : old_prefetch_state_(prerender::PrerenderManager::IsPrefetchEnabled()),
old_prerender_mode_(prerender::PrerenderManager::GetMode()) {
- ResourceDispatcherHost::set_is_prefetch_enabled(prefetch);
+ prerender::PrerenderManager::SetIsPrefetchEnabled(prefetch);
prerender::PrerenderManager::SetMode(
prerender::PrerenderManager::PRERENDER_MODE_DISABLED);
}
~SetPrefetchForTest() {
- ResourceDispatcherHost::set_is_prefetch_enabled(old_prefetch_state_);
+ prerender::PrerenderManager::SetIsPrefetchEnabled(old_prefetch_state_);
prerender::PrerenderManager::SetMode(old_prerender_mode_);
}
private:
diff --git a/chrome/browser/ui/login/login_prompt.cc b/chrome/browser/ui/login/login_prompt.cc
index e30cfd4..c39d25d 100644
--- a/chrome/browser/ui/login/login_prompt.cc
+++ b/chrome/browser/ui/login/login_prompt.cc
@@ -15,12 +15,12 @@
#include "chrome/browser/ui/constrained_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_notification_types.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_view_host_delegate.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
@@ -36,6 +36,7 @@ using content::BrowserThread;
using content::NavigationController;
using content::RenderViewHost;
using content::RenderViewHostDelegate;
+using content::ResourceDispatcherHost;
using content::ResourceRequestInfo;
using content::WebContents;
using webkit::forms::PasswordForm;
@@ -46,7 +47,7 @@ class LoginHandlerImpl;
// Should only be called from the IO thread, since it accesses an
// net::URLRequest.
void ResetLoginHandlerForRequest(net::URLRequest* request) {
- ResourceDispatcherHost::ClearLoginDelegate(request);
+ ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request);
}
// Get the signon_realm under which this auth info should be stored.
diff --git a/chrome/browser/ui/login/login_prompt_browsertest.cc b/chrome/browser/ui/login/login_prompt_browsertest.cc
index 068794d..ff544aa 100644
--- a/chrome/browser/ui/login/login_prompt_browsertest.cc
+++ b/chrome/browser/ui/login/login_prompt_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,7 +14,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
@@ -225,16 +224,16 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, PrefetchAuthCancels) {
class SetPrefetchForTest {
public:
explicit SetPrefetchForTest(bool prefetch)
- : old_prefetch_state_(ResourceDispatcherHost::is_prefetch_enabled()),
+ : old_prefetch_state_(prerender::PrerenderManager::IsPrefetchEnabled()),
old_mode_(prerender::PrerenderManager::GetMode()) {
- ResourceDispatcherHost::set_is_prefetch_enabled(prefetch);
+ prerender::PrerenderManager::SetIsPrefetchEnabled(prefetch);
// Disable prerender so this is just a prefetch of the top-level page.
prerender::PrerenderManager::SetMode(
prerender::PrerenderManager::PRERENDER_MODE_DISABLED);
}
~SetPrefetchForTest() {
- ResourceDispatcherHost::set_is_prefetch_enabled(old_prefetch_state_);
+ prerender::PrerenderManager::SetIsPrefetchEnabled(old_prefetch_state_);
prerender::PrerenderManager::SetMode(old_mode_);
}
private:
diff --git a/chrome/browser/ui/login/login_prompt_gtk.cc b/chrome/browser/ui/login/login_prompt_gtk.cc
index 6ec0851..717c0a5 100644
--- a/chrome/browser/ui/login/login_prompt_gtk.cc
+++ b/chrome/browser/ui/login/login_prompt_gtk.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/ui/gtk/gtk_util.h"
#include "chrome/browser/ui/login/login_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
diff --git a/chrome/browser/ui/login/login_prompt_mac.mm b/chrome/browser/ui/login/login_prompt_mac.mm
index c0d5c0c..84ef4d7 100644
--- a/chrome/browser/ui/login/login_prompt_mac.mm
+++ b/chrome/browser/ui/login/login_prompt_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,7 +16,6 @@
#include "chrome/browser/ui/cocoa/constrained_window_mac.h"
#include "chrome/browser/ui/login/login_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
diff --git a/chrome/browser/ui/login/login_prompt_win.cc b/chrome/browser/ui/login/login_prompt_win.cc
index 8f0c451..f9e72d8 100644
--- a/chrome/browser/ui/login/login_prompt_win.cc
+++ b/chrome/browser/ui/login/login_prompt_win.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/views/constrained_window_views.h"
#include "chrome/browser/ui/views/login_view.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc
index aa5a45b..89f6496 100644
--- a/chrome/browser/web_resource/web_resource_service.cc
+++ b/chrome/browser/web_resource/web_resource_service.cc
@@ -17,8 +17,8 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/web_resource/web_resource_unpacker.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h"
#include "content/public/common/url_fetcher.h"
@@ -37,7 +37,6 @@ class WebResourceService::UnpackerClient : public UtilityProcessHostClient {
public:
explicit UnpackerClient(WebResourceService* web_resource_service)
: web_resource_service_(web_resource_service),
- resource_dispatcher_host_(ResourceDispatcherHost::Get()),
got_response_(false) {
}
@@ -45,11 +44,11 @@ class WebResourceService::UnpackerClient : public UtilityProcessHostClient {
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.
+ // or not. Using |ResourceDispatcherHost::Get()| for this is pretty lame.
+ // If we don't have a ResourceDispatcherHost, assume we're in a test and
+ // run the unpacker directly in-process.
bool use_utility_process =
- resource_dispatcher_host_ != NULL &&
+ content::ResourceDispatcherHost::Get() &&
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
if (use_utility_process) {
BrowserThread::ID thread_id;
@@ -123,9 +122,6 @@ class WebResourceService::UnpackerClient : public UtilityProcessHostClient {
scoped_refptr<WebResourceService> web_resource_service_;
- // 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.
bool got_response_;
diff --git a/content/browser/appcache/appcache_dispatcher_host.h b/content/browser/appcache/appcache_dispatcher_host.h
index 5e868fd..0ba101b 100644
--- a/content/browser/appcache/appcache_dispatcher_host.h
+++ b/content/browser/appcache/appcache_dispatcher_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,7 +12,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/process.h"
#include "content/browser/appcache/appcache_frontend_proxy.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/public/browser/browser_message_filter.h"
#include "webkit/appcache/appcache_backend_impl.h"
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 99daf44..15006c4 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -22,7 +22,7 @@
#include "content/browser/in_process_webkit/webkit_thread.h"
#include "content/browser/net/browser_online_state_observer.h"
#include "content/browser/plugin_service_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/trace_controller.h"
#include "content/common/hi_res_timer_manager.h"
#include "content/common/sandbox_policy.h"
@@ -592,7 +592,7 @@ void BrowserMainLoop::InitializeMainThread() {
void BrowserMainLoop::BrowserThreadsStarted() {
// RDH needs the IO thread to be created.
- resource_dispatcher_host_.reset(new ResourceDispatcherHost());
+ resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl());
#if defined(OS_LINUX)
// MediaDeviceNotificationsLinux needs the File Thread.
diff --git a/content/browser/browser_main_loop.h b/content/browser/browser_main_loop.h
index 7869709..eb34a0a 100644
--- a/content/browser/browser_main_loop.h
+++ b/content/browser/browser_main_loop.h
@@ -15,7 +15,6 @@ class BrowserOnlineStateObserver;
class CommandLine;
class HighResolutionTimerManager;
class MessageLoop;
-class ResourceDispatcherHost;
class SystemMessageWindowWin;
namespace base {
@@ -33,6 +32,7 @@ class BrowserShutdownImpl;
class BrowserThreadImpl;
struct MainFunctionParams;
class MediaDeviceNotificationsLinux;
+class ResourceDispatcherHostImpl;
class WebKitThread;
// Implements the main browser loop stages called from |BrowserMain()|.
@@ -104,7 +104,7 @@ class BrowserMainLoop {
scoped_ptr<BrowserThreadImpl> main_thread_;
// Members initialized in |BrowserThreadsStarted()| --------------------------
- scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
+ scoped_ptr<ResourceDispatcherHostImpl> resource_dispatcher_host_;
// Members initialized in |RunMainMessageLoopParts()| ------------------------
scoped_ptr<BrowserProcessSubThread> db_thread_;
diff --git a/content/browser/download/download_file_manager.cc b/content/browser/download/download_file_manager.cc
index 00126d0..3d608a4 100644
--- a/content/browser/download/download_file_manager.cc
+++ b/content/browser/download/download_file_manager.cc
@@ -19,7 +19,6 @@
#include "content/browser/download/download_interrupt_reasons_impl.h"
#include "content/browser/download/download_request_handle.h"
#include "content/browser/download/download_stats.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
@@ -65,9 +64,8 @@ DownloadFile* DownloadFileFactoryImpl::CreateFile(
} // namespace
-DownloadFileManager::DownloadFileManager(ResourceDispatcherHost* rdh,
- DownloadFileFactory* factory)
- : resource_dispatcher_host_(rdh), download_file_factory_(factory) {
+DownloadFileManager::DownloadFileManager(DownloadFileFactory* factory)
+ : download_file_factory_(factory) {
if (download_file_factory_ == NULL)
download_file_factory_.reset(new DownloadFileFactoryImpl);
}
diff --git a/content/browser/download/download_file_manager.h b/content/browser/download/download_file_manager.h
index c33033c..030e258 100644
--- a/content/browser/download/download_file_manager.h
+++ b/content/browser/download/download_file_manager.h
@@ -5,7 +5,7 @@
// The DownloadFileManager owns a set of DownloadFile objects, each of which
// represent one in progress download and performs the disk IO for that
// download. The DownloadFileManager itself is a singleton object owned by the
-// ResourceDispatcherHost.
+// ResourceDispatcherHostImpl.
//
// The DownloadFileManager uses the file_thread for performing file write
// operations, in order to avoid disk activity on either the IO (network) thread
@@ -58,7 +58,6 @@
struct DownloadCreateInfo;
class DownloadRequestHandle;
class FilePath;
-class ResourceDispatcherHost;
namespace content {
class DownloadBuffer;
@@ -89,8 +88,7 @@ class CONTENT_EXPORT DownloadFileManager
// Takes ownership of the factory.
// Passing in a NULL for |factory| will cause a default
// |DownloadFileFactory| to be used.
- DownloadFileManager(ResourceDispatcherHost* rdh,
- DownloadFileFactory* factory);
+ explicit DownloadFileManager(DownloadFileFactory* factory);
// Called on shutdown on the UI thread.
void Shutdown();
@@ -191,7 +189,6 @@ class CONTENT_EXPORT DownloadFileManager
// is controlled from the FILE thread, and posts updates to the UI thread.
base::RepeatingTimer<DownloadFileManager> update_timer_;
- ResourceDispatcherHost* resource_dispatcher_host_;
scoped_ptr<DownloadFileFactory> download_file_factory_;
DISALLOW_COPY_AND_ASSIGN(DownloadFileManager);
diff --git a/content/browser/download/download_file_manager_unittest.cc b/content/browser/download/download_file_manager_unittest.cc
index 6be93ea..15eab3a 100644
--- a/content/browser/download/download_file_manager_unittest.cc
+++ b/content/browser/download/download_file_manager_unittest.cc
@@ -139,8 +139,7 @@ class DownloadFileManagerTest : public testing::Test {
download_manager_ = new MockDownloadManager();
request_handle_.reset(new MockDownloadRequestHandle(download_manager_));
download_file_factory_ = new MockDownloadFileFactory;
- download_file_manager_ =
- new DownloadFileManager(NULL, download_file_factory_);
+ download_file_manager_ = new DownloadFileManager(download_file_factory_);
}
virtual void TearDown() {
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 1603f6a..16555c2 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -23,7 +23,7 @@
#include "content/browser/download/download_stats.h"
#include "content/browser/net/url_request_slow_download_job.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -51,6 +51,7 @@ using content::BrowserThread;
using content::DownloadId;
using content::DownloadItem;
using content::DownloadPersistentStoreInfo;
+using content::ResourceDispatcherHostImpl;
using content::WebContents;
namespace {
@@ -74,7 +75,7 @@ struct RenderParams {
void BeginDownload(const URLParams& url_params,
bool prefer_cache,
const DownloadSaveInfo& save_info,
- ResourceDispatcherHost* resource_dispatcher_host,
+ ResourceDispatcherHostImpl* resource_dispatcher_host,
const RenderParams& render_params,
content::ResourceContext* context) {
scoped_ptr<net::URLRequest> request(
@@ -92,11 +93,13 @@ void BeginDownload(const URLParams& url_params,
request->set_upload(upload_data);
}
resource_dispatcher_host->BeginDownload(
- request.Pass(), prefer_cache, save_info,
- DownloadResourceHandler::OnStartedCallback(),
+ request.Pass(),
+ context,
render_params.render_process_id_,
render_params.render_view_id_,
- context);
+ prefer_cache,
+ save_info,
+ ResourceDispatcherHostImpl::DownloadStartedCallback());
}
class MapValueIteratorAdapter {
@@ -140,7 +143,7 @@ void EnsureNoPendingDownloadsOnIO(bool* result) {
}
scoped_refptr<DownloadFileManager> download_file_manager =
- ResourceDispatcherHost::Get()->download_file_manager();
+ ResourceDispatcherHostImpl::Get()->download_file_manager();
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&EnsureNoPendingDownloadsOnFile,
@@ -319,10 +322,10 @@ bool DownloadManagerImpl::Init(content::BrowserContext* browser_context) {
browser_context_ = browser_context;
- // In test mode, there may be no ResourceDispatcherHost. In this case it's
- // safe to avoid setting |file_manager_| because we only call a small set of
- // functions, none of which need it.
- ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
+ // In test mode, there may be no ResourceDispatcherHostImpl. In this case
+ // it's safe to avoid setting |file_manager_| because we only call a small
+ // set of functions, none of which need it.
+ ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
if (rdh) {
file_manager_ = rdh->download_file_manager();
DCHECK(file_manager_);
@@ -864,8 +867,9 @@ void DownloadManagerImpl::DownloadUrl(
int64 post_id,
const DownloadSaveInfo& save_info,
WebContents* web_contents) {
- ResourceDispatcherHost* resource_dispatcher_host =
- ResourceDispatcherHost::Get();
+ ResourceDispatcherHostImpl* resource_dispatcher_host =
+ ResourceDispatcherHostImpl::Get();
+ DCHECK(resource_dispatcher_host);
// We send a pointer to content::ResourceContext, instead of the usual
// reference, so that a copy of the object isn't made.
diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc
index 8d113f0..eda8b9e 100644
--- a/content/browser/download/download_manager_impl_unittest.cc
+++ b/content/browser/download/download_manager_impl_unittest.cc
@@ -297,8 +297,7 @@ class DownloadManagerTest : public testing::Test {
DownloadFileManager* file_manager() {
if (!file_manager_) {
- file_manager_ = new DownloadFileManager(NULL,
- new MockDownloadFileFactory);
+ file_manager_ = new DownloadFileManager(new MockDownloadFileFactory);
download_manager_->SetFileManagerForTesting(file_manager_);
}
return file_manager_;
diff --git a/content/browser/download/download_request_handle.cc b/content/browser/download/download_request_handle.cc
index 6d2292e..861027b 100644
--- a/content/browser/download/download_request_handle.cc
+++ b/content/browser/download/download_request_handle.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/stringprintf.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -15,45 +15,45 @@
using content::BrowserThread;
using content::DownloadManager;
using content::RenderViewHostImpl;
+using content::ResourceDispatcherHostImpl;
// IO Thread indirections to resource dispatcher host.
// Provided as targets for PostTask from within this object
// only.
-static void ResourceDispatcherHostPauseRequest(
- ResourceDispatcherHost* rdh,
+static void DoPauseRequest(
int process_unique_id,
int request_id,
bool pause) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- rdh->PauseRequest(process_unique_id, request_id, pause);
+ ResourceDispatcherHostImpl::Get()->PauseRequest(process_unique_id,
+ request_id,
+ pause);
}
-static void ResourceDispatcherHostCancelRequest(
- ResourceDispatcherHost* rdh,
+static void DoCancelRequest(
int process_unique_id,
int request_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- rdh->CancelRequest(process_unique_id, request_id, false);
+ ResourceDispatcherHostImpl::Get()->CancelRequest(process_unique_id,
+ request_id,
+ false);
}
DownloadRequestHandle::DownloadRequestHandle()
- : rdh_(NULL),
- child_id_(-1),
+ : child_id_(-1),
render_view_id_(-1),
request_id_(-1) {
}
-DownloadRequestHandle::DownloadRequestHandle(ResourceDispatcherHost* rdh,
- int child_id,
+DownloadRequestHandle::DownloadRequestHandle(int child_id,
int render_view_id,
int request_id)
- : rdh_(rdh),
- child_id_(child_id),
+ : child_id_(child_id),
render_view_id_(render_view_id),
request_id_(request_id) {
- // ResourceDispatcherHost should not be null for non-default instances
- // of DownloadRequestHandle.
- DCHECK(rdh);
+ // ResourceDispatcherHostImpl should not be null for non-default instances of
+ // DownloadRequestHandle.
+ DCHECK(ResourceDispatcherHostImpl::Get());
}
TabContents* DownloadRequestHandle::GetTabContents() const {
@@ -81,35 +81,32 @@ DownloadManager* DownloadRequestHandle::GetDownloadManager() const {
}
void DownloadRequestHandle::PauseRequest() const {
- // The post is safe because ResourceDispatcherHost is guaranteed
+ // The post is safe because ResourceDispatcherHostImpl is guaranteed
// to outlive the IO thread.
- if (rdh_) {
+ if (ResourceDispatcherHostImpl::Get()) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&ResourceDispatcherHostPauseRequest,
- rdh_, child_id_, request_id_, true));
+ base::Bind(&DoPauseRequest, child_id_, request_id_, true));
}
}
void DownloadRequestHandle::ResumeRequest() const {
- // The post is safe because ResourceDispatcherHost is guaranteed
+ // The post is safe because ResourceDispatcherHostImpl is guaranteed
// to outlive the IO thread.
- if (rdh_) {
+ if (ResourceDispatcherHostImpl::Get()) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&ResourceDispatcherHostPauseRequest,
- rdh_, child_id_, request_id_, false));
+ base::Bind(&DoPauseRequest, child_id_, request_id_, false));
}
}
void DownloadRequestHandle::CancelRequest() const {
- // The post is safe because ResourceDispatcherHost is guaranteed
+ // The post is safe because ResourceDispatcherHostImpl is guaranteed
// to outlive the IO thread.
- if (rdh_) {
+ if (ResourceDispatcherHostImpl::Get()) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&ResourceDispatcherHostCancelRequest,
- rdh_, child_id_, request_id_));
+ base::Bind(&DoCancelRequest, child_id_, request_id_));
}
}
diff --git a/content/browser/download/download_request_handle.h b/content/browser/download/download_request_handle.h
index a81c2845..92e826d 100644
--- a/content/browser/download/download_request_handle.h
+++ b/content/browser/download/download_request_handle.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,7 +11,6 @@
#include "base/compiler_specific.h"
#include "content/common/content_export.h"
-class ResourceDispatcherHost;
class TabContents;
namespace content {
@@ -57,8 +56,7 @@ class CONTENT_EXPORT DownloadRequestHandle
DownloadRequestHandle();
// Note that |rdh| is required to be non-null.
- DownloadRequestHandle(ResourceDispatcherHost* rdh,
- int child_id,
+ DownloadRequestHandle(int child_id,
int render_view_id,
int request_id);
@@ -71,9 +69,6 @@ class CONTENT_EXPORT DownloadRequestHandle
virtual std::string DebugString() const OVERRIDE;
private:
- // The resource dispatcher host.
- ResourceDispatcherHost* rdh_;
-
// The ID of the child process that started the download.
int child_id_;
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index 44d3652..2118915 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -18,7 +18,7 @@
#include "content/browser/download/download_manager_impl.h"
#include "content/browser/download/download_request_handle.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_impl.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_interrupt_reasons.h"
@@ -34,10 +34,10 @@ using content::BrowserThread;
using content::DownloadId;
using content::DownloadItem;
using content::DownloadManager;
+using content::ResourceDispatcherHostImpl;
using content::ResourceRequestInfoImpl;
DownloadResourceHandler::DownloadResourceHandler(
- ResourceDispatcherHost* rdh,
int render_process_host_id,
int render_view_id,
int request_id,
@@ -55,7 +55,6 @@ DownloadResourceHandler::DownloadResourceHandler(
started_cb_(started_cb),
save_info_(save_info),
buffer_(new content::DownloadBuffer),
- rdh_(rdh),
is_paused_(false),
last_buffer_size_(0),
bytes_read_(0) {
@@ -95,7 +94,7 @@ bool DownloadResourceHandler::OnResponseStarted(
set_content_length(response->content_length);
const ResourceRequestInfoImpl* request_info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
// Deleted in DownloadManager.
scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo(
@@ -114,7 +113,7 @@ bool DownloadResourceHandler::OnResponseStarted(
info->remote_address = request_->GetSocketAddress().host();
download_stats::RecordDownloadMimeType(info->mime_type);
- DownloadRequestHandle request_handle(rdh_, global_id_.child_id,
+ DownloadRequestHandle request_handle(global_id_.child_id,
render_view_id_, global_id_.request_id);
// Get the last modified time and etag.
@@ -155,7 +154,9 @@ bool DownloadResourceHandler::OnResponseStarted(
// We can't start saving the data before we create the file on disk and have a
// download id. The request will be un-paused in
// DownloadFileManager::CreateDownloadFile.
- rdh_->PauseRequest(global_id_.child_id, global_id_.request_id, true);
+ ResourceDispatcherHostImpl::Get()->PauseRequest(global_id_.child_id,
+ global_id_.request_id,
+ true);
return true;
}
@@ -376,8 +377,9 @@ void DownloadResourceHandler::CheckWriteProgress() {
StartPauseTimer();
if (is_paused_ != should_pause) {
- rdh_->PauseRequest(global_id_.child_id, global_id_.request_id,
- should_pause);
+ ResourceDispatcherHostImpl::Get()->PauseRequest(global_id_.child_id,
+ global_id_.request_id,
+ should_pause);
is_paused_ = should_pause;
}
}
diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h
index df36368..5b9c708 100644
--- a/content/browser/download/download_resource_handler.h
+++ b/content/browser/download/download_resource_handler.h
@@ -19,7 +19,6 @@
class DownloadFileManager;
class DownloadRequestHandle;
-class ResourceDispatcherHost;
struct DownloadCreateInfo;
namespace content {
@@ -39,8 +38,7 @@ class DownloadResourceHandler : public ResourceHandler {
static const size_t kLoadsToWrite = 100; // number of data buffers queued
// started_cb will be called exactly once on the UI thread.
- DownloadResourceHandler(ResourceDispatcherHost* rdh,
- int render_process_host_id,
+ DownloadResourceHandler(int render_process_host_id,
int render_view_id,
int request_id,
const GURL& url,
@@ -120,7 +118,6 @@ class DownloadResourceHandler : public ResourceHandler {
OnStartedCallback started_cb_;
DownloadSaveInfo save_info_;
scoped_refptr<content::DownloadBuffer> buffer_;
- ResourceDispatcherHost* rdh_;
bool is_paused_;
base::OneShotTimer<DownloadResourceHandler> pause_timer_;
diff --git a/content/browser/download/save_file_manager.cc b/content/browser/download/save_file_manager.cc
index 03e2e51..35e3c71 100644
--- a/content/browser/download/save_file_manager.cc
+++ b/content/browser/download/save_file_manager.cc
@@ -15,7 +15,7 @@
#include "content/browser/download/save_file.h"
#include "content/browser/download/save_package.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
@@ -24,11 +24,10 @@
using content::BrowserThread;
using content::RenderViewHostImpl;
+using content::ResourceDispatcherHostImpl;
-SaveFileManager::SaveFileManager(ResourceDispatcherHost* rdh)
- : next_id_(0),
- resource_dispatcher_host_(rdh) {
- DCHECK(resource_dispatcher_host_);
+SaveFileManager::SaveFileManager()
+ : next_id_(0) {
}
SaveFileManager::~SaveFileManager() {
@@ -56,7 +55,7 @@ SaveFile* SaveFileManager::LookupSaveFile(int save_id) {
}
// Called on the IO thread when
-// a) The ResourceDispatcherHost has decided that a request is savable.
+// a) The ResourceDispatcherHostImpl has decided that a request is savable.
// b) The resource does not come from the network, but we still need a
// save ID for for managing the status of the saving operation. So we
// file a request from the file thread to the IO thread to generate a
@@ -359,11 +358,11 @@ void SaveFileManager::OnSaveURL(
int render_view_id,
content::ResourceContext* context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- resource_dispatcher_host_->BeginSaveFile(url,
- referrer,
- render_process_host_id,
- render_view_id,
- context);
+ ResourceDispatcherHostImpl::Get()->BeginSaveFile(url,
+ referrer,
+ render_process_host_id,
+ render_view_id,
+ context);
}
void SaveFileManager::OnRequireSaveJobFromOtherSource(
@@ -381,9 +380,9 @@ void SaveFileManager::OnRequireSaveJobFromOtherSource(
void SaveFileManager::ExecuteCancelSaveRequest(int render_process_id,
int request_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- resource_dispatcher_host_->CancelRequest(render_process_id,
- request_id,
- false);
+ ResourceDispatcherHostImpl::Get()->CancelRequest(render_process_id,
+ request_id,
+ false);
}
// Notifications sent from the UI thread and run on the file thread.
diff --git a/content/browser/download/save_file_manager.h b/content/browser/download/save_file_manager.h
index 9b88405..03237ba 100644
--- a/content/browser/download/save_file_manager.h
+++ b/content/browser/download/save_file_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -11,10 +11,10 @@
// and UI.
//
// The SaveFileManager itself is a singleton object owned by the
-// ResourceDispatcherHost.
+// ResourceDispatcherHostImpl.
//
// The data sent to SaveFileManager have 2 sources, one is from
-// ResourceDispatcherHost, run in network IO thread, the all sub-resources
+// ResourceDispatcherHostImpl, run in network IO thread, the all sub-resources
// and save-only-HTML pages will be got from network IO. The second is from
// render process, those html pages which are serialized from DOM will be
// composed in render process and encoded to its original encoding, then sent
@@ -71,7 +71,6 @@ class FilePath;
class GURL;
class SaveFile;
class SavePackage;
-class ResourceDispatcherHost;
namespace content {
class ResourceContext;
@@ -84,7 +83,7 @@ class IOBuffer;
class SaveFileManager
: public base::RefCountedThreadSafe<SaveFileManager> {
public:
- explicit SaveFileManager(ResourceDispatcherHost* rdh);
+ SaveFileManager();
// Lifetime management.
CONTENT_EXPORT void Shutdown();
@@ -95,7 +94,7 @@ class SaveFileManager
int GetNextId();
// Save the specified URL. Called on the UI thread and forwarded to the
- // ResourceDispatcherHost on the IO thread.
+ // ResourceDispatcherHostImpl on the IO thread.
void SaveURL(const GURL& url,
const GURL& referrer,
int render_process_host_id,
@@ -213,7 +212,7 @@ class SaveFileManager
content::ResourceContext* context);
// Handler for a notification sent to the IO thread for generating save id.
void OnRequireSaveJobFromOtherSource(SaveFileCreateInfo* info);
- // Call ResourceDispatcherHost's CancelRequest method to execute cancel
+ // Call ResourceDispatcherHostImpl's CancelRequest method to execute cancel
// action in the IO thread.
void ExecuteCancelSaveRequest(int render_process_id, int request_id);
@@ -224,8 +223,6 @@ class SaveFileManager
typedef base::hash_map<int, SaveFile*> SaveFileMap;
SaveFileMap save_file_map_;
- ResourceDispatcherHost* resource_dispatcher_host_;
-
// Tracks which SavePackage to send data to, called only on UI thread.
// SavePackageMap maps save IDs to their SavePackage.
typedef base::hash_map<int, SavePackage*> SavePackageMap;
diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc
index acb4fe22..232ea34 100644
--- a/content/browser/download/save_package.cc
+++ b/content/browser/download/save_package.cc
@@ -26,7 +26,7 @@
#include "content/browser/download/save_item.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_context.h"
@@ -48,6 +48,7 @@ using base::Time;
using content::BrowserThread;
using content::DownloadItem;
using content::NavigationEntry;
+using content::ResourceDispatcherHostImpl;
using content::WebContents;
using WebKit::WebPageSerializerClient;
@@ -250,7 +251,7 @@ void SavePackage::Cancel(bool user_action) {
// Init() can be called directly, or indirectly via GetSaveInfo(). In both
// cases, we need file_manager_ to be initialized, so we do this first.
void SavePackage::InternalInit() {
- ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
+ ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
if (!rdh) {
NOTREACHED();
return;
diff --git a/content/browser/indexed_db/idbbindingutilities_browsertest.cc b/content/browser/indexed_db/idbbindingutilities_browsertest.cc
index 6583fd7..8d297a7 100644
--- a/content/browser/indexed_db/idbbindingutilities_browsertest.cc
+++ b/content/browser/indexed_db/idbbindingutilities_browsertest.cc
@@ -6,7 +6,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/utility_process_host_impl.h"
#include "content/public/browser/utility_process_host_client.h"
#include "content/common/indexed_db/indexed_db_key.h"
diff --git a/content/browser/renderer_host/async_resource_handler.cc b/content/browser/renderer_host/async_resource_handler.cc
index e31afe0..b73fb29 100644
--- a/content/browser/renderer_host/async_resource_handler.cc
+++ b/content/browser/renderer_host/async_resource_handler.cc
@@ -13,14 +13,14 @@
#include "base/shared_memory.h"
#include "content/browser/debugger/devtools_netlog_observer.h"
#include "content/browser/host_zoom_map_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/resource_message_filter.h"
-#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/browser/resource_context_impl.h"
#include "content/common/resource_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/browser/resource_dispatcher_host_delegate.h"
+#include "content/public/browser/resource_request_info.h"
#include "content/public/common/resource_response.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
@@ -28,9 +28,8 @@
#include "webkit/glue/resource_loader_bridge.h"
using base::TimeTicks;
-using content::GlobalRequestID;
-using content::HostZoomMap;
-using content::ResourceRequestInfoImpl;
+
+namespace content {
namespace {
@@ -83,10 +82,10 @@ AsyncResourceHandler::AsyncResourceHandler(
ResourceMessageFilter* filter,
int routing_id,
const GURL& url,
- ResourceDispatcherHost* resource_dispatcher_host)
+ ResourceDispatcherHostImpl* rdh)
: filter_(filter),
routing_id_(routing_id),
- rdh_(resource_dispatcher_host),
+ rdh_(rdh),
next_buffer_size_(kInitialReadBufSize),
url_(url) {
}
@@ -139,7 +138,7 @@ bool AsyncResourceHandler::OnResponseStarted(
content::HostZoomMap* host_zoom_map =
content::GetHostZoomMapForResourceContext(resource_context);
- ResourceRequestInfoImpl* info = rdh_->InfoForRequest(request);
+ const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) {
GURL request_url(request->url());
filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL(
@@ -286,3 +285,5 @@ void AsyncResourceHandler::GlobalCleanup() {
tmp->Release();
}
}
+
+} // namespace content
diff --git a/content/browser/renderer_host/async_resource_handler.h b/content/browser/renderer_host/async_resource_handler.h
index 5e43615..5bc3733 100644
--- a/content/browser/renderer_host/async_resource_handler.h
+++ b/content/browser/renderer_host/async_resource_handler.h
@@ -11,8 +11,10 @@
#include "content/browser/renderer_host/resource_handler.h"
#include "googleurl/src/gurl.h"
-class ResourceDispatcherHost;
class ResourceMessageFilter;
+
+namespace content {
+class ResourceDispatcherHostImpl;
class SharedIOBuffer;
// Used to complete an asynchronous resource request in response to resource
@@ -22,7 +24,7 @@ class AsyncResourceHandler : public ResourceHandler {
AsyncResourceHandler(ResourceMessageFilter* filter,
int routing_id,
const GURL& url,
- ResourceDispatcherHost* resource_dispatcher_host);
+ ResourceDispatcherHostImpl* rdh);
// ResourceHandler implementation:
virtual bool OnUploadProgress(int request_id,
@@ -30,10 +32,10 @@ class AsyncResourceHandler : public ResourceHandler {
uint64 size) OVERRIDE;
virtual bool OnRequestRedirected(int request_id,
const GURL& new_url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) OVERRIDE;
virtual bool OnResponseStarted(int request_id,
- content::ResourceResponse* response) OVERRIDE;
+ ResourceResponse* response) OVERRIDE;
virtual bool OnWillStart(int request_id,
const GURL& url,
bool* defer) OVERRIDE;
@@ -58,7 +60,7 @@ class AsyncResourceHandler : public ResourceHandler {
scoped_refptr<SharedIOBuffer> read_buffer_;
scoped_refptr<ResourceMessageFilter> filter_;
int routing_id_;
- ResourceDispatcherHost* rdh_;
+ ResourceDispatcherHostImpl* rdh_;
// |next_buffer_size_| is the size of the buffer to be allocated on the next
// OnWillRead() call. We exponentially grow the size of the buffer allocated
@@ -74,4 +76,6 @@ class AsyncResourceHandler : public ResourceHandler {
DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_RENDERER_HOST_ASYNC_RESOURCE_HANDLER_H_
diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc
index e37d296..b5d0d35 100644
--- a/content/browser/renderer_host/buffered_resource_handler.cc
+++ b/content/browser/renderer_host/buffered_resource_handler.cc
@@ -14,7 +14,7 @@
#include "content/browser/download/download_stats.h"
#include "content/browser/download/download_types.h"
#include "content/browser/plugin_service_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/browser/renderer_host/x509_user_cert_resource_handler.h"
#include "content/public/browser/browser_thread.h"
@@ -61,9 +61,10 @@ void RecordSnifferMetrics(bool sniffing_blocked,
} // namespace
-BufferedResourceHandler::BufferedResourceHandler(ResourceHandler* handler,
- ResourceDispatcherHost* host,
- net::URLRequest* request)
+BufferedResourceHandler::BufferedResourceHandler(
+ ResourceHandler* handler,
+ ResourceDispatcherHostImpl* host,
+ net::URLRequest* request)
: LayeredResourceHandler(handler),
host_(host),
request_(request),
@@ -118,7 +119,7 @@ bool BufferedResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
bool BufferedResourceHandler::OnReadCompleted(int request_id, int* bytes_read) {
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
if (sniff_content_) {
if (KeepBuffering(*bytes_read))
@@ -257,7 +258,7 @@ bool BufferedResourceHandler::KeepBuffering(int bytes_read) {
bool BufferedResourceHandler::CompleteResponseStarted(int request_id) {
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
std::string mime_type;
request_->GetMimeType(&mime_type);
@@ -281,8 +282,9 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id) {
}
X509UserCertResourceHandler* x509_cert_handler =
- new X509UserCertResourceHandler(host_, request_,
- info->GetChildID(), info->GetRouteID());
+ new X509UserCertResourceHandler(request_,
+ info->GetChildID(),
+ info->GetRouteID());
if (!UseAlternateResourceHandler(request_id, x509_cert_handler))
return false;
}
@@ -331,7 +333,7 @@ bool BufferedResourceHandler::ShouldWaitForPlugins() {
// We don't want to keep buffering as our buffer will fill up.
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
host_->PauseRequest(info->GetChildID(), info->GetRequestID(), true);
// Get the plugins asynchronously.
@@ -367,7 +369,7 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) {
// Finally, check the plugin list.
bool allow_wildcard = false;
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
bool stale = false;
webkit::WebPluginInfo plugin;
bool found = PluginServiceImpl::GetInstance()->GetPluginInfo(
@@ -401,7 +403,7 @@ bool BufferedResourceHandler::UseAlternateResourceHandler(
// from the extra request info because the CrossSiteResourceHandler (part of
// the original ResourceHandler chain) will be deleted by the next statement.
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
info->set_cross_site_handler(NULL);
// This is handled entirely within the new ResourceHandler, so just reset the
@@ -417,7 +419,7 @@ bool BufferedResourceHandler::UseAlternateResourceHandler(
bool BufferedResourceHandler::ForwardPendingEventsToNextHandler(
int request_id) {
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
if (info->pause_count())
return true;
@@ -461,7 +463,7 @@ void BufferedResourceHandler::OnPluginsLoaded(
return;
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
int child_id = info->GetChildID();
int request_id = info->GetRequestID();
diff --git a/content/browser/renderer_host/buffered_resource_handler.h b/content/browser/renderer_host/buffered_resource_handler.h
index 869d328..b8af757 100644
--- a/content/browser/renderer_host/buffered_resource_handler.h
+++ b/content/browser/renderer_host/buffered_resource_handler.h
@@ -10,8 +10,6 @@
#include "content/browser/renderer_host/layered_resource_handler.h"
-class ResourceDispatcherHost;
-
namespace net {
class URLRequest;
} // namespace net
@@ -21,12 +19,13 @@ struct WebPluginInfo;
}
namespace content {
+class ResourceDispatcherHostImpl;
// Used to buffer a request until enough data has been received.
class BufferedResourceHandler : public LayeredResourceHandler {
public:
BufferedResourceHandler(ResourceHandler* handler,
- ResourceDispatcherHost* host,
+ ResourceDispatcherHostImpl* host,
net::URLRequest* request);
// ResourceHandler implementation:
@@ -81,7 +80,7 @@ class BufferedResourceHandler : public LayeredResourceHandler {
void OnPluginsLoaded(const std::vector<webkit::WebPluginInfo>& plugins);
scoped_refptr<ResourceResponse> response_;
- ResourceDispatcherHost* host_;
+ ResourceDispatcherHostImpl* host_;
net::URLRequest* request_;
scoped_refptr<net::IOBuffer> read_buffer_;
scoped_refptr<net::IOBuffer> my_buffer_;
diff --git a/content/browser/renderer_host/cross_site_resource_handler.cc b/content/browser/renderer_host/cross_site_resource_handler.cc
index 7f7cac7..aee115e 100644
--- a/content/browser/renderer_host/cross_site_resource_handler.cc
+++ b/content/browser/renderer_host/cross_site_resource_handler.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_request_id.h"
@@ -39,7 +39,7 @@ CrossSiteResourceHandler::CrossSiteResourceHandler(
ResourceHandler* handler,
int render_process_host_id,
int render_view_id,
- ResourceDispatcherHost* resource_dispatcher_host)
+ ResourceDispatcherHostImpl* rdh)
: LayeredResourceHandler(handler),
render_process_host_id_(render_process_host_id),
render_view_id_(render_view_id),
@@ -49,7 +49,7 @@ CrossSiteResourceHandler::CrossSiteResourceHandler(
completed_during_transition_(false),
completed_status_(),
response_(NULL),
- rdh_(resource_dispatcher_host) {
+ rdh_(rdh) {
}
bool CrossSiteResourceHandler::OnRequestRedirected(
@@ -80,8 +80,7 @@ bool CrossSiteResourceHandler::OnResponseStarted(
DLOG(WARNING) << "Request wasn't found";
return false;
}
- ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
// If this is a download, just pass the response through without doing a
// cross-site check. The renderer will see it is a download and abort the
@@ -171,7 +170,7 @@ void CrossSiteResourceHandler::ResumeResponse() {
// Remove ourselves from the ExtraRequestInfo.
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
+ ResourceRequestInfoImpl::ForRequest(request);
info->set_cross_site_handler(NULL);
// If the response completed during the transition, notify the next
@@ -203,7 +202,7 @@ void CrossSiteResourceHandler::StartCrossSiteTransition(
return;
}
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
+ ResourceRequestInfoImpl::ForRequest(request);
info->set_cross_site_handler(this);
if (has_started_response_) {
diff --git a/content/browser/renderer_host/cross_site_resource_handler.h b/content/browser/renderer_host/cross_site_resource_handler.h
index 7a25d80..e7dc4cb 100644
--- a/content/browser/renderer_host/cross_site_resource_handler.h
+++ b/content/browser/renderer_host/cross_site_resource_handler.h
@@ -9,9 +9,8 @@
#include "content/browser/renderer_host/layered_resource_handler.h"
#include "net/url_request/url_request_status.h"
-class ResourceDispatcherHost;
-
namespace content {
+class ResourceDispatcherHostImpl;
struct GlobalRequestID;
// Ensures that cross-site responses are delayed until the onunload handler of
@@ -24,15 +23,15 @@ class CrossSiteResourceHandler : public LayeredResourceHandler {
CrossSiteResourceHandler(ResourceHandler* handler,
int render_process_host_id,
int render_view_id,
- ResourceDispatcherHost* resource_dispatcher_host);
+ ResourceDispatcherHostImpl* rdh);
// ResourceHandler implementation:
virtual bool OnRequestRedirected(int request_id,
const GURL& new_url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) OVERRIDE;
virtual bool OnResponseStarted(int request_id,
- content::ResourceResponse* response) OVERRIDE;
+ ResourceResponse* response) OVERRIDE;
virtual bool OnReadCompleted(int request_id,
int* bytes_read) OVERRIDE;
virtual bool OnResponseCompleted(int request_id,
@@ -50,8 +49,8 @@ class CrossSiteResourceHandler : public LayeredResourceHandler {
// telling the old RenderViewHost to run its onunload handler.
void StartCrossSiteTransition(
int request_id,
- content::ResourceResponse* response,
- const content::GlobalRequestID& global_id);
+ ResourceResponse* response,
+ const GlobalRequestID& global_id);
int render_process_host_id_;
int render_view_id_;
@@ -61,8 +60,8 @@ class CrossSiteResourceHandler : public LayeredResourceHandler {
bool completed_during_transition_;
net::URLRequestStatus completed_status_;
std::string completed_security_info_;
- content::ResourceResponse* response_;
- ResourceDispatcherHost* rdh_;
+ ResourceResponse* response_;
+ ResourceDispatcherHostImpl* rdh_;
DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler);
};
diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.cc b/content/browser/renderer_host/redirect_to_file_resource_handler.cc
index 406ce91..031df1e 100644
--- a/content/browser/renderer_host/redirect_to_file_resource_handler.cc
+++ b/content/browser/renderer_host/redirect_to_file_resource_handler.cc
@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "base/message_loop_proxy.h"
#include "base/platform_file.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/public/common/resource_response.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
@@ -28,7 +28,7 @@ static const int kReadBufSize = 32768;
RedirectToFileResourceHandler::RedirectToFileResourceHandler(
ResourceHandler* next_handler,
int process_id,
- ResourceDispatcherHost* host)
+ ResourceDispatcherHostImpl* host)
: LayeredResourceHandler(next_handler),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
host_(host),
diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.h b/content/browser/renderer_host/redirect_to_file_resource_handler.h
index b649519..ff6bab0 100644
--- a/content/browser/renderer_host/redirect_to_file_resource_handler.h
+++ b/content/browser/renderer_host/redirect_to_file_resource_handler.h
@@ -13,8 +13,6 @@
#include "content/browser/renderer_host/layered_resource_handler.h"
#include "net/url_request/url_request_status.h"
-class ResourceDispatcherHost;
-
namespace net {
class FileStream;
class GrowableIOBuffer;
@@ -25,6 +23,7 @@ class ShareableFileReference;
}
namespace content {
+class ResourceDispatcherHostImpl;
// Redirects network data to a file. This is intended to be layered in front
// of either the AsyncResourceHandler or the SyncResourceHandler.
@@ -33,7 +32,7 @@ class RedirectToFileResourceHandler : public LayeredResourceHandler {
RedirectToFileResourceHandler(
ResourceHandler* next_handler,
int process_id,
- ResourceDispatcherHost* resource_dispatcher_host);
+ ResourceDispatcherHostImpl* resource_dispatcher_host);
// ResourceHandler implementation:
virtual bool OnResponseStarted(int request_id,
@@ -63,7 +62,7 @@ class RedirectToFileResourceHandler : public LayeredResourceHandler {
base::WeakPtrFactory<RedirectToFileResourceHandler> weak_factory_;
- ResourceDispatcherHost* host_;
+ ResourceDispatcherHostImpl* host_;
int process_id_;
int request_id_;
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index a48d4b1..79c191e 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -26,6 +26,7 @@
#include "content/browser/ppapi_plugin_process_host.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_widget_helper.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/child_process_messages.h"
#include "content/common/desktop_notification_messages.h"
@@ -74,6 +75,7 @@ using content::BrowserMessageFilter;
using content::BrowserThread;
using content::ChildProcessHostImpl;
using content::PluginServiceFilter;
+using content::ResourceDispatcherHostImpl;
using content::UserMetricsAction;
using net::CookieStore;
@@ -269,7 +271,7 @@ RenderMessageFilter::RenderMessageFilter(
content::BrowserContext* browser_context,
net::URLRequestContextGetter* request_context,
RenderWidgetHelper* render_widget_helper)
- : resource_dispatcher_host_(ResourceDispatcherHost::Get()),
+ : resource_dispatcher_host_(ResourceDispatcherHostImpl::Get()),
plugin_service_(plugin_service),
browser_context_(browser_context),
request_context_(request_context),
@@ -688,18 +690,17 @@ void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message,
const string16& suggested_name) {
DownloadSaveInfo save_info;
save_info.suggested_name = suggested_name;
- scoped_ptr<net::URLRequest> request(
- new net::URLRequest(url, resource_dispatcher_host_));
+ scoped_ptr<net::URLRequest> request(new net::URLRequest(url, NULL));
request->set_referrer(referrer.spec());
download_stats::RecordDownloadSource(download_stats::INITIATED_BY_RENDERER);
resource_dispatcher_host_->BeginDownload(
request.Pass(),
- false,
- save_info,
- DownloadResourceHandler::OnStartedCallback(),
+ resource_context_,
render_process_id_,
message.routing_id(),
- resource_context_);
+ false,
+ save_info,
+ ResourceDispatcherHostImpl::DownloadStartedCallback());
}
void RenderMessageFilter::OnCheckNotificationPermission(
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index 22f6618..36f1265 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -19,7 +19,7 @@
#include "base/shared_memory.h"
#include "base/string16.h"
#include "build/build_config.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/public/browser/browser_message_filter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
#include "ui/gfx/native_widget_types.h"
@@ -38,6 +38,7 @@ struct WebScreenInfo;
namespace content {
class BrowserContext;
class ResourceContext;
+class ResourceDispatcherHostImpl;
}
namespace base {
@@ -230,7 +231,7 @@ class RenderMessageFilter : public content::BrowserMessageFilter {
// Cached resource request dispatcher host and plugin service, guaranteed to
// be non-null if Init succeeds. We do not own the objects, they are managed
// by the BrowserProcess, which has a wider scope than we do.
- ResourceDispatcherHost* resource_dispatcher_host_;
+ content::ResourceDispatcherHostImpl* resource_dispatcher_host_;
PluginServiceImpl* plugin_service_;
// The browser context associated with our renderer process. This should only
diff --git a/content/browser/renderer_host/render_widget_helper.cc b/content/browser/renderer_host/render_widget_helper.cc
index 8ad0289..e69ba49 100644
--- a/content/browser/renderer_host/render_widget_helper.cc
+++ b/content/browser/renderer_host/render_widget_helper.cc
@@ -11,12 +11,13 @@
#include "content/browser/gpu/gpu_surface_tracker.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
using content::RenderViewHostImpl;
+using content::ResourceDispatcherHostImpl;
// A helper used with DidReceiveUpdateMsg that we hold a pointer to in
// pending_paints_.
@@ -80,7 +81,7 @@ RenderWidgetHelper::~RenderWidgetHelper() {
void RenderWidgetHelper::Init(
int render_process_id,
- ResourceDispatcherHost* resource_dispatcher_host) {
+ ResourceDispatcherHostImpl* resource_dispatcher_host) {
render_process_id_ = render_process_id;
resource_dispatcher_host_ = resource_dispatcher_host;
}
diff --git a/content/browser/renderer_host/render_widget_helper.h b/content/browser/renderer_host/render_widget_helper.h
index f53e445..f897984 100644
--- a/content/browser/renderer_host/render_widget_helper.h
+++ b/content/browser/renderer_host/render_widget_helper.h
@@ -28,7 +28,10 @@ namespace base {
class TimeDelta;
}
-class ResourceDispatcherHost;
+namespace content {
+class ResourceDispatcherHostImpl;
+}
+
struct ViewHostMsg_CreateWindow_Params;
struct ViewMsg_SwapOut_Params;
@@ -97,7 +100,7 @@ class RenderWidgetHelper
RenderWidgetHelper();
void Init(int render_process_id,
- ResourceDispatcherHost* resource_dispatcher_host);
+ content::ResourceDispatcherHostImpl* resource_dispatcher_host);
// Gets the next available routing id. This is thread safe.
int GetNextRoutingID();
@@ -212,7 +215,7 @@ class RenderWidgetHelper
// The next routing id to use.
base::AtomicSequenceNumber next_routing_id_;
- ResourceDispatcherHost* resource_dispatcher_host_;
+ content::ResourceDispatcherHostImpl* resource_dispatcher_host_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHelper);
};
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host_impl.cc
index c440872..7d1e4e3 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_impl.cc
@@ -4,7 +4,7 @@
// See http://dev.chromium.org/developers/design-documents/multi-process-resource-loading
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include <set>
#include <vector>
@@ -87,26 +87,17 @@
using base::Time;
using base::TimeDelta;
using base::TimeTicks;
-using content::BrowserThread;
-using content::GlobalRequestID;
-using content::RenderViewHostImpl;
-using content::ResourceContext;
-using content::ResourceRequestInfo;
-using content::ResourceRequestInfoImpl;
-using content::ResourceResponse;
-using content::ResourceThrottle;
-using content::ThrottlingResourceHandler;
-using content::WebContents;
-using content::WorkerServiceImpl;
using webkit_blob::ShareableFileReference;
// ----------------------------------------------------------------------------
+namespace content {
+
namespace {
-static ResourceDispatcherHost* g_resource_dispatcher_host;
+static ResourceDispatcherHostImpl* g_resource_dispatcher_host;
-// The interval for calls to ResourceDispatcherHost::UpdateLoadStates
+// The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates
const int kUpdateLoadStatesIntervalMsec = 100;
// Maximum number of pending data messages sent to the renderer at any
@@ -142,7 +133,7 @@ void AbortRequestBeforeItStarts(ResourceMessageFilter* filter,
net::URLRequestStatus status(net::URLRequestStatus::FAILED,
net::ERR_ABORTED);
if (sync_result) {
- content::SyncLoadResult result;
+ SyncLoadResult result;
result.status = status;
ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result);
filter->Send(sync_result);
@@ -164,13 +155,13 @@ GURL MaybeStripReferrer(const GURL& possible_referrer) {
}
// Consults the RendererSecurity policy to determine whether the
-// ResourceDispatcherHost should service this request. A request might be
+// ResourceDispatcherHostImpl should service this request. A request might be
// disallowed if the renderer is not authorized to retrieve the request URL or
// if the renderer is attempting to upload an unauthorized file.
-bool ShouldServiceRequest(content::ProcessType process_type,
+bool ShouldServiceRequest(ProcessType process_type,
int child_id,
const ResourceHostMsg_Request& request_data) {
- if (process_type == content::PROCESS_TYPE_PLUGIN)
+ if (process_type == PROCESS_TYPE_PLUGIN)
return true;
ChildProcessSecurityPolicyImpl* policy =
@@ -306,15 +297,14 @@ void OnSwapOutACKHelper(int render_process_id, int render_view_id) {
} // namespace
+// static
ResourceDispatcherHost* ResourceDispatcherHost::Get() {
return g_resource_dispatcher_host;
}
-ResourceDispatcherHost::ResourceDispatcherHost()
- : ALLOW_THIS_IN_INITIALIZER_LIST(
- download_file_manager_(new DownloadFileManager(this, NULL))),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- save_file_manager_(new SaveFileManager(this))),
+ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()
+ : download_file_manager_(new DownloadFileManager(NULL)),
+ save_file_manager_(new SaveFileManager()),
request_id_(-1),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
is_shutdown_(false),
@@ -327,7 +317,7 @@ ResourceDispatcherHost::ResourceDispatcherHost()
DCHECK(!g_resource_dispatcher_host);
g_resource_dispatcher_host = this;
- content::GetContentClient()->browser()->ResourceDispatcherHostCreated();
+ GetContentClient()->browser()->ResourceDispatcherHostCreated();
ANNOTATE_BENIGN_RACE(
&last_user_gesture_time_,
@@ -338,7 +328,7 @@ ResourceDispatcherHost::ResourceDispatcherHost()
base::Bind(&appcache::AppCacheInterceptor::EnsureRegistered));
}
-ResourceDispatcherHost::~ResourceDispatcherHost() {
+ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() {
DCHECK(g_resource_dispatcher_host);
g_resource_dispatcher_host = NULL;
AsyncResourceHandler::GlobalCleanup();
@@ -350,25 +340,220 @@ ResourceDispatcherHost::~ResourceDispatcherHost() {
DCHECK(transferred_navigations_.empty());
}
-void ResourceDispatcherHost::Shutdown() {
+// static
+ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() {
+ return g_resource_dispatcher_host;
+}
+
+void ResourceDispatcherHostImpl::SetDelegate(
+ ResourceDispatcherHostDelegate* delegate) {
+ delegate_ = delegate;
+}
+
+void ResourceDispatcherHostImpl::SetAllowCrossOriginAuthPrompt(bool value) {
+ allow_cross_origin_auth_prompt_ = value;
+}
+
+void ResourceDispatcherHostImpl::CancelRequestsForContext(
+ ResourceContext* context) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(context);
+
+ // Note that request cancellation has side effects. Therefore, we gather all
+ // the requests to cancel first, and then we start cancelling. We assert at
+ // the end that there are no more to cancel since the context is about to go
+ // away.
+ std::vector<net::URLRequest*> requests_to_cancel;
+ for (PendingRequestList::iterator i = pending_requests_.begin();
+ i != pending_requests_.end();) {
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
+ if (info->GetContext() == context) {
+ requests_to_cancel.push_back(i->second);
+ pending_requests_.erase(i++);
+ } else {
+ ++i;
+ }
+ }
+
+ for (BlockedRequestMap::iterator i = blocked_requests_map_.begin();
+ i != blocked_requests_map_.end();) {
+ BlockedRequestsList* requests = i->second;
+ if (requests->empty()) {
+ // This can happen if BlockRequestsForRoute() has been called for a route,
+ // but we haven't blocked any matching requests yet.
+ ++i;
+ continue;
+ }
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(requests->front());
+ if (info->GetContext() == context) {
+ blocked_requests_map_.erase(i++);
+ for (BlockedRequestsList::const_iterator it = requests->begin();
+ it != requests->end(); ++it) {
+ net::URLRequest* request = *it;
+ info = ResourceRequestInfoImpl::ForRequest(request);
+ // We make the assumption that all requests on the list have the same
+ // ResourceContext.
+ DCHECK_EQ(context, info->GetContext());
+ IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(),
+ info->GetChildID());
+ requests_to_cancel.push_back(request);
+ }
+ delete requests;
+ } else {
+ ++i;
+ }
+ }
+
+ for (std::vector<net::URLRequest*>::iterator i = requests_to_cancel.begin();
+ i != requests_to_cancel.end(); ++i) {
+ net::URLRequest* request = *i;
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(request);
+ // There is no strict requirement that this be the case, but currently
+ // downloads and transferred requests are the only requests that aren't
+ // cancelled when the associated processes go away. It may be OK for this
+ // invariant to change in the future, but if this assertion fires without
+ // the invariant changing, then it's indicative of a leak.
+ GlobalRequestID request_id(info->GetChildID(), info->GetRequestID());
+ bool is_transferred = IsTransferredNavigation(request_id);
+ DCHECK(info->is_download() || is_transferred);
+ if (is_transferred)
+ transferred_navigations_.erase(request_id);
+ delete request;
+ }
+
+ // Validate that no more requests for this context were added.
+ for (PendingRequestList::const_iterator i = pending_requests_.begin();
+ i != pending_requests_.end(); ++i) {
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
+ DCHECK_NE(info->GetContext(), context);
+ }
+
+ for (BlockedRequestMap::const_iterator i = blocked_requests_map_.begin();
+ i != blocked_requests_map_.end(); ++i) {
+ BlockedRequestsList* requests = i->second;
+ if (!requests->empty()) {
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(requests->front());
+ DCHECK_NE(info->GetContext(), context);
+ }
+ }
+}
+
+net::Error ResourceDispatcherHostImpl::BeginDownload(
+ scoped_ptr<net::URLRequest> request,
+ ResourceContext* context,
+ int child_id,
+ int route_id,
+ bool prefer_cache,
+ const DownloadSaveInfo& save_info,
+ const DownloadStartedCallback& started_callback) {
+ if (is_shutdown_)
+ return net::ERR_INSUFFICIENT_RESOURCES;
+
+ const GURL& url = request->original_url();
+#if defined(OS_CHROMEOS)
+ // crosbug.com/26646.
+ VLOG(1) << "BeginDownload: " << request->url().spec();
+#endif
+ const net::URLRequestContext* request_context = context->GetRequestContext();
+ request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec());
+ request->set_context(request_context);
+ int extra_load_flags = net::LOAD_IS_DOWNLOAD;
+ if (prefer_cache) {
+ // If there is upload data attached, only retrieve from cache because there
+ // is no current mechanism to prompt the user for their consent for a
+ // re-post. For GETs, try to retrieve data from the cache and skip
+ // validating the entry if present.
+ if (request->get_upload() != NULL)
+ extra_load_flags |= net::LOAD_ONLY_FROM_CACHE;
+ else
+ extra_load_flags |= net::LOAD_PREFERRING_CACHE;
+ } else {
+ extra_load_flags |= net::LOAD_DISABLE_CACHE;
+ }
+ request->set_load_flags(request->load_flags() | extra_load_flags);
+ // Check if the renderer is permitted to request the requested URL.
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->
+ CanRequestURL(child_id, url)) {
+ VLOG(1) << "Denied unauthorized download request for "
+ << url.possibly_invalid_spec();
+ return net::ERR_ACCESS_DENIED;
+ }
+
+ request_id_--;
+
+ scoped_refptr<ResourceHandler> handler(
+ CreateResourceHandlerForDownload(request.get(), context, child_id,
+ route_id, request_id_, save_info,
+ started_callback));
+
+ if (!request_context->job_factory()->IsHandledURL(url)) {
+ VLOG(1) << "Download request for unsupported protocol: "
+ << url.possibly_invalid_spec();
+ return net::ERR_ACCESS_DENIED;
+ }
+
+ ResourceRequestInfoImpl* extra_info =
+ CreateRequestInfo(handler, child_id, route_id, true, context);
+ extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
+
+ request->set_delegate(this);
+ BeginRequestInternal(request.release());
+
+ return net::OK;
+}
+
+void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest(
+ net::URLRequest* request) {
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
+ if (info)
+ info->set_login_delegate(NULL);
+}
+
+void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
+ net::URLRequest* transferred_request) {
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(transferred_request);
+
+ GlobalRequestID transferred_request_id(info->GetChildID(),
+ info->GetRequestID());
+ transferred_navigations_[transferred_request_id] = transferred_request;
+
+ // If a URLRequest is transferred to a new RenderViewHost, its
+ // ResourceHandler should not receive any notifications because it may
+ // depend on the state of the old RVH. We set a ResourceHandler that only
+ // allows canceling requests, because on shutdown of the RDH all pending
+ // requests are canceled. The RVH of requests that are being transferred may
+ // be gone by that time. If the request is resumed, the ResoureHandlers are
+ // substituted again.
+ scoped_refptr<ResourceHandler> transferred_resource_handler(
+ new DoomedResourceHandler(info->resource_handler()));
+ info->set_resource_handler(transferred_resource_handler.get());
+}
+
+void ResourceDispatcherHostImpl::Shutdown() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(BrowserThread::IO,
FROM_HERE,
- base::Bind(&ResourceDispatcherHost::OnShutdown,
+ base::Bind(&ResourceDispatcherHostImpl::OnShutdown,
base::Unretained(this)));
}
scoped_refptr<ResourceHandler>
-ResourceDispatcherHost::CreateResourceHandlerForDownload(
+ResourceDispatcherHostImpl::CreateResourceHandlerForDownload(
net::URLRequest* request,
- content::ResourceContext* context,
+ ResourceContext* context,
int child_id,
int route_id,
int request_id,
const DownloadSaveInfo& save_info,
const DownloadResourceHandler::OnStartedCallback& started_cb) {
scoped_refptr<ResourceHandler> handler(
- new DownloadResourceHandler(this, child_id, route_id, request_id,
+ new DownloadResourceHandler(child_id, route_id, request_id,
request->url(), download_file_manager_.get(),
request, started_cb, save_info));
if (delegate_) {
@@ -384,16 +569,22 @@ ResourceDispatcherHost::CreateResourceHandlerForDownload(
}
// static
-void ResourceDispatcherHost::ClearLoginDelegate(net::URLRequest* request) {
- ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
- if (!info)
- return;
+bool ResourceDispatcherHostImpl::RenderViewForRequest(
+ const net::URLRequest* request,
+ int* render_process_id,
+ int* render_view_id) {
+ const ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(request);
+ if (!info) {
+ *render_process_id = -1;
+ *render_view_id = -1;
+ return false;
+ }
- info->set_login_delegate(NULL);
+ return info->GetAssociatedRenderView(render_process_id, render_view_id);
}
-void ResourceDispatcherHost::OnShutdown() {
+void ResourceDispatcherHostImpl::OnShutdown() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
is_shutdown_ = true;
for (PendingRequestList::const_iterator i = pending_requests_.begin();
@@ -424,7 +615,7 @@ void ResourceDispatcherHost::OnShutdown() {
}
}
-bool ResourceDispatcherHost::HandleExternalProtocol(
+bool ResourceDispatcherHostImpl::HandleExternalProtocol(
int request_id,
int child_id,
int route_id,
@@ -450,12 +641,13 @@ bool ResourceDispatcherHost::HandleExternalProtocol(
return true;
}
-bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message,
- ResourceMessageFilter* filter,
- bool* message_was_ok) {
+bool ResourceDispatcherHostImpl::OnMessageReceived(
+ const IPC::Message& message,
+ ResourceMessageFilter* filter,
+ bool* message_was_ok) {
filter_ = filter;
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok)
+ IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHostImpl, message, *message_was_ok)
IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad)
IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile,
@@ -483,7 +675,7 @@ bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message,
return handled;
}
-void ResourceDispatcherHost::OnRequestResource(
+void ResourceDispatcherHostImpl::OnRequestResource(
const IPC::Message& message,
int request_id,
const ResourceHostMsg_Request& request_data) {
@@ -498,7 +690,7 @@ void ResourceDispatcherHost::OnRequestResource(
//
// If sync_result is non-null, then a SyncLoad reply will be generated, else
// a normal asynchronous set of response messages will be generated.
-void ResourceDispatcherHost::OnSyncLoad(
+void ResourceDispatcherHostImpl::OnSyncLoad(
int request_id,
const ResourceHostMsg_Request& request_data,
IPC::Message* sync_result) {
@@ -506,12 +698,12 @@ void ResourceDispatcherHost::OnSyncLoad(
sync_result->routing_id());
}
-void ResourceDispatcherHost::BeginRequest(
+void ResourceDispatcherHostImpl::BeginRequest(
int request_id,
const ResourceHostMsg_Request& request_data,
IPC::Message* sync_result, // only valid for sync
int route_id) {
- content::ProcessType process_type = filter_->process_type();
+ ProcessType process_type = filter_->process_type();
int child_id = filter_->child_id();
// If we crash here, figure out what URL the renderer was requesting.
@@ -534,7 +726,7 @@ void ResourceDispatcherHost::BeginRequest(
transferred_navigations_.erase(iter);
}
- content::ResourceContext* resource_context = filter_->resource_context();
+ ResourceContext* resource_context = filter_->resource_context();
// Might need to resolve the blob references in the upload data.
if (request_data.upload_data) {
@@ -548,8 +740,8 @@ void ResourceDispatcherHost::BeginRequest(
return;
}
- const content::Referrer referrer(MaybeStripReferrer(request_data.referrer),
- request_data.referrer_policy);
+ const Referrer referrer(MaybeStripReferrer(request_data.referrer),
+ request_data.referrer_policy);
// Allow the observer to block/handle the request.
if (delegate_ && !delegate_->ShouldBeginRequest(child_id,
@@ -575,8 +767,7 @@ void ResourceDispatcherHost::BeginRequest(
// The RedirectToFileResourceHandler depends on being next in the chain.
if (request_data.download_to_file)
- handler = new content::RedirectToFileResourceHandler(handler, child_id,
- this);
+ handler = new RedirectToFileResourceHandler(handler, child_id, this);
if (HandleExternalProtocol(
request_id, child_id, route_id, request_data.url,
@@ -654,19 +845,16 @@ void ResourceDispatcherHost::BeginRequest(
// MAIN_FRAME requests. Unblock requests only come from a blocked page, do
// not count as cross-site, otherwise it gets blocked indefinitely.
if (request_data.resource_type == ResourceType::MAIN_FRAME &&
- process_type == content::PROCESS_TYPE_RENDERER &&
+ process_type == PROCESS_TYPE_RENDERER &&
CrossSiteRequestManager::GetInstance()->
HasPendingCrossSiteRequest(child_id, route_id)) {
// Wrap the event handler to be sure the current page's onunload handler
// has a chance to run before we render the new page.
- handler = new content::CrossSiteResourceHandler(handler,
- child_id,
- route_id,
- this);
+ handler = new CrossSiteResourceHandler(handler, child_id, route_id, this);
}
// Insert a buffered event handler before the actual one.
- handler = new content::BufferedResourceHandler(handler, this, request);
+ handler = new BufferedResourceHandler(handler, this, request);
if (delegate_) {
bool is_continuation_of_transferred_request =
@@ -736,25 +924,26 @@ void ResourceDispatcherHost::BeginRequest(
}
}
-void ResourceDispatcherHost::OnReleaseDownloadedFile(int request_id) {
+void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) {
DCHECK(pending_requests_.end() ==
pending_requests_.find(
GlobalRequestID(filter_->child_id(), request_id)));
UnregisterDownloadedTempFile(filter_->child_id(), request_id);
}
-void ResourceDispatcherHost::OnDataReceivedACK(int request_id) {
+void ResourceDispatcherHostImpl::OnDataReceivedACK(int request_id) {
DataReceivedACK(filter_->child_id(), request_id);
}
-void ResourceDispatcherHost::DataReceivedACK(int child_id,
- int request_id) {
+void ResourceDispatcherHostImpl::DataReceivedACK(int child_id,
+ int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end())
return;
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
// Decrement the number of pending data messages.
info->DecrementPendingDataCount();
@@ -770,11 +959,11 @@ void ResourceDispatcherHost::DataReceivedACK(int child_id,
}
}
-void ResourceDispatcherHost::OnDataDownloadedACK(int request_id) {
+void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) {
// TODO(michaeln): maybe throttle DataDownloaded messages
}
-void ResourceDispatcherHost::RegisterDownloadedTempFile(
+void ResourceDispatcherHostImpl::RegisterDownloadedTempFile(
int child_id, int request_id, ShareableFileReference* reference) {
registered_temp_files_[child_id][request_id] = reference;
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
@@ -793,7 +982,7 @@ void ResourceDispatcherHost::RegisterDownloadedTempFile(
child_id));
}
-void ResourceDispatcherHost::UnregisterDownloadedTempFile(
+void ResourceDispatcherHostImpl::UnregisterDownloadedTempFile(
int child_id, int request_id) {
DeletableFilesMap& map = registered_temp_files_[child_id];
DeletableFilesMap::iterator found = map.find(request_id);
@@ -806,30 +995,31 @@ void ResourceDispatcherHost::UnregisterDownloadedTempFile(
// when all file refs are deleted (see RegisterDownloadedTempFile).
}
-bool ResourceDispatcherHost::Send(IPC::Message* message) {
+bool ResourceDispatcherHostImpl::Send(IPC::Message* message) {
delete message;
return false;
}
-void ResourceDispatcherHost::OnUploadProgressACK(int request_id) {
+void ResourceDispatcherHostImpl::OnUploadProgressACK(int request_id) {
int child_id = filter_->child_id();
PendingRequestList::iterator i = pending_requests_.find(
GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end())
return;
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
info->set_waiting_for_upload_progress_ack(false);
}
-void ResourceDispatcherHost::OnCancelRequest(int request_id) {
+void ResourceDispatcherHostImpl::OnCancelRequest(int request_id) {
CancelRequest(filter_->child_id(), request_id, true);
}
// Assigns the pending request a new routing_id because it was transferred
// to a new page.
-void ResourceDispatcherHost::OnTransferRequestToNewPage(int new_routing_id,
- int request_id) {
+void ResourceDispatcherHostImpl::OnTransferRequestToNewPage(int new_routing_id,
+ int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
GlobalRequestID(filter_->child_id(), request_id));
if (i == pending_requests_.end()) {
@@ -840,11 +1030,11 @@ void ResourceDispatcherHost::OnTransferRequestToNewPage(int new_routing_id,
return;
}
net::URLRequest* request = i->second;
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
info->set_route_id(new_routing_id);
}
-void ResourceDispatcherHost::OnFollowRedirect(
+void ResourceDispatcherHostImpl::OnFollowRedirect(
int request_id,
bool has_new_first_party_for_cookies,
const GURL& new_first_party_for_cookies) {
@@ -853,15 +1043,15 @@ void ResourceDispatcherHost::OnFollowRedirect(
new_first_party_for_cookies);
}
-ResourceRequestInfoImpl* ResourceDispatcherHost::CreateRequestInfo(
+ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
ResourceHandler* handler,
int child_id,
int route_id,
bool download,
- content::ResourceContext* context) {
+ ResourceContext* context) {
return new ResourceRequestInfoImpl(
handler,
- content::PROCESS_TYPE_RENDERER,
+ PROCESS_TYPE_RENDERER,
child_id,
route_id,
0,
@@ -871,7 +1061,7 @@ ResourceRequestInfoImpl* ResourceDispatcherHost::CreateRequestInfo(
false, // parent_is_main_frame
-1, // parent_frame_id
ResourceType::SUB_RESOURCE,
- content::PAGE_TRANSITION_LINK,
+ PAGE_TRANSITION_LINK,
0, // upload_size
download, // is_download
download, // allow_download
@@ -880,7 +1070,7 @@ ResourceRequestInfoImpl* ResourceDispatcherHost::CreateRequestInfo(
context);
}
-void ResourceDispatcherHost::OnSwapOutACK(
+void ResourceDispatcherHostImpl::OnSwapOutACK(
const ViewMsg_SwapOut_Params& params) {
// Closes for cross-site transitions are handled such that the cross-site
// transition continues.
@@ -889,20 +1079,21 @@ void ResourceDispatcherHost::OnSwapOutACK(
PendingRequestList::iterator i = pending_requests_.find(global_id);
if (i != pending_requests_.end()) {
// The response we were meant to resume could have already been canceled.
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
if (info->cross_site_handler())
info->cross_site_handler()->ResumeResponse();
}
// Update the RenderViewHost's internal state after the ACK.
- content::BrowserThread::PostTask(
- content::BrowserThread::UI,
+ BrowserThread::PostTask(
+ BrowserThread::UI,
FROM_HERE,
base::Bind(&OnSwapOutACKHelper,
params.closing_process_id,
params.closing_route_id));
}
-void ResourceDispatcherHost::OnDidLoadResourceFromMemoryCache(
+void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache(
const GURL& url,
const std::string& security_info,
const std::string& http_method,
@@ -914,77 +1105,13 @@ void ResourceDispatcherHost::OnDidLoadResourceFromMemoryCache(
GetCache()->OnExternalCacheHit(url, http_method);
}
-// We are explicitly forcing the download of 'url'.
-net::Error ResourceDispatcherHost::BeginDownload(
- scoped_ptr<net::URLRequest> request,
- bool prefer_cache,
- const DownloadSaveInfo& save_info,
- const DownloadResourceHandler::OnStartedCallback& started_cb,
- int child_id,
- int route_id,
- content::ResourceContext* context) {
- if (is_shutdown_)
- return net::ERR_INSUFFICIENT_RESOURCES;
-
- const GURL& url = request->original_url();
-#if defined(OS_CHROMEOS)
- // crosbug.com/26646.
- VLOG(1) << "BeginDownload: " << request->url().spec();
-#endif
- const net::URLRequestContext* request_context = context->GetRequestContext();
- request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec());
- request->set_context(request_context);
- int extra_load_flags = net::LOAD_IS_DOWNLOAD;
- if (prefer_cache) {
- // If there is upload data attached, only retrieve from cache because there
- // is no current mechanism to prompt the user for their consent for a
- // re-post. For GETs, try to retrieve data from the cache and skip
- // validating the entry if present.
- if (request->get_upload() != NULL)
- extra_load_flags |= net::LOAD_ONLY_FROM_CACHE;
- else
- extra_load_flags |= net::LOAD_PREFERRING_CACHE;
- } else {
- extra_load_flags |= net::LOAD_DISABLE_CACHE;
- }
- request->set_load_flags(request->load_flags() | extra_load_flags);
- // Check if the renderer is permitted to request the requested URL.
- if (!ChildProcessSecurityPolicyImpl::GetInstance()->
- CanRequestURL(child_id, url)) {
- VLOG(1) << "Denied unauthorized download request for "
- << url.possibly_invalid_spec();
- return net::ERR_ACCESS_DENIED;
- }
-
- request_id_--;
-
- scoped_refptr<ResourceHandler> handler(
- CreateResourceHandlerForDownload(request.get(), context, child_id,
- route_id, request_id_, save_info,
- started_cb));
-
- if (!request_context->job_factory()->IsHandledURL(url)) {
- VLOG(1) << "Download request for unsupported protocol: "
- << url.possibly_invalid_spec();
- return net::ERR_ACCESS_DENIED;
- }
-
- ResourceRequestInfoImpl* extra_info =
- CreateRequestInfo(handler, child_id, route_id, true, context);
- extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
-
- BeginRequestInternal(request.release());
-
- return net::OK;
-}
-
// This function is only used for saving feature.
-void ResourceDispatcherHost::BeginSaveFile(
+void ResourceDispatcherHostImpl::BeginSaveFile(
const GURL& url,
const GURL& referrer,
int child_id,
int route_id,
- content::ResourceContext* context) {
+ ResourceContext* context) {
if (is_shutdown_)
return;
@@ -1022,7 +1149,7 @@ void ResourceDispatcherHost::BeginSaveFile(
BeginRequestInternal(request);
}
-void ResourceDispatcherHost::FollowDeferredRedirect(
+void ResourceDispatcherHostImpl::FollowDeferredRedirect(
int child_id,
int request_id,
bool has_new_first_party_for_cookies,
@@ -1039,8 +1166,8 @@ void ResourceDispatcherHost::FollowDeferredRedirect(
i->second->FollowDeferredRedirect();
}
-void ResourceDispatcherHost::StartDeferredRequest(int child_id,
- int request_id) {
+void ResourceDispatcherHostImpl::StartDeferredRequest(int child_id,
+ int request_id) {
GlobalRequestID global_id(child_id, request_id);
PendingRequestList::iterator i = pending_requests_.find(global_id);
if (i == pending_requests_.end()) {
@@ -1056,8 +1183,8 @@ void ResourceDispatcherHost::StartDeferredRequest(int child_id,
StartRequest(i->second);
}
-bool ResourceDispatcherHost::WillSendData(int child_id,
- int request_id) {
+bool ResourceDispatcherHostImpl::WillSendData(int child_id,
+ int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end()) {
@@ -1065,7 +1192,8 @@ bool ResourceDispatcherHost::WillSendData(int child_id,
return false;
}
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
info->IncrementPendingDataCount();
if (info->pending_data_count() > kMaxPendingDataMessages) {
@@ -1079,9 +1207,9 @@ bool ResourceDispatcherHost::WillSendData(int child_id,
return true;
}
-void ResourceDispatcherHost::PauseRequest(int child_id,
- int request_id,
- bool pause) {
+void ResourceDispatcherHostImpl::PauseRequest(int child_id,
+ int request_id,
+ bool pause) {
GlobalRequestID global_id(child_id, request_id);
PendingRequestList::iterator i = pending_requests_.find(global_id);
if (i == pending_requests_.end()) {
@@ -1089,7 +1217,8 @@ void ResourceDispatcherHost::PauseRequest(int child_id,
return;
}
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
int pause_count = info->pause_count() + (pause ? 1 : -1);
if (pause_count < 0) {
NOTREACHED(); // Unbalanced call to pause.
@@ -1104,12 +1233,13 @@ void ResourceDispatcherHost::PauseRequest(int child_id,
if (info->pause_count() == 0) {
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(
- &ResourceDispatcherHost::ResumeRequest, weak_factory_.GetWeakPtr(),
+ &ResourceDispatcherHostImpl::ResumeRequest,
+ weak_factory_.GetWeakPtr(),
global_id));
}
}
-int ResourceDispatcherHost::GetOutstandingRequestsMemoryCost(
+int ResourceDispatcherHostImpl::GetOutstandingRequestsMemoryCost(
int child_id) const {
OutstandingRequestsMemoryCostMap::const_iterator entry =
outstanding_requests_memory_cost_map_.find(child_id);
@@ -1120,13 +1250,13 @@ int ResourceDispatcherHost::GetOutstandingRequestsMemoryCost(
// The object died, so cancel and detach all requests associated with it except
// for downloads, which belong to the browser process even if initiated via a
// renderer.
-void ResourceDispatcherHost::CancelRequestsForProcess(int child_id) {
+void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) {
CancelRequestsForRoute(child_id, -1 /* cancel all */);
registered_temp_files_.erase(child_id);
}
-void ResourceDispatcherHost::CancelRequestsForRoute(int child_id,
- int route_id) {
+void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id,
+ int route_id) {
// Since pending_requests_ is a map, we first build up a list of all of the
// matching requests to be cancelled, and then we cancel them. Since there
// may be more than one request to cancel, we cannot simply hold onto the map
@@ -1137,7 +1267,8 @@ void ResourceDispatcherHost::CancelRequestsForRoute(int child_id,
for (PendingRequestList::const_iterator i = pending_requests_.begin();
i != pending_requests_.end(); ++i) {
if (i->first.child_id == child_id) {
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(i->second);
GlobalRequestID id(child_id, i->first.request_id);
DCHECK(id == i->first);
// Don't cancel navigations that are transferring to another process,
@@ -1193,95 +1324,9 @@ void ResourceDispatcherHost::CancelRequestsForRoute(int child_id,
}
}
-void ResourceDispatcherHost::CancelRequestsForContext(
- content::ResourceContext* context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(context);
-
- // Note that request cancellation has side effects. Therefore, we gather all
- // the requests to cancel first, and then we start cancelling. We assert at
- // the end that there are no more to cancel since the context is about to go
- // away.
- std::vector<net::URLRequest*> requests_to_cancel;
- for (PendingRequestList::iterator i = pending_requests_.begin();
- i != pending_requests_.end();) {
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
- if (info->GetContext() == context) {
- requests_to_cancel.push_back(i->second);
- pending_requests_.erase(i++);
- } else {
- ++i;
- }
- }
-
- for (BlockedRequestMap::iterator i = blocked_requests_map_.begin();
- i != blocked_requests_map_.end();) {
- BlockedRequestsList* requests = i->second;
- if (requests->empty()) {
- // This can happen if BlockRequestsForRoute() has been called for a route,
- // but we haven't blocked any matching requests yet.
- ++i;
- continue;
- }
- ResourceRequestInfoImpl* info =
- InfoForRequest(requests->front());
- if (info->GetContext() == context) {
- blocked_requests_map_.erase(i++);
- for (BlockedRequestsList::const_iterator it = requests->begin();
- it != requests->end(); ++it) {
- net::URLRequest* request = *it;
- info = InfoForRequest(request);
- // We make the assumption that all requests on the list have the same
- // ResourceContext.
- DCHECK_EQ(context, info->GetContext());
- IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(),
- info->GetChildID());
- requests_to_cancel.push_back(request);
- }
- delete requests;
- } else {
- ++i;
- }
- }
-
- for (std::vector<net::URLRequest*>::iterator i = requests_to_cancel.begin();
- i != requests_to_cancel.end(); ++i) {
- net::URLRequest* request = *i;
- ResourceRequestInfoImpl* info = InfoForRequest(request);
- // There is no strict requirement that this be the case, but currently
- // downloads and transferred requests are the only requests that aren't
- // cancelled when the associated processes go away. It may be OK for this
- // invariant to change in the future, but if this assertion fires without
- // the invariant changing, then it's indicative of a leak.
- GlobalRequestID request_id(info->GetChildID(), info->GetRequestID());
- bool is_transferred = IsTransferredNavigation(request_id);
- DCHECK(info->is_download() || is_transferred);
- if (is_transferred)
- transferred_navigations_.erase(request_id);
- delete request;
- }
-
- // Validate that no more requests for this context were added.
- for (PendingRequestList::const_iterator i = pending_requests_.begin();
- i != pending_requests_.end(); ++i) {
- ResourceRequestInfoImpl* info = InfoForRequest(i->second);
- DCHECK_NE(info->GetContext(), context);
- }
-
- for (BlockedRequestMap::const_iterator i = blocked_requests_map_.begin();
- i != blocked_requests_map_.end(); ++i) {
- BlockedRequestsList* requests = i->second;
- if (!requests->empty()) {
- ResourceRequestInfoImpl* info =
- InfoForRequest(requests->front());
- DCHECK_NE(info->GetContext(), context);
- }
- }
-}
-
// Cancels the request and removes it from the list.
-void ResourceDispatcherHost::RemovePendingRequest(int child_id,
- int request_id) {
+void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id,
+ int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
GlobalRequestID(child_id, request_id));
if (i == pending_requests_.end()) {
@@ -1291,9 +1336,10 @@ void ResourceDispatcherHost::RemovePendingRequest(int child_id,
RemovePendingRequest(i);
}
-void ResourceDispatcherHost::RemovePendingRequest(
+void ResourceDispatcherHostImpl::RemovePendingRequest(
const PendingRequestList::iterator& iter) {
- ResourceRequestInfoImpl* info = InfoForRequest(iter->second);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(iter->second);
// Remove the memory credit that we added when pushing the request onto
// the pending list.
@@ -1318,15 +1364,15 @@ void ResourceDispatcherHost::RemovePendingRequest(
// net::URLRequest::Delegate ---------------------------------------------------
-void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request,
- const GURL& new_url,
- bool* defer_redirect) {
+void ResourceDispatcherHostImpl::OnReceivedRedirect(net::URLRequest* request,
+ const GURL& new_url,
+ bool* defer_redirect) {
VLOG(1) << "OnReceivedRedirect: " << request->url().spec();
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
DCHECK(request->status().is_success());
- if (info->process_type() != content::PROCESS_TYPE_PLUGIN &&
+ if (info->process_type() != PROCESS_TYPE_PLUGIN &&
!ChildProcessSecurityPolicyImpl::GetInstance()->
CanRequestURL(info->GetChildID(), new_url)) {
VLOG(1) << "Denied unauthorized request for "
@@ -1357,7 +1403,7 @@ void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request,
CancelRequestInternal(request, false);
}
-void ResourceDispatcherHost::OnAuthRequired(
+void ResourceDispatcherHostImpl::OnAuthRequired(
net::URLRequest* request,
net::AuthChallengeInfo* auth_info) {
if (request->load_flags() & net::LOAD_DO_NOT_PROMPT_FOR_LOGIN) {
@@ -1392,7 +1438,7 @@ void ResourceDispatcherHost::OnAuthRequired(
// authentication.
// That would also solve the problem of the net::URLRequest being cancelled
// before we receive authentication.
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
DCHECK(!info->login_delegate()) <<
"OnAuthRequired called with login_delegate pending";
if (delegate_) {
@@ -1403,7 +1449,7 @@ void ResourceDispatcherHost::OnAuthRequired(
request->CancelAuth();
}
-void ResourceDispatcherHost::OnCertificateRequested(
+void ResourceDispatcherHostImpl::OnCertificateRequested(
net::URLRequest* request,
net::SSLCertRequestInfo* cert_request_info) {
DCHECK(request);
@@ -1419,7 +1465,7 @@ void ResourceDispatcherHost::OnCertificateRequested(
return;
}
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
DCHECK(!info->ssl_client_auth_handler()) <<
"OnCertificateRequested called with ssl_client_auth_handler pending";
info->set_ssl_client_auth_handler(
@@ -1427,17 +1473,17 @@ void ResourceDispatcherHost::OnCertificateRequested(
info->ssl_client_auth_handler()->SelectCertificate();
}
-void ResourceDispatcherHost::OnSSLCertificateError(
+void ResourceDispatcherHostImpl::OnSSLCertificateError(
net::URLRequest* request,
const net::SSLInfo& ssl_info,
bool is_hsts_host) {
DCHECK(request);
- SSLManager::OnSSLCertificateError(this, request, ssl_info, is_hsts_host);
+ SSLManager::OnSSLCertificateError(request, ssl_info, is_hsts_host);
}
-void ResourceDispatcherHost::OnResponseStarted(net::URLRequest* request) {
+void ResourceDispatcherHostImpl::OnResponseStarted(net::URLRequest* request) {
VLOG(1) << "OnResponseStarted: " << request->url().spec();
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
if (request->status().is_success()) {
if (PauseRequestIfNeeded(info)) {
@@ -1467,8 +1513,9 @@ void ResourceDispatcherHost::OnResponseStarted(net::URLRequest* request) {
}
}
-bool ResourceDispatcherHost::CompleteResponseStarted(net::URLRequest* request) {
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+bool ResourceDispatcherHostImpl::CompleteResponseStarted(
+ net::URLRequest* request) {
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
scoped_refptr<ResourceResponse> response(new ResourceResponse);
PopulateResourceResponse(request, response);
@@ -1477,7 +1524,7 @@ bool ResourceDispatcherHost::CompleteResponseStarted(net::URLRequest* request) {
int cert_id =
CertStore::GetInstance()->StoreCert(request->ssl_info().cert,
info->GetChildID());
- response->security_info = content::SerializeSecurityInfo(
+ response->security_info = SerializeSecurityInfo(
cert_id, request->ssl_info().cert_status,
request->ssl_info().security_bits,
request->ssl_info().connection_status);
@@ -1494,9 +1541,9 @@ bool ResourceDispatcherHost::CompleteResponseStarted(net::URLRequest* request) {
response.get());
}
-void ResourceDispatcherHost::CancelRequest(int child_id,
- int request_id,
- bool from_renderer) {
+void ResourceDispatcherHostImpl::CancelRequest(int child_id,
+ int request_id,
+ bool from_renderer) {
GlobalRequestID id(child_id, request_id);
if (from_renderer) {
// When the old renderer dies, it sends a message to us to cancel its
@@ -1523,20 +1570,20 @@ void ResourceDispatcherHost::CancelRequest(int child_id,
// this request.
MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&ResourceDispatcherHost::CallResponseCompleted,
+ base::Bind(&ResourceDispatcherHostImpl::CallResponseCompleted,
base::Unretained(this),
child_id,
request_id));
}
}
-bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request,
- bool from_renderer) {
+bool ResourceDispatcherHostImpl::CancelRequestInternal(net::URLRequest* request,
+ bool from_renderer) {
VLOG(1) << "CancelRequest: " << request->url().spec();
// WebKit will send us a cancel for downloads since it no longer handles them.
// In this case, ignore the cancel since we handle downloads in the browser.
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
if (!from_renderer || !info->is_download()) {
if (info->login_delegate()) {
info->login_delegate()->OnRequestCancelled();
@@ -1558,7 +1605,7 @@ bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request,
return false;
}
-int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost(
+int ResourceDispatcherHostImpl::IncrementOutstandingRequestsMemoryCost(
int cost,
int child_id) {
// Retrieve the previous value (defaulting to 0 if not found).
@@ -1580,7 +1627,7 @@ int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost(
}
// static
-int ResourceDispatcherHost::CalculateApproximateMemoryCost(
+int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
net::URLRequest* request) {
// The following fields should be a minor size contribution (experimentally
// on the order of 100). However since they are variable length, it could
@@ -1595,9 +1642,10 @@ int ResourceDispatcherHost::CalculateApproximateMemoryCost(
return kAvgBytesPerOutstandingRequest + strings_cost;
}
-void ResourceDispatcherHost::BeginRequestInternal(net::URLRequest* request) {
+void ResourceDispatcherHostImpl::BeginRequestInternal(
+ net::URLRequest* request) {
DCHECK(!request->is_pending());
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
if ((TimeTicks::Now() - last_user_gesture_time_) <
TimeDelta::FromMilliseconds(kUserGestureWindowMs)) {
@@ -1660,31 +1708,32 @@ void ResourceDispatcherHost::BeginRequestInternal(net::URLRequest* request) {
StartRequest(request);
}
-void ResourceDispatcherHost::StartRequest(net::URLRequest* request) {
+void ResourceDispatcherHostImpl::StartRequest(net::URLRequest* request) {
request->Start();
// Make sure we have the load state monitor running
if (!update_load_states_timer_.IsRunning()) {
update_load_states_timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec),
- this, &ResourceDispatcherHost::UpdateLoadStates);
+ this, &ResourceDispatcherHostImpl::UpdateLoadStates);
}
}
-bool ResourceDispatcherHost::PauseRequestIfNeeded(
+bool ResourceDispatcherHostImpl::PauseRequestIfNeeded(
ResourceRequestInfoImpl* info) {
if (info->pause_count() > 0)
info->set_is_paused(true);
return info->is_paused();
}
-void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) {
+void ResourceDispatcherHostImpl::ResumeRequest(
+ const GlobalRequestID& request_id) {
PendingRequestList::iterator i = pending_requests_.find(request_id);
if (i == pending_requests_.end()) // The request may have been destroyed
return;
net::URLRequest* request = i->second;
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
// We may already be unpaused, or the pause count may have increased since we
// posted the task to call ResumeRequest.
@@ -1710,20 +1759,21 @@ void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) {
}
}
-void ResourceDispatcherHost::StartReading(net::URLRequest* request) {
+void ResourceDispatcherHostImpl::StartReading(net::URLRequest* request) {
// Start reading.
int bytes_read = 0;
if (Read(request, &bytes_read)) {
OnReadCompleted(request, bytes_read);
} else if (!request->status().is_io_pending()) {
- DCHECK(!InfoForRequest(request)->is_paused());
+ DCHECK(!ResourceRequestInfoImpl::ForRequest(request)->is_paused());
// If the error is not an IO pending, then we're done reading.
ResponseCompleted(request);
}
}
-bool ResourceDispatcherHost::Read(net::URLRequest* request, int* bytes_read) {
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+bool ResourceDispatcherHostImpl::Read(net::URLRequest* request,
+ int* bytes_read) {
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
DCHECK(!info->is_paused());
net::IOBuffer* buf;
@@ -1740,12 +1790,12 @@ bool ResourceDispatcherHost::Read(net::URLRequest* request, int* bytes_read) {
return request->Read(buf, buf_size, bytes_read);
}
-void ResourceDispatcherHost::OnReadCompleted(net::URLRequest* request,
- int bytes_read) {
+void ResourceDispatcherHostImpl::OnReadCompleted(net::URLRequest* request,
+ int bytes_read) {
DCHECK(request);
VLOG(1) << "OnReadCompleted: \"" << request->url().spec() << "\""
<< " bytes_read = " << bytes_read;
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
// bytes_read == -1 always implies an error, so we want to skip the pause
// checks and just call ResponseCompleted.
@@ -1788,7 +1838,7 @@ void ResourceDispatcherHost::OnReadCompleted(net::URLRequest* request,
MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(
- &ResourceDispatcherHost::ResumeRequest,
+ &ResourceDispatcherHostImpl::ResumeRequest,
weak_factory_.GetWeakPtr(), id));
return;
}
@@ -1809,14 +1859,14 @@ void ResourceDispatcherHost::OnReadCompleted(net::URLRequest* request,
ResponseCompleted(request);
}
-bool ResourceDispatcherHost::CompleteRead(net::URLRequest* request,
- int* bytes_read) {
+bool ResourceDispatcherHostImpl::CompleteRead(net::URLRequest* request,
+ int* bytes_read) {
if (!request || !request->status().is_success()) {
NOTREACHED();
return false;
}
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
if (!info->resource_handler()->OnReadCompleted(info->GetRequestID(),
bytes_read)) {
CancelRequestInternal(request, false);
@@ -1826,9 +1876,9 @@ bool ResourceDispatcherHost::CompleteRead(net::URLRequest* request,
return *bytes_read != 0;
}
-void ResourceDispatcherHost::ResponseCompleted(net::URLRequest* request) {
+void ResourceDispatcherHostImpl::ResponseCompleted(net::URLRequest* request) {
VLOG(1) << "ResponseCompleted: " << request->url().spec();
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
// If the load for a main frame has failed, track it in a histogram,
// since it will probably cause the user to see an error page.
@@ -1859,7 +1909,7 @@ void ResourceDispatcherHost::ResponseCompleted(net::URLRequest* request) {
if (ssl_info.cert != NULL) {
int cert_id = CertStore::GetInstance()->StoreCert(ssl_info.cert,
info->GetChildID());
- security_info = content::SerializeSecurityInfo(
+ security_info = SerializeSecurityInfo(
cert_id, ssl_info.cert_status, ssl_info.security_bits,
ssl_info.connection_status);
}
@@ -1875,50 +1925,19 @@ void ResourceDispatcherHost::ResponseCompleted(net::URLRequest* request) {
// call until later. We will notify the world and clean up when we resume.
}
-void ResourceDispatcherHost::CallResponseCompleted(int child_id,
- int request_id) {
+void ResourceDispatcherHostImpl::CallResponseCompleted(int child_id,
+ int request_id) {
PendingRequestList::iterator i = pending_requests_.find(
GlobalRequestID(child_id, request_id));
if (i != pending_requests_.end())
ResponseCompleted(i->second);
}
-void ResourceDispatcherHost::OnUserGesture(TabContents* tab) {
+void ResourceDispatcherHostImpl::OnUserGesture(TabContents* tab) {
last_user_gesture_time_ = TimeTicks::Now();
}
-// static
-ResourceRequestInfoImpl* ResourceDispatcherHost::InfoForRequest(
- net::URLRequest* request) {
- // Avoid writing this function twice by casting the const version.
- const net::URLRequest* const_request = request;
- return const_cast<ResourceRequestInfoImpl*>(
- InfoForRequest(const_request));
-}
-
-// static
-const ResourceRequestInfoImpl* ResourceDispatcherHost::InfoForRequest(
- const net::URLRequest* request) {
- return static_cast<const ResourceRequestInfoImpl*>(
- ResourceRequestInfo::ForRequest(request));
-}
-
-// static
-bool ResourceDispatcherHost::RenderViewForRequest(
- const net::URLRequest* request,
- int* render_process_id,
- int* render_view_id) {
- const ResourceRequestInfoImpl* info = InfoForRequest(request);
- if (!info) {
- *render_process_id = -1;
- *render_view_id = -1;
- return false;
- }
-
- return info->GetAssociatedRenderView(render_process_id, render_view_id);
-}
-
-net::URLRequest* ResourceDispatcherHost::GetURLRequest(
+net::URLRequest* ResourceDispatcherHostImpl::GetURLRequest(
const GlobalRequestID& request_id) const {
// This should be running in the IO loop.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -1938,8 +1957,8 @@ static int GetCertID(net::URLRequest* request, int child_id) {
return 0;
}
-void ResourceDispatcherHost::NotifyResponseStarted(net::URLRequest* request,
- int child_id) {
+void ResourceDispatcherHostImpl::NotifyResponseStarted(net::URLRequest* request,
+ int child_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
int render_process_id, render_view_id;
@@ -1952,14 +1971,15 @@ void ResourceDispatcherHost::NotifyResponseStarted(net::URLRequest* request,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(
- &ResourceDispatcherHost::NotifyOnUI<ResourceRequestDetails>,
- static_cast<int>(content::NOTIFICATION_RESOURCE_RESPONSE_STARTED),
+ &ResourceDispatcherHostImpl::NotifyOnUI<ResourceRequestDetails>,
+ static_cast<int>(NOTIFICATION_RESOURCE_RESPONSE_STARTED),
render_process_id, render_view_id, detail));
}
-void ResourceDispatcherHost::NotifyReceivedRedirect(net::URLRequest* request,
- int child_id,
- const GURL& new_url) {
+void ResourceDispatcherHostImpl::NotifyReceivedRedirect(
+ net::URLRequest* request,
+ int child_id,
+ const GURL& new_url) {
int render_process_id, render_view_id;
if (!RenderViewForRequest(request, &render_process_id, &render_view_id))
return;
@@ -1970,23 +1990,23 @@ void ResourceDispatcherHost::NotifyReceivedRedirect(net::URLRequest* request,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(
- &ResourceDispatcherHost::NotifyOnUI<ResourceRedirectDetails>,
- static_cast<int>(content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT),
+ &ResourceDispatcherHostImpl::NotifyOnUI<ResourceRedirectDetails>,
+ static_cast<int>(NOTIFICATION_RESOURCE_RECEIVED_REDIRECT),
render_process_id, render_view_id, detail));
}
template <class T>
-void ResourceDispatcherHost::NotifyOnUI(int type,
- int render_process_id,
- int render_view_id,
- T* detail) {
+void ResourceDispatcherHostImpl::NotifyOnUI(int type,
+ int render_process_id,
+ int render_view_id,
+ T* detail) {
RenderViewHostImpl* rvh =
RenderViewHostImpl::FromID(render_process_id, render_view_id);
if (rvh) {
- content::RenderViewHostDelegate* rvhd = rvh->GetDelegate();
- content::NotificationService::current()->Notify(
- type, content::Source<WebContents>(rvhd->GetAsWebContents()),
- content::Details<T>(detail));
+ RenderViewHostDelegate* rvhd = rvh->GetDelegate();
+ NotificationService::current()->Notify(
+ type, Source<WebContents>(rvhd->GetAsWebContents()),
+ Details<T>(detail));
}
delete detail;
}
@@ -2041,7 +2061,7 @@ void LoadInfoUpdateCallback(const LoadInfoMap& info_map) {
} // namespace
-void ResourceDispatcherHost::UpdateLoadStates() {
+void ResourceDispatcherHostImpl::UpdateLoadStates() {
// Populate this map with load state changes, and then send them on to the UI
// thread where they can be passed along to the respective RVHs.
LoadInfoMap info_map;
@@ -2053,7 +2073,8 @@ void ResourceDispatcherHost::UpdateLoadStates() {
std::map<std::pair<int, int>, uint64> largest_upload_size;
for (i = pending_requests_.begin(); i != pending_requests_.end(); ++i) {
net::URLRequest* request = i->second;
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(request);
uint64 upload_size = info->GetUploadSize();
if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST)
upload_size = 0;
@@ -2065,7 +2086,8 @@ void ResourceDispatcherHost::UpdateLoadStates() {
for (i = pending_requests_.begin(); i != pending_requests_.end(); ++i) {
net::URLRequest* request = i->second;
net::LoadStateWithParam load_state = request->GetLoadState();
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(request);
std::pair<int, int> key(info->GetChildID(), info->GetRouteID());
// We also poll for upload progress on this timer and send upload
@@ -2102,7 +2124,7 @@ void ResourceDispatcherHost::UpdateLoadStates() {
}
// Calls the ResourceHandler to send upload progress messages to the renderer.
-void ResourceDispatcherHost::MaybeUpdateUploadProgress(
+void ResourceDispatcherHostImpl::MaybeUpdateUploadProgress(
ResourceRequestInfoImpl *info,
net::URLRequest *request) {
@@ -2135,24 +2157,25 @@ void ResourceDispatcherHost::MaybeUpdateUploadProgress(
}
}
-void ResourceDispatcherHost::BlockRequestsForRoute(int child_id, int route_id) {
+void ResourceDispatcherHostImpl::BlockRequestsForRoute(int child_id,
+ int route_id) {
std::pair<int, int> key(child_id, route_id);
DCHECK(blocked_requests_map_.find(key) == blocked_requests_map_.end()) <<
"BlockRequestsForRoute called multiple time for the same RVH";
blocked_requests_map_[key] = new BlockedRequestsList();
}
-void ResourceDispatcherHost::ResumeBlockedRequestsForRoute(int child_id,
- int route_id) {
+void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute(int child_id,
+ int route_id) {
ProcessBlockedRequestsForRoute(child_id, route_id, false);
}
-void ResourceDispatcherHost::CancelBlockedRequestsForRoute(int child_id,
- int route_id) {
+void ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute(int child_id,
+ int route_id) {
ProcessBlockedRequestsForRoute(child_id, route_id, true);
}
-void ResourceDispatcherHost::ProcessBlockedRequestsForRoute(
+void ResourceDispatcherHostImpl::ProcessBlockedRequestsForRoute(
int child_id,
int route_id,
bool cancel_requests) {
@@ -2174,7 +2197,8 @@ void ResourceDispatcherHost::ProcessBlockedRequestsForRoute(
// Remove the memory credit that we added when pushing the request onto
// the blocked list.
net::URLRequest* request = *req_iter;
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(request);
IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(),
info->GetChildID());
if (cancel_requests)
@@ -2186,30 +2210,17 @@ void ResourceDispatcherHost::ProcessBlockedRequestsForRoute(
delete requests;
}
-bool ResourceDispatcherHost::IsValidRequest(net::URLRequest* request) {
+bool ResourceDispatcherHostImpl::IsValidRequest(net::URLRequest* request) {
if (!request)
return false;
- ResourceRequestInfoImpl* info = InfoForRequest(request);
+ ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
return pending_requests_.find(
GlobalRequestID(info->GetChildID(), info->GetRequestID())) !=
pending_requests_.end();
}
-// static
-bool ResourceDispatcherHost::is_prefetch_enabled() {
- return is_prefetch_enabled_;
-}
-
-// static
-void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) {
- is_prefetch_enabled_ = value;
-}
-
-// static
-bool ResourceDispatcherHost::is_prefetch_enabled_ = false;
-
-ResourceDispatcherHost::HttpAuthResourceType
-ResourceDispatcherHost::HttpAuthResourceTypeOf(net::URLRequest* request) {
+ResourceDispatcherHostImpl::HttpAuthResourceType
+ResourceDispatcherHostImpl::HttpAuthResourceTypeOf(net::URLRequest* request) {
// Use the same critera as for cookies to determine the sub-resource type
// that is requesting to be authenticated.
if (!request->first_party_for_cookies().is_valid())
@@ -2225,34 +2236,14 @@ ResourceDispatcherHost::HttpAuthResourceTypeOf(net::URLRequest* request) {
return HTTP_AUTH_RESOURCE_BLOCKED_CROSS;
}
-bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() {
+bool ResourceDispatcherHostImpl::allow_cross_origin_auth_prompt() {
return allow_cross_origin_auth_prompt_;
}
-void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) {
- allow_cross_origin_auth_prompt_ = value;
-}
-
-void ResourceDispatcherHost::MarkAsTransferredNavigation(
- const GlobalRequestID& transferred_request_id,
- net::URLRequest* transferred_request) {
- transferred_navigations_[transferred_request_id] = transferred_request;
-
- // If a URLRequest is transferred to a new RenderViewHost, its
- // ResourceHandlers should not receive any notifications because they may
- // depend on the state of the old RVH. We set a ResourceHandler that only
- // allows canceling requests, because on shutdown of the RDH all pending
- // requests are canceled. The RVH of requests that are being transferred may
- // be gone by that time. If the request is resumed, the ResoureHandlers are
- // substituted again.
- ResourceRequestInfoImpl* info = InfoForRequest(transferred_request);
- scoped_refptr<ResourceHandler> transferred_resource_handler(
- new DoomedResourceHandler(info->resource_handler()));
- info->set_resource_handler(transferred_resource_handler.get());
-}
-
-bool ResourceDispatcherHost::IsTransferredNavigation(
- const content::GlobalRequestID& transferred_request_id) const {
+bool ResourceDispatcherHostImpl::IsTransferredNavigation(
+ const GlobalRequestID& transferred_request_id) const {
return transferred_navigations_.find(transferred_request_id) !=
transferred_navigations_.end();
}
+
+} // namespace content
diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host_impl.h
index fb38569..9f09b5e 100644
--- a/content/browser/renderer_host/resource_dispatcher_host.h
+++ b/content/browser/renderer_host/resource_dispatcher_host_impl.h
@@ -9,8 +9,8 @@
//
// See http://dev.chromium.org/developers/design-documents/multi-process-resource-loading
-#ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_
-#define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_
+#ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_
+#define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_
#pragma once
#include <map>
@@ -27,6 +27,7 @@
#include "content/common/content_export.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/resource_dispatcher_host.h"
#include "ipc/ipc_message.h"
#include "net/url_request/url_request.h"
#include "webkit/glue/resource_type.h"
@@ -40,30 +41,46 @@ struct DownloadSaveInfo;
struct ResourceHostMsg_Request;
struct ViewMsg_SwapOut_Params;
-namespace content {
-class ResourceContext;
-class ResourceDispatcherHostDelegate;
-class ResourceRequestInfoImpl;
-struct GlobalRequestID;
-}
-
namespace net {
class CookieList;
class URLRequestJobFactory;
-} // namespace net
+}
namespace webkit_blob {
class ShareableFileReference;
}
-class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
- public:
- ResourceDispatcherHost();
- virtual ~ResourceDispatcherHost();
+namespace content {
+class ResourceContext;
+class ResourceDispatcherHostDelegate;
+class ResourceRequestInfoImpl;
+struct GlobalRequestID;
- // Returns the current ResourceDispatcherHost. May return NULL if it hasn't
- // been created yet.
- static ResourceDispatcherHost* Get();
+class CONTENT_EXPORT ResourceDispatcherHostImpl
+ : public ResourceDispatcherHost,
+ public net::URLRequest::Delegate {
+ public:
+ ResourceDispatcherHostImpl();
+ virtual ~ResourceDispatcherHostImpl();
+
+ // Returns the current ResourceDispatcherHostImpl. May return NULL if it
+ // hasn't been created yet.
+ static ResourceDispatcherHostImpl* Get();
+
+ // ResourceDispatcherHost implementation:
+ virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) OVERRIDE;
+ virtual void SetAllowCrossOriginAuthPrompt(bool value) OVERRIDE;
+ virtual void CancelRequestsForContext(ResourceContext* context) OVERRIDE;
+ virtual net::Error BeginDownload(
+ scoped_ptr<net::URLRequest> request,
+ ResourceContext* context,
+ int child_id,
+ int route_id,
+ bool prefer_cache,
+ const DownloadSaveInfo& save_info,
+ const DownloadStartedCallback& started_callback) OVERRIDE;
+ virtual void ClearLoginDelegateForRequest(net::URLRequest* request) OVERRIDE;
+ virtual void MarkAsTransferredNavigation(net::URLRequest* request) OVERRIDE;
// Puts the resource dispatcher host in an inactive state (unable to begin
// new requests). Cancels all pending requests.
@@ -75,26 +92,13 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
ResourceMessageFilter* filter,
bool* message_was_ok);
- // Initiates a download by explicit request of the renderer, e.g. due to
- // alt-clicking a link. If the download is started, |started_cb| will be
- // called on the UI thread with the DownloadId; otherwise an error code will
- // be returned.
- net::Error BeginDownload(
- scoped_ptr<net::URLRequest> request,
- bool prefer_cache,
- const DownloadSaveInfo& save_info,
- const DownloadResourceHandler::OnStartedCallback& started_cb,
- int child_id,
- int route_id,
- content::ResourceContext* context);
-
// Initiates a save file from the browser process (as opposed to a resource
// request from the renderer or another child process).
void BeginSaveFile(const GURL& url,
const GURL& referrer,
int child_id,
int route_id,
- content::ResourceContext* context);
+ ResourceContext* context);
// Cancels the given request if it still exists. We ignore cancels from the
// renderer in the event of a download.
@@ -167,11 +171,6 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// acts like CancelRequestsForProcess when route_id is -1.
void CancelRequestsForRoute(int child_id, int route_id);
- // Force cancels any pending requests for the given |context|. This is
- // necessary to ensure that before |context| goes away, all requests
- // for it are dead.
- void CancelRequestsForContext(content::ResourceContext* context);
-
// net::URLRequest::Delegate
virtual void OnReceivedRedirect(net::URLRequest* request,
const GURL& new_url,
@@ -190,24 +189,9 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
void OnUserGesture(TabContents* tab);
- // Helper functions to get the dispatcher's request info for the request.
- // If the dispatcher didn't create the request then NULL is returned.
- static content::ResourceRequestInfoImpl* InfoForRequest(
- net::URLRequest* request);
- static const content::ResourceRequestInfoImpl* InfoForRequest(
- const net::URLRequest* request);
-
- // Extracts the render view/process host's identifiers from the given request
- // and places them in the given out params (both required). If there are no
- // such IDs associated with the request (such as non-page-related requests),
- // this function will return false and both out params will be -1.
- static bool RenderViewForRequest(const net::URLRequest* request,
- int* render_process_host_id,
- int* render_view_host_id);
-
// Retrieves a net::URLRequest. Must be called from the IO thread.
net::URLRequest* GetURLRequest(
- const content::GlobalRequestID& request_id) const;
+ const GlobalRequestID& request_id) const;
void RemovePendingRequest(int child_id, int request_id);
@@ -240,42 +224,23 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// Needed for the sync IPC message dispatcher macros.
bool Send(IPC::Message* message);
- // Controls if we launch or squash prefetch requests as they arrive
- // from renderers.
- static bool is_prefetch_enabled();
- static void set_is_prefetch_enabled(bool value);
-
- // Controls whether third-party sub-content can pop-up HTTP basic auth
+ // Indicates whether third-party sub-content can pop-up HTTP basic auth
// dialog boxes.
bool allow_cross_origin_auth_prompt();
- void set_allow_cross_origin_auth_prompt(bool value);
- // This does not take ownership of the delegate. It is expected that the
- // delegate have a longer lifetime than the ResourceDispatcherHost.
- void set_delegate(content::ResourceDispatcherHostDelegate* delegate) {
- delegate_ = delegate;
- }
- content::ResourceDispatcherHostDelegate* delegate() {
+ ResourceDispatcherHostDelegate* delegate() {
return delegate_;
}
- // Marks the request as "parked". This happens if a request is
- // redirected cross-site and needs to be resumed by a new render view.
- void MarkAsTransferredNavigation(
- const content::GlobalRequestID& transferred_request_id,
- net::URLRequest* transferred_request);
-
scoped_refptr<ResourceHandler> CreateResourceHandlerForDownload(
net::URLRequest* request,
- content::ResourceContext* context,
+ ResourceContext* context,
int child_id,
int route_id,
int request_id,
const DownloadSaveInfo& save_info,
const DownloadResourceHandler::OnStartedCallback& started_cb);
- static void ClearLoginDelegate(net::URLRequest* request);
-
private:
FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest,
TestBlockedRequestsProcessDies);
@@ -288,16 +253,24 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
friend class ShutdownTask;
+ // Extracts the render view/process host's identifiers from the given request
+ // and places them in the given out params (both required). If there are no
+ // such IDs associated with the request (such as non-page-related requests),
+ // this function will return false and both out params will be -1.
+ static bool RenderViewForRequest(const net::URLRequest* request,
+ int* render_process_host_id,
+ int* render_view_host_id);
+
// A shutdown helper that runs on the IO thread.
void OnShutdown();
void StartRequest(net::URLRequest* request);
// Returns true if the request is paused.
- bool PauseRequestIfNeeded(content::ResourceRequestInfoImpl* info);
+ bool PauseRequestIfNeeded(ResourceRequestInfoImpl* info);
// Resumes the given request by calling OnResponseStarted or OnReadCompleted.
- void ResumeRequest(const content::GlobalRequestID& request_id);
+ void ResumeRequest(const GlobalRequestID& request_id);
// Internal function to start reading for the first time.
void StartReading(net::URLRequest* request);
@@ -346,7 +319,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// It may be enhanced in the future to provide some kind of prioritization
// mechanism. We should also consider a hashtable or binary tree if it turns
// out we have a lot of things here.
- typedef std::map<content::GlobalRequestID, net::URLRequest*>
+ typedef std::map<GlobalRequestID, net::URLRequest*>
PendingRequestList;
// Deletes the pending request identified by the iterator passed in.
@@ -377,7 +350,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
void UpdateLoadStates();
// Checks the upload state and sends an update if one is necessary.
- void MaybeUpdateUploadProgress(content::ResourceRequestInfoImpl *info,
+ void MaybeUpdateUploadProgress(ResourceRequestInfoImpl *info,
net::URLRequest *request);
// Resumes or cancels (if |cancel_requests| is true) any blocked requests.
@@ -407,12 +380,12 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// Creates ResourceRequestInfoImpl for a download or page save.
// |download| should be true if the request is a file download.
- content::ResourceRequestInfoImpl* CreateRequestInfo(
+ ResourceRequestInfoImpl* CreateRequestInfo(
ResourceHandler* handler,
int child_id,
int route_id,
bool download,
- content::ResourceContext* context);
+ ResourceContext* context);
// Returns true if |request| is in |pending_requests_|.
bool IsValidRequest(net::URLRequest* request);
@@ -441,7 +414,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// This happens if a request is redirected cross-site and needs to be resumed
// by a new render view.
bool IsTransferredNavigation(
- const content::GlobalRequestID& transferred_request_id) const;
+ const GlobalRequestID& transferred_request_id) const;
PendingRequestList pending_requests_;
@@ -456,7 +429,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// A timer that periodically calls UpdateLoadStates while pending_requests_
// is not empty.
- base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_;
+ base::RepeatingTimer<ResourceDispatcherHostImpl> update_load_states_timer_;
// We own the download file writing thread and manager
scoped_refptr<DownloadFileManager> download_file_manager_;
@@ -474,7 +447,7 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
int request_id_;
// For running tasks.
- base::WeakPtrFactory<ResourceDispatcherHost> weak_factory_;
+ base::WeakPtrFactory<ResourceDispatcherHostImpl> weak_factory_;
// True if the resource dispatcher host has been shut down.
bool is_shutdown_;
@@ -507,18 +480,18 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate {
// to the source of the message.
ResourceMessageFilter* filter_;
- content::ResourceDispatcherHostDelegate* delegate_;
+ ResourceDispatcherHostDelegate* delegate_;
- static bool is_prefetch_enabled_;
bool allow_cross_origin_auth_prompt_;
// Maps the request ID of request that is being transferred to a new RVH
// to the respective request.
- typedef std::map<content::GlobalRequestID, net::URLRequest*>
- TransferredNavigations;
+ typedef std::map<GlobalRequestID, net::URLRequest*> TransferredNavigations;
TransferredNavigations transferred_navigations_;
- DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost);
+ DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
};
-#endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_
diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
index 2f79982..4de2c2d 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include <vector>
@@ -13,7 +13,7 @@
#include "base/process_util.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/child_process_security_policy_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/resource_message_filter.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/resource_messages.h"
@@ -33,15 +33,11 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/appcache/appcache_interfaces.h"
-using content::BrowserContext;
-using content::BrowserThread;
-using content::BrowserThreadImpl;
-using content::ChildProcessHostImpl;
-using content::GlobalRequestID;
-
// TODO(eroman): Write unit tests for SafeBrowsing that exercise
// SafeBrowsingResourceHandler.
+namespace content {
+
namespace {
// Returns the resource response header structure for this request.
@@ -464,7 +460,7 @@ class ResourceDispatcherHostTest : public testing::Test,
BrowserThreadImpl io_thread_;
scoped_ptr<TestBrowserContext> browser_context_;
scoped_refptr<ForwardingFilter> filter_;
- ResourceDispatcherHost host_;
+ ResourceDispatcherHostImpl host_;
ResourceIPCAccumulator accum_;
std::string response_headers_;
std::string response_data_;
@@ -631,7 +627,7 @@ TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) {
TestResourceDispatcherHostDelegate delegate;
delegate.set_defer_start(true);
delegate.set_url_request_user_data(new TestUserData(&was_deleted));
- host_.set_delegate(&delegate);
+ host_.SetDelegate(&delegate);
MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1());
CancelRequest(1);
@@ -944,11 +940,13 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
// Test the private helper method "CalculateApproximateMemoryCost()".
TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) {
net::URLRequest req(GURL("http://www.google.com"), NULL);
- EXPECT_EQ(4427, ResourceDispatcherHost::CalculateApproximateMemoryCost(&req));
+ EXPECT_EQ(4427,
+ ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(&req));
// Add 9 bytes of referrer.
req.set_referrer("123456789");
- EXPECT_EQ(4436, ResourceDispatcherHost::CalculateApproximateMemoryCost(&req));
+ EXPECT_EQ(4436,
+ ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(&req));
// Add 33 bytes of upload content.
std::string upload_content;
@@ -957,7 +955,8 @@ TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) {
req.AppendBytesToUpload(upload_content.data(), upload_content.size());
// Since the upload throttling is disabled, this has no effect on the cost.
- EXPECT_EQ(4436, ResourceDispatcherHost::CalculateApproximateMemoryCost(&req));
+ EXPECT_EQ(4436,
+ ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(&req));
}
// Test the private helper method "IncrementOutstandingRequestsMemoryCost()".
@@ -1001,7 +1000,7 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
// Expected cost of each request as measured by
// ResourceDispatcherHost::CalculateApproximateMemoryCost().
int kMemoryCostOfTest2Req =
- ResourceDispatcherHost::kAvgBytesPerOutstandingRequest +
+ ResourceDispatcherHostImpl::kAvgBytesPerOutstandingRequest +
std::string("GET").size() +
net::URLRequestTestJob::test_url_2().spec().size();
@@ -1338,8 +1337,7 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) {
MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
GlobalRequestID global_request_id(filter_->child_id(), request_id);
- host_.MarkAsTransferredNavigation(global_request_id,
- host_.GetURLRequest(global_request_id));
+ host_.MarkAsTransferredNavigation(host_.GetURLRequest(global_request_id));
// And now simulate a cancellation coming from the renderer.
ResourceHostMsg_CancelRequest msg(filter_->child_id(), request_id);
@@ -1392,3 +1390,5 @@ TEST_F(ResourceDispatcherHostTest, UnknownURLScheme) {
EXPECT_EQ(net::URLRequestStatus::FAILED, status.status());
EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error());
}
+
+} // namespace content
diff --git a/content/browser/renderer_host/resource_message_filter.cc b/content/browser/renderer_host/resource_message_filter.cc
index 502d0a3..0c1a127 100644
--- a/content/browser/renderer_host/resource_message_filter.cc
+++ b/content/browser/renderer_host/resource_message_filter.cc
@@ -1,14 +1,15 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/renderer_host/resource_message_filter.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
using content::BrowserMessageFilter;
+using content::ResourceDispatcherHostImpl;
ResourceMessageFilter::ResourceMessageFilter(
int child_id,
@@ -31,12 +32,12 @@ void ResourceMessageFilter::OnChannelClosing() {
// Unhook us from all pending network requests so they don't get sent to a
// deleted object.
- ResourceDispatcherHost::Get()->CancelRequestsForProcess(child_id_);
+ ResourceDispatcherHostImpl::Get()->CancelRequestsForProcess(child_id_);
}
bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) {
- return ResourceDispatcherHost::Get()->OnMessageReceived(
+ return ResourceDispatcherHostImpl::Get()->OnMessageReceived(
message, this, message_was_ok);
}
diff --git a/content/browser/renderer_host/resource_request_details.cc b/content/browser/renderer_host/resource_request_details.cc
index 7ae17e6..ca65e58 100644
--- a/content/browser/renderer_host/resource_request_details.cc
+++ b/content/browser/renderer_host/resource_request_details.cc
@@ -4,9 +4,9 @@
#include "content/browser/renderer_host/resource_request_details.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/browser/worker_host/worker_service_impl.h"
+#include "net/url_request/url_request.h"
using content::ResourceRequestInfoImpl;
using content::WorkerServiceImpl;
@@ -24,7 +24,7 @@ ResourceRequestDetails::ResourceRequestDetails(const net::URLRequest* request,
ssl_cert_status_(request->ssl_info().cert_status),
socket_address_(request->GetSocketAddress()) {
const ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
+ ResourceRequestInfoImpl::ForRequest(request);
resource_type_ = info->GetResourceType();
frame_id_ = info->GetFrameID();
diff --git a/content/browser/renderer_host/resource_request_info_impl.cc b/content/browser/renderer_host/resource_request_info_impl.cc
index 92c9240..77d5011 100644
--- a/content/browser/renderer_host/resource_request_info_impl.cc
+++ b/content/browser/renderer_host/resource_request_info_impl.cc
@@ -14,11 +14,13 @@
namespace content {
+// ----------------------------------------------------------------------------
+// ResourceRequestInfo
+
// static
const ResourceRequestInfo* ResourceRequestInfo::ForRequest(
const net::URLRequest* request) {
- return static_cast<const ResourceRequestInfoImpl*>(
- request->GetUserData(NULL));
+ return ResourceRequestInfoImpl::ForRequest(request);
}
// static
@@ -62,6 +64,20 @@ bool ResourceRequestInfo::GetRenderViewForRequest(
return true;
}
+// ----------------------------------------------------------------------------
+// ResourceRequestInfoImpl
+
+// static
+ResourceRequestInfoImpl* ResourceRequestInfoImpl::ForRequest(
+ net::URLRequest* request) {
+ return static_cast<ResourceRequestInfoImpl*>(request->GetUserData(NULL));
+}
+
+// static
+const ResourceRequestInfoImpl* ResourceRequestInfoImpl::ForRequest(
+ const net::URLRequest* request) {
+ return ForRequest(const_cast<net::URLRequest*>(request));
+}
ResourceRequestInfoImpl::ResourceRequestInfoImpl(
ResourceHandler* handler,
diff --git a/content/browser/renderer_host/resource_request_info_impl.h b/content/browser/renderer_host/resource_request_info_impl.h
index 6b41bea..b823f93 100644
--- a/content/browser/renderer_host/resource_request_info_impl.h
+++ b/content/browser/renderer_host/resource_request_info_impl.h
@@ -19,7 +19,6 @@
#include "net/base/load_states.h"
#include "webkit/glue/resource_type.h"
-class ResourceDispatcherHost;
class ResourceHandler;
class SSLClientAuthHandler;
@@ -30,6 +29,7 @@ class BlobData;
namespace content {
class CrossSiteResourceHandler;
class ResourceContext;
+class ResourceDispatcherHostImpl;
class ResourceDispatcherHostLoginDelegate;
// Holds the data ResourceDispatcherHost associates with each request.
@@ -37,6 +37,14 @@ class ResourceDispatcherHostLoginDelegate;
class ResourceRequestInfoImpl : public ResourceRequestInfo,
public base::SupportsUserData::Data {
public:
+ // Returns the ResourceRequestInfoImpl associated with the given URLRequest.
+ CONTENT_EXPORT static ResourceRequestInfoImpl* ForRequest(
+ net::URLRequest* request);
+
+ // And, a const version for cases where you only need read access.
+ static const ResourceRequestInfoImpl* ForRequest(
+ const net::URLRequest* request);
+
// This will take a reference to the handler.
CONTENT_EXPORT ResourceRequestInfoImpl(
ResourceHandler* handler,
@@ -171,7 +179,7 @@ class ResourceRequestInfoImpl : public ResourceRequestInfo,
void set_requested_blob_data(webkit_blob::BlobData* data);
private:
- friend class ::ResourceDispatcherHost;
+ friend class ResourceDispatcherHostImpl;
// Request is temporarily not handling network data. Should be used only
// by the ResourceDispatcherHost, not the event handlers (accessors are
diff --git a/content/browser/renderer_host/sync_resource_handler.cc b/content/browser/renderer_host/sync_resource_handler.cc
index b2f805f..a82a946 100644
--- a/content/browser/renderer_host/sync_resource_handler.cc
+++ b/content/browser/renderer_host/sync_resource_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,7 +6,7 @@
#include "base/logging.h"
#include "content/browser/debugger/devtools_netlog_observer.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/resource_message_filter.h"
#include "content/common/resource_messages.h"
#include "content/public/browser/global_request_id.h"
@@ -14,13 +14,13 @@
#include "net/base/io_buffer.h"
#include "net/http/http_response_headers.h"
-using content::GlobalRequestID;
+namespace content {
SyncResourceHandler::SyncResourceHandler(
ResourceMessageFilter* filter,
const GURL& url,
IPC::Message* result_message,
- ResourceDispatcherHost* resource_dispatcher_host)
+ ResourceDispatcherHostImpl* resource_dispatcher_host)
: read_buffer_(new net::IOBuffer(kReadBufSize)),
filter_(filter),
result_message_(result_message),
@@ -40,7 +40,7 @@ bool SyncResourceHandler::OnUploadProgress(int request_id,
bool SyncResourceHandler::OnRequestRedirected(
int request_id,
const GURL& new_url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) {
net::URLRequest* request = rdh_->GetURLRequest(
GlobalRequestID(filter_->child_id(), request_id));
@@ -61,7 +61,7 @@ bool SyncResourceHandler::OnRequestRedirected(
bool SyncResourceHandler::OnResponseStarted(
int request_id,
- content::ResourceResponse* response) {
+ ResourceResponse* response) {
net::URLRequest* request = rdh_->GetURLRequest(
GlobalRequestID(filter_->child_id(), request_id));
if (rdh_->delegate())
@@ -128,3 +128,5 @@ void SyncResourceHandler::OnRequestClosed() {
result_message_->set_reply_error();
filter_->Send(result_message_);
}
+
+} // namespace content
diff --git a/content/browser/renderer_host/sync_resource_handler.h b/content/browser/renderer_host/sync_resource_handler.h
index 43c9bb8..314e9a8 100644
--- a/content/browser/renderer_host/sync_resource_handler.h
+++ b/content/browser/renderer_host/sync_resource_handler.h
@@ -11,7 +11,6 @@
#include "content/browser/renderer_host/resource_handler.h"
#include "content/public/common/resource_response.h"
-class ResourceDispatcherHost;
class ResourceMessageFilter;
namespace IPC {
@@ -22,6 +21,9 @@ namespace net {
class IOBuffer;
}
+namespace content {
+class ResourceDispatcherHostImpl;
+
// Used to complete a synchronous resource request in response to resource load
// events from the resource dispatcher host.
class SyncResourceHandler : public ResourceHandler {
@@ -29,17 +31,17 @@ class SyncResourceHandler : public ResourceHandler {
SyncResourceHandler(ResourceMessageFilter* filter,
const GURL& url,
IPC::Message* result_message,
- ResourceDispatcherHost* resource_dispatcher_host);
+ ResourceDispatcherHostImpl* resource_dispatcher_host);
virtual bool OnUploadProgress(int request_id,
uint64 position,
uint64 size) OVERRIDE;
virtual bool OnRequestRedirected(int request_id,
const GURL& new_url,
- content::ResourceResponse* response,
+ ResourceResponse* response,
bool* defer) OVERRIDE;
virtual bool OnResponseStarted(int request_id,
- content::ResourceResponse* response) OVERRIDE;
+ ResourceResponse* response) OVERRIDE;
virtual bool OnWillStart(int request_id,
const GURL& url,
bool* defer) OVERRIDE;
@@ -61,10 +63,12 @@ class SyncResourceHandler : public ResourceHandler {
scoped_refptr<net::IOBuffer> read_buffer_;
- content::SyncLoadResult result_;
+ SyncLoadResult result_;
scoped_refptr<ResourceMessageFilter> filter_;
IPC::Message* result_message_;
- ResourceDispatcherHost* rdh_;
+ ResourceDispatcherHostImpl* rdh_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_RENDERER_HOST_SYNC_RESOURCE_HANDLER_H_
diff --git a/content/browser/renderer_host/throttling_resource_handler.cc b/content/browser/renderer_host/throttling_resource_handler.cc
index 38b656f..5ae01f4 100644
--- a/content/browser/renderer_host/throttling_resource_handler.cc
+++ b/content/browser/renderer_host/throttling_resource_handler.cc
@@ -4,14 +4,14 @@
#include "content/browser/renderer_host/throttling_resource_handler.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/public/browser/resource_throttle.h"
#include "content/public/common/resource_response.h"
namespace content {
ThrottlingResourceHandler::ThrottlingResourceHandler(
- ResourceDispatcherHost* host,
+ ResourceDispatcherHostImpl* host,
ResourceHandler* next_handler,
int child_id,
int request_id,
diff --git a/content/browser/renderer_host/throttling_resource_handler.h b/content/browser/renderer_host/throttling_resource_handler.h
index 4a387ee..a8fb145 100644
--- a/content/browser/renderer_host/throttling_resource_handler.h
+++ b/content/browser/renderer_host/throttling_resource_handler.h
@@ -12,10 +12,9 @@
#include "content/public/browser/resource_throttle_controller.h"
#include "googleurl/src/gurl.h"
-class ResourceDispatcherHost;
-
namespace content {
+class ResourceDispatcherHostImpl;
class ResourceThrottle;
struct ResourceResponse;
@@ -24,7 +23,7 @@ class ThrottlingResourceHandler : public LayeredResourceHandler,
public ResourceThrottleController {
public:
// Takes ownership of the ResourceThrottle instances.
- ThrottlingResourceHandler(ResourceDispatcherHost* host,
+ ThrottlingResourceHandler(ResourceDispatcherHostImpl* host,
ResourceHandler* next_handler,
int child_id,
int request_id,
@@ -59,7 +58,7 @@ class ThrottlingResourceHandler : public LayeredResourceHandler,
};
DeferredStage deferred_stage_;
- ResourceDispatcherHost* host_;
+ ResourceDispatcherHostImpl* host_;
int child_id_;
int request_id_;
diff --git a/content/browser/renderer_host/x509_user_cert_resource_handler.cc b/content/browser/renderer_host/x509_user_cert_resource_handler.cc
index 046453e..90c8bca 100644
--- a/content/browser/renderer_host/x509_user_cert_resource_handler.cc
+++ b/content/browser/renderer_host/x509_user_cert_resource_handler.cc
@@ -6,7 +6,6 @@
#include "base/string_util.h"
#include "content/browser/download/download_types.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/resource_response.h"
@@ -19,10 +18,10 @@
#include "net/url_request/url_request_status.h"
X509UserCertResourceHandler::X509UserCertResourceHandler(
- ResourceDispatcherHost* host, net::URLRequest* request,
- int render_process_host_id, int render_view_id)
- : host_(host),
- request_(request),
+ net::URLRequest* request,
+ int render_process_host_id,
+ int render_view_id)
+ : request_(request),
content_length_(0),
read_buffer_(NULL),
resource_buffer_(NULL),
diff --git a/content/browser/renderer_host/x509_user_cert_resource_handler.h b/content/browser/renderer_host/x509_user_cert_resource_handler.h
index 30ef0d1..3c19a7d 100644
--- a/content/browser/renderer_host/x509_user_cert_resource_handler.h
+++ b/content/browser/renderer_host/x509_user_cert_resource_handler.h
@@ -13,8 +13,6 @@
#include "content/browser/renderer_host/resource_handler.h"
#include "googleurl/src/gurl.h"
-class ResourceDispatcherHost;
-
namespace net {
class IOBuffer;
class URLRequest;
@@ -27,8 +25,7 @@ class URLRequestStatus;
class X509UserCertResourceHandler : public ResourceHandler {
public:
- X509UserCertResourceHandler(ResourceDispatcherHost* host,
- net::URLRequest* request,
+ X509UserCertResourceHandler(net::URLRequest* request,
int render_process_host_id,
int render_view_id);
@@ -74,7 +71,6 @@ class X509UserCertResourceHandler : public ResourceHandler {
void AssembleResource();
GURL url_;
- ResourceDispatcherHost* host_;
net::URLRequest* request_;
size_t content_length_;
content::ContentVector buffer_;
diff --git a/content/browser/ssl/ssl_cert_error_handler.cc b/content/browser/ssl/ssl_cert_error_handler.cc
index 3e3414b..496ac43 100644
--- a/content/browser/ssl/ssl_cert_error_handler.cc
+++ b/content/browser/ssl/ssl_cert_error_handler.cc
@@ -1,21 +1,23 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/ssl/ssl_cert_error_handler.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/ssl/ssl_policy.h"
#include "net/base/cert_status_flags.h"
#include "net/base/x509_certificate.h"
+using content::ResourceDispatcherHostImpl;
+
SSLCertErrorHandler::SSLCertErrorHandler(
- ResourceDispatcherHost* rdh,
+ ResourceDispatcherHostImpl* host,
net::URLRequest* request,
ResourceType::Type resource_type,
const net::SSLInfo& ssl_info,
bool fatal)
- : SSLErrorHandler(rdh, request, resource_type),
+ : SSLErrorHandler(host, request, resource_type),
ssl_info_(ssl_info),
cert_error_(net::MapCertStatusToNetError(ssl_info.cert_status)),
fatal_(fatal) {
diff --git a/content/browser/ssl/ssl_cert_error_handler.h b/content/browser/ssl/ssl_cert_error_handler.h
index e2ce1f0..0f095a9 100644
--- a/content/browser/ssl/ssl_cert_error_handler.h
+++ b/content/browser/ssl/ssl_cert_error_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -17,7 +17,7 @@
class SSLCertErrorHandler : public SSLErrorHandler {
public:
// Construct on the IO thread.
- SSLCertErrorHandler(ResourceDispatcherHost* rdh,
+ SSLCertErrorHandler(content::ResourceDispatcherHostImpl* host,
net::URLRequest* request,
ResourceType::Type resource_type,
const net::SSLInfo& ssl_info,
diff --git a/content/browser/ssl/ssl_client_auth_handler.cc b/content/browser/ssl/ssl_client_auth_handler.cc
index 11a43ba..9572d80 100644
--- a/content/browser/ssl/ssl_client_auth_handler.cc
+++ b/content/browser/ssl/ssl_client_auth_handler.cc
@@ -5,7 +5,6 @@
#include "content/browser/ssl/ssl_client_auth_handler.h"
#include "base/bind.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
@@ -15,6 +14,7 @@
#include "net/url_request/url_request_context.h"
using content::BrowserThread;
+using content::ResourceRequestInfo;
using content::ResourceRequestInfoImpl;
SSLClientAuthHandler::SSLClientAuthHandler(
@@ -38,12 +38,13 @@ void SSLClientAuthHandler::OnRequestCancelled() {
void SSLClientAuthHandler::SelectCertificate() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(request_);
int render_process_host_id;
int render_view_host_id;
- if (!ResourceDispatcherHost::RenderViewForRequest(request_,
- &render_process_host_id,
- &render_view_host_id))
+ if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderView(
+ &render_process_host_id,
+ &render_view_host_id))
NOTREACHED();
// If the RVH does not exist by the time this task gets run, then the task
@@ -78,7 +79,7 @@ void SSLClientAuthHandler::DoCertificateSelected(net::X509Certificate* cert) {
request_->ContinueWithCertificate(cert);
ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request_);
+ ResourceRequestInfoImpl::ForRequest(request_);
if (info)
info->set_ssl_client_auth_handler(NULL);
diff --git a/content/browser/ssl/ssl_error_handler.cc b/content/browser/ssl/ssl_error_handler.cc
index 0632193..d818052 100644
--- a/content/browser/ssl/ssl_error_handler.cc
+++ b/content/browser/ssl/ssl_error_handler.cc
@@ -6,33 +6,33 @@
#include "base/bind.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
-#include "content/browser/renderer_host/resource_request_info_impl.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/ssl/ssl_cert_error_handler.h"
#include "content/browser/tab_contents/navigation_controller_impl.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_request_info.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
using content::BrowserThread;
using content::RenderViewHostImpl;
-using content::ResourceRequestInfoImpl;
+using content::ResourceDispatcherHostImpl;
+using content::ResourceRequestInfo;
using content::WebContents;
-SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHost* rdh,
+SSLErrorHandler::SSLErrorHandler(ResourceDispatcherHostImpl* host,
net::URLRequest* request,
ResourceType::Type resource_type)
: manager_(NULL),
request_id_(0, 0),
- resource_dispatcher_host_(rdh),
+ resource_dispatcher_host_(host),
request_url_(request->url()),
resource_type_(resource_type),
request_has_been_notified_(false) {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
- ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
+ const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
request_id_.child_id = info->GetChildID();
request_id_.request_id = info->GetRequestID();
diff --git a/content/browser/ssl/ssl_error_handler.h b/content/browser/ssl/ssl_error_handler.h
index 848b9d3..eadf89b 100644
--- a/content/browser/ssl/ssl_error_handler.h
+++ b/content/browser/ssl/ssl_error_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,9 +16,12 @@
#include "googleurl/src/gurl.h"
#include "webkit/glue/resource_type.h"
-class ResourceDispatcherHost;
class SSLCertErrorHandler;
+namespace content {
+class ResourceDispatcherHostImpl;
+}
+
namespace net {
class URLRequest;
} // namespace net
@@ -83,7 +86,7 @@ class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
friend class base::RefCountedThreadSafe<SSLErrorHandler>;
// Construct on the IO thread.
- SSLErrorHandler(ResourceDispatcherHost* resource_dispatcher_host,
+ SSLErrorHandler(content::ResourceDispatcherHostImpl* host,
net::URLRequest* request,
ResourceType::Type resource_type);
@@ -102,8 +105,8 @@ class SSLErrorHandler : public base::RefCountedThreadSafe<SSLErrorHandler> {
// Should only be accessed from the IO thread.
content::GlobalRequestID request_id_;
- // The ResourceDispatcherHost we are associated with.
- ResourceDispatcherHost* resource_dispatcher_host_;
+ // The ResourceDispatcherHostImpl we are associated with.
+ content::ResourceDispatcherHostImpl* resource_dispatcher_host_;
private:
// Completes the CancelRequest operation on the IO thread.
diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc
index a6635f4..b4aa8cc 100644
--- a/content/browser/ssl/ssl_manager.cc
+++ b/content/browser/ssl/ssl_manager.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/utf_string_conversions.h"
#include "content/browser/load_from_memory_cache_details.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/resource_request_details.h"
#include "content/browser/renderer_host/resource_request_info_impl.h"
#include "content/browser/ssl/ssl_cert_error_handler.h"
@@ -22,18 +22,19 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/common/ssl_status.h"
+#include "net/url_request/url_request.h"
using content::BrowserThread;
using content::NavigationController;
using content::NavigationEntry;
using content::NavigationEntryImpl;
+using content::ResourceDispatcherHostImpl;
using content::ResourceRequestInfoImpl;
using content::SSLStatus;
using content::WebContents;
// static
-void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
- net::URLRequest* request,
+void SSLManager::OnSSLCertificateError(net::URLRequest* request,
const net::SSLInfo& ssl_info,
bool fatal) {
DVLOG(1) << "OnSSLCertificateError() cert_error: "
@@ -41,15 +42,15 @@ void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
<< " url: " << request->url().spec()
<< " cert_status: " << std::hex << ssl_info.cert_status;
- ResourceRequestInfoImpl* info =
- ResourceDispatcherHost::InfoForRequest(request);
+ const ResourceRequestInfoImpl* info =
+ ResourceRequestInfoImpl::ForRequest(request);
// A certificate error occurred. Construct a SSLCertErrorHandler object and
// hand it over to the UI thread for processing.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&SSLCertErrorHandler::Dispatch,
- new SSLCertErrorHandler(rdh,
+ new SSLCertErrorHandler(ResourceDispatcherHostImpl::Get(),
request,
info->GetResourceType(),
ssl_info,
diff --git a/content/browser/ssl/ssl_manager.h b/content/browser/ssl/ssl_manager.h
index 70cd067..db2b65d 100644
--- a/content/browser/ssl/ssl_manager.h
+++ b/content/browser/ssl/ssl_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -20,7 +20,6 @@
class LoadFromMemoryCacheDetails;
class NavigationControllerImpl;
-class ResourceDispatcherHost;
class ResourceRedirectDetails;
class ResourceRequestDetails;
class SSLPolicy;
@@ -50,8 +49,7 @@ class SSLManager : public content::NotificationObserver {
// |ContinueDespiteLastError| on the net::URLRequest.
//
// Called on the IO thread.
- static void OnSSLCertificateError(ResourceDispatcherHost* resource_dispatcher,
- net::URLRequest* request,
+ static void OnSSLCertificateError(net::URLRequest* request,
const net::SSLInfo& ssl_info,
bool fatal);
diff --git a/content/browser/tab_contents/interstitial_page_impl.cc b/content/browser/tab_contents/interstitial_page_impl.cc
index a01cbf5..9186bc3 100644
--- a/content/browser/tab_contents/interstitial_page_impl.cc
+++ b/content/browser/tab_contents/interstitial_page_impl.cc
@@ -14,7 +14,7 @@
#include "base/utf_string_conversions.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/tab_contents/navigation_controller_impl.h"
#include "content/browser/tab_contents/navigation_entry_impl.h"
@@ -48,6 +48,7 @@ using content::RenderWidgetHost;
using content::RenderWidgetHostImpl;
using content::RenderWidgetHostView;
using content::RenderWidgetHostViewPort;
+using content::ResourceDispatcherHostImpl;
using content::SiteInstance;
using content::WebContents;
using content::WebContentsView;
@@ -56,22 +57,19 @@ using WebKit::WebDragOperationsMask;
namespace {
-void ResourceRequestHelper(ResourceDispatcherHost* resource_dispatcher_host,
+void ResourceRequestHelper(ResourceDispatcherHostImpl* rdh,
int process_id,
int render_view_host_id,
ResourceRequestAction action) {
switch (action) {
case BLOCK:
- resource_dispatcher_host->BlockRequestsForRoute(
- process_id, render_view_host_id);
+ rdh->BlockRequestsForRoute(process_id, render_view_host_id);
break;
case RESUME:
- resource_dispatcher_host->ResumeBlockedRequestsForRoute(
- process_id, render_view_host_id);
+ rdh->ResumeBlockedRequestsForRoute(process_id, render_view_host_id);
break;
case CANCEL:
- resource_dispatcher_host->CancelBlockedRequestsForRoute(
- process_id, render_view_host_id);
+ rdh->CancelBlockedRequestsForRoute(process_id, render_view_host_id);
break;
default:
NOTREACHED();
@@ -649,11 +647,11 @@ void InterstitialPageImpl::TakeActionOnResourceDispatcher(
// The tab might not have a render_view_host if it was closed (in which case,
// we have taken care of the blocked requests when processing
// NOTIFY_RENDER_WIDGET_HOST_DESTROYED.
- // Also we need to test there is a ResourceDispatcherHost, as when unit-tests
- // we don't have one.
+ // Also we need to test there is a ResourceDispatcherHostImpl, as when unit-
+ // tests we don't have one.
RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(original_child_id_,
original_rvh_id_);
- if (!rvh || !ResourceDispatcherHost::Get())
+ if (!rvh || !ResourceDispatcherHostImpl::Get())
return;
BrowserThread::PostTask(
@@ -661,7 +659,7 @@ void InterstitialPageImpl::TakeActionOnResourceDispatcher(
FROM_HERE,
base::Bind(
&ResourceRequestHelper,
- ResourceDispatcherHost::Get(),
+ ResourceDispatcherHostImpl::Get(),
original_child_id_,
original_rvh_id_,
action));
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index ee37026..1bc7503 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -27,7 +27,7 @@
#include "content/browser/load_from_memory_cache_details.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/resource_request_details.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/tab_contents/interstitial_page_impl.h"
@@ -130,6 +130,7 @@ using content::RenderViewHostImpl;
using content::RenderWidgetHost;
using content::RenderWidgetHostView;
using content::RenderWidgetHostViewPort;
+using content::ResourceDispatcherHostImpl;
using content::SessionStorageNamespace;
using content::SiteInstance;
using content::SSLStatus;
@@ -2316,7 +2317,7 @@ void TabContents::OnUserGesture() {
// Notify observers.
FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture());
- ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
+ ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
if (rdh) // NULL in unittests.
rdh->OnUserGesture(this);
}
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 1a83ae3..2076bf5 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -109,6 +109,7 @@
'public/browser/render_widget_host_view.h',
'public/browser/render_widget_host_view_mac_delegate.h',
'public/browser/resource_context.h',
+ 'public/browser/resource_dispatcher_host.h',
'public/browser/resource_dispatcher_host_delegate.cc',
'public/browser/resource_dispatcher_host_delegate.h',
'public/browser/resource_dispatcher_host_login_delegate.h',
@@ -561,8 +562,8 @@
'browser/renderer_host/render_widget_host_view_mac_editcommand_helper.mm',
'browser/renderer_host/render_widget_host_view_win.cc',
'browser/renderer_host/render_widget_host_view_win.h',
- 'browser/renderer_host/resource_dispatcher_host.cc',
- 'browser/renderer_host/resource_dispatcher_host.h',
+ 'browser/renderer_host/resource_dispatcher_host_impl.cc',
+ 'browser/renderer_host/resource_dispatcher_host_impl.h',
'browser/renderer_host/resource_handler.h',
'browser/renderer_host/resource_message_filter.cc',
'browser/renderer_host/resource_message_filter.h',
diff --git a/content/public/browser/resource_dispatcher_host.h b/content/public/browser/resource_dispatcher_host.h
new file mode 100644
index 0000000..efb6df5
--- /dev/null
+++ b/content/public/browser/resource_dispatcher_host.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_
+#define CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_
+#pragma once
+
+#include "base/callback_forward.h"
+#include "content/public/browser/download_id.h"
+#include "net/base/net_errors.h"
+
+struct DownloadSaveInfo;
+
+namespace net {
+class URLRequest;
+}
+
+namespace content {
+class ResourceContext;
+class ResourceDispatcherHostDelegate;
+
+class CONTENT_EXPORT ResourceDispatcherHost {
+ public:
+ typedef base::Callback<void(DownloadId, net::Error)> DownloadStartedCallback;
+
+ // Returns the singleton instance of the ResourceDispatcherHost.
+ static ResourceDispatcherHost* Get();
+
+ // This does not take ownership of the delegate. It is expected that the
+ // delegate have a longer lifetime than the ResourceDispatcherHost.
+ virtual void SetDelegate(ResourceDispatcherHostDelegate* delegate) = 0;
+
+ // Controls whether third-party sub-content can pop-up HTTP basic auth
+ // dialog boxes.
+ virtual void SetAllowCrossOriginAuthPrompt(bool value) = 0;
+
+ // Force cancels any pending requests for the given |context|. This is
+ // necessary to ensure that before |context| goes away, all requests
+ // for it are dead.
+ virtual void CancelRequestsForContext(ResourceContext* context) = 0;
+
+ // Initiates a download by explicit request of the renderer, e.g. due to
+ // alt-clicking a link. If the download is started, |started_callback| will
+ // be called on the UI thread with the DownloadId; otherwise an error code
+ // will be returned.
+ virtual net::Error BeginDownload(
+ scoped_ptr<net::URLRequest> request,
+ ResourceContext* context,
+ int child_id,
+ int route_id,
+ bool prefer_cache,
+ const DownloadSaveInfo& save_info,
+ const DownloadStartedCallback& started_callback) = 0;
+
+ // Clears the ResourceDispatcherHostLoginDelegate associated with the request.
+ virtual void ClearLoginDelegateForRequest(net::URLRequest* request) = 0;
+
+ // Marks the request as "parked". This happens if a request is
+ // redirected cross-site and needs to be resumed by a new render view.
+ virtual void MarkAsTransferredNavigation(net::URLRequest* request) = 0;
+
+ protected:
+ virtual ~ResourceDispatcherHost() {}
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_BROWSER_RESOURCE_DISPATCHER_HOST_H_
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 3875efd..c02c7a3 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -34,7 +34,6 @@ class FilePath;
class AutoUpdateInterceptor;
class ChildProcessSecurityPolicyTest;
class ComponentUpdateInterceptor;
-class ResourceDispatcherHostTest;
class TestAutomationProvider;
class URLRequestAutomationJob;
class UserScriptListenerTest;
@@ -49,6 +48,12 @@ class AppCacheURLRequestJobTest;
// Temporary layering violation to allow existing users of a deprecated
// interface.
+namespace content {
+class ResourceDispatcherHostTest;
+}
+
+// Temporary layering violation to allow existing users of a deprecated
+// interface.
namespace fileapi {
class FileSystemDirURLRequestJobTest;
class FileSystemOperationWriteTest;
@@ -155,7 +160,6 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
friend class ::AutoUpdateInterceptor;
friend class ::ChildProcessSecurityPolicyTest;
friend class ::ComponentUpdateInterceptor;
- friend class ::ResourceDispatcherHostTest;
friend class ::TestAutomationProvider;
friend class ::UserScriptListenerTest;
friend class ::URLRequestAutomationJob;
@@ -164,6 +168,7 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
friend class appcache::AppCacheInterceptor;
friend class appcache::AppCacheRequestHandlerTest;
friend class appcache::AppCacheURLRequestJobTest;
+ friend class content::ResourceDispatcherHostTest;
friend class fileapi::FileSystemDirURLRequestJobTest;
friend class fileapi::FileSystemOperationWriteTest;
friend class fileapi::FileSystemURLRequestJobTest;