diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 00:46:33 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 00:46:33 +0000 |
commit | 46b0d4aacbf25108badc143e09f91064fc0b0472 (patch) | |
tree | d1ec74ba60c5c7ae6fd683ad7b685095434e6f03 /chrome | |
parent | 08ae5f310a475f73807df520fa0b50cf7138c4f5 (diff) | |
download | chromium_src-46b0d4aacbf25108badc143e09f91064fc0b0472.zip chromium_src-46b0d4aacbf25108badc143e09f91064fc0b0472.tar.gz chromium_src-46b0d4aacbf25108badc143e09f91064fc0b0472.tar.bz2 |
Add a CreateBridge method to the ChildThread.
The intent is to allow unit-tests that use render view
to override ChildThread::CreateBridge() to provide their
own resource loading.
This is used by the upcoming translate unit-test.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/503032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35014 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/child_thread.cc | 9 | ||||
-rw-r--r-- | chrome/common/child_thread.h | 7 | ||||
-rw-r--r-- | chrome/common/resource_dispatcher.cc | 82 | ||||
-rw-r--r-- | chrome/common/resource_dispatcher.h | 19 | ||||
-rw-r--r-- | chrome/common/resource_dispatcher_unittest.cc | 20 | ||||
-rw-r--r-- | chrome/plugin/chrome_plugin_host.cc | 29 | ||||
-rw-r--r-- | chrome/renderer/renderer_glue.cc | 19 |
7 files changed, 72 insertions, 113 deletions
diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc index cb145ae..e973554 100644 --- a/chrome/common/child_thread.cc +++ b/chrome/common/child_thread.cc @@ -95,6 +95,15 @@ void ChildThread::RemoveRoute(int32 routing_id) { router_.RemoveRoute(routing_id); } +webkit_glue::ResourceLoaderBridge* ChildThread::CreateBridge( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, + int host_renderer_id, + int host_render_view_id) { + return resource_dispatcher()-> + CreateBridge(request_info, host_renderer_id, host_render_view_id); +} + + void ChildThread::OnMessageReceived(const IPC::Message& msg) { // Resource responses are sent to the resource dispatcher. if (resource_dispatcher_->OnMessageReceived(msg)) diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h index 63464fe..c731b45 100644 --- a/chrome/common/child_thread.h +++ b/chrome/common/child_thread.h @@ -32,6 +32,13 @@ class ChildThread : public IPC::Channel::Listener, void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); void RemoveRoute(int32 routing_id); + // Creates a ResourceLoaderBridge. + // Tests can override this method if they want a custom loading behavior. + virtual webkit_glue::ResourceLoaderBridge* CreateBridge( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, + int host_renderer_id, + int host_render_view_id); + ResourceDispatcher* resource_dispatcher() { return resource_dispatcher_.get(); } diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc index 5639f77..8eb74a5 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -44,21 +44,9 @@ namespace webkit_glue { class IPCResourceLoaderBridge : public ResourceLoaderBridge { public: IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, - const std::string& method, - const GURL& url, - const GURL& first_party_for_cookies, - const GURL& referrer, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& headers, - int load_flags, - int origin_pid, - ResourceType::Type resource_type, - uint32 request_context, - int appcache_host_id, - int routing_id, - int host_renderer_id, - int host_render_view_id); + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, + int host_renderer_id, + int host_render_view_id); virtual ~IPCResourceLoaderBridge(); // ResourceLoaderBridge @@ -109,40 +97,28 @@ class IPCResourceLoaderBridge : public ResourceLoaderBridge { IPCResourceLoaderBridge::IPCResourceLoaderBridge( ResourceDispatcher* dispatcher, - const std::string& method, - const GURL& url, - const GURL& first_party_for_cookies, - const GURL& referrer, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& headers, - int load_flags, - int origin_child_id, - ResourceType::Type resource_type, - uint32 request_context, - int appcache_host_id, - int routing_id, + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, int host_renderer_id, int host_render_view_id) : peer_(NULL), dispatcher_(dispatcher), request_id_(-1), - routing_id_(routing_id), + routing_id_(request_info.routing_id), host_renderer_id_(host_renderer_id), host_render_view_id_(host_render_view_id) { DCHECK(dispatcher_) << "no resource dispatcher"; - request_.method = method; - request_.url = url; - request_.first_party_for_cookies = first_party_for_cookies; - request_.referrer = referrer; - request_.frame_origin = frame_origin; - request_.main_frame_origin = main_frame_origin; - request_.headers = headers; - request_.load_flags = load_flags; - request_.origin_child_id = origin_child_id; - request_.resource_type = resource_type; - request_.request_context = request_context; - request_.appcache_host_id = appcache_host_id; + request_.method = request_info.method; + request_.url = request_info.url; + request_.first_party_for_cookies = request_info.first_party_for_cookies; + request_.referrer = request_info.referrer; + request_.frame_origin = request_info.frame_origin; + request_.main_frame_origin = request_info.main_frame_origin; + request_.headers = request_info.headers; + request_.load_flags = request_info.load_flags; + request_.origin_child_id = request_info.requestor_pid; + request_.resource_type = request_info.request_type; + request_.request_context = request_info.request_context; + request_.appcache_host_id = request_info.appcache_host_id; request_.host_renderer_id = host_renderer_id_; request_.host_render_view_id = host_render_view_id_; @@ -577,30 +553,10 @@ void ResourceDispatcher::FlushDeferredMessages(int request_id) { } webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( - const std::string& method, - const GURL& url, - const GURL& first_party_for_cookies, - const GURL& referrer, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& headers, - int flags, - int origin_pid, - ResourceType::Type resource_type, - uint32 request_context, - int appcache_host_id, - int route_id, + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, int host_renderer_id, int host_render_view_id) { - return new webkit_glue::IPCResourceLoaderBridge(this, method, url, - first_party_for_cookies, - referrer, frame_origin, - main_frame_origin, headers, - flags, origin_pid, - resource_type, - request_context, - appcache_host_id, - route_id, + return new webkit_glue::IPCResourceLoaderBridge(this, request_info, host_renderer_id, host_render_view_id); } diff --git a/chrome/common/resource_dispatcher.h b/chrome/common/resource_dispatcher.h index 7a93024..1d3f25a 100644 --- a/chrome/common/resource_dispatcher.h +++ b/chrome/common/resource_dispatcher.h @@ -34,21 +34,10 @@ class ResourceDispatcher { // Creates a ResourceLoaderBridge for this type of dispatcher, this is so // this can be tested regardless of the ResourceLoaderBridge::Create // implementation. - webkit_glue::ResourceLoaderBridge* CreateBridge(const std::string& method, - const GURL& url, - const GURL& first_party_for_cookies, - const GURL& referrer, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& headers, - int load_flags, - int origin_pid, - ResourceType::Type resource_type, - uint32 request_context /* used for plugin->browser requests */, - int appcache_host_id, - int routing_id, - int host_renderer_id, - int host_render_view_id); + webkit_glue::ResourceLoaderBridge* CreateBridge( + const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, + int host_renderer_id, + int host_render_view_id); // Adds a request from the pending_requests_ list, returning the new // requests' ID diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index 67b9351..bf2ec19 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -148,11 +148,21 @@ class ResourceDispatcherTest : public testing::Test, } ResourceLoaderBridge* CreateBridge() { - ResourceLoaderBridge* bridge = dispatcher_->CreateBridge( - "GET", GURL(test_page_url), GURL(test_page_url), GURL(), "null", - "null", std::string(), 0, 0, ResourceType::SUB_RESOURCE, 0, - appcache::kNoHostId, MSG_ROUTING_CONTROL, -1, -1); - return bridge; + webkit_glue::ResourceLoaderBridge::RequestInfo request_info; + request_info.method = "GET"; + request_info.url = GURL(test_page_url); + request_info.first_party_for_cookies = GURL(test_page_url); + request_info.referrer = GURL(); + request_info.frame_origin = "null"; + request_info.main_frame_origin = "null"; + request_info.headers = std::string(); + request_info.load_flags = 0; + request_info.requestor_pid = 0; + request_info.request_type = ResourceType::SUB_RESOURCE; + request_info.appcache_host_id = 0; + request_info.routing_id = appcache::kNoHostId; + + return dispatcher_->CreateBridge(request_info, -1, -1); } std::vector<IPC::Message> message_queue_; diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index 4e3a8cb..ab459f4 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -151,21 +151,24 @@ class PluginRequestHandlerProxy } CPError Start(int renderer_id, int render_view_id) { + webkit_glue::ResourceLoaderBridge::RequestInfo request_info; + request_info.method = cprequest_->method; + request_info.url = GURL(cprequest_->url); + request_info.first_party_for_cookies = + GURL(cprequest_->url); // TODO(jackson): policy url? + request_info.referrer = GURL(); // TODO(mpcomplete): referrer? + request_info.frame_origin = "null"; + request_info.main_frame_origin = "null"; + request_info.headers = extra_headers_; + request_info.load_flags = load_flags_; + request_info.requestor_pid = base::GetCurrentProcId(); + request_info.request_type = ResourceType::OBJECT; + request_info.request_context = cprequest_->context; + request_info.appcache_host_id = appcache::kNoHostId; + request_info.routing_id = MSG_ROUTING_CONTROL; bridge_.reset( PluginThread::current()->resource_dispatcher()->CreateBridge( - cprequest_->method, - GURL(cprequest_->url), - GURL(cprequest_->url), // TODO(jackson): policy url? - GURL(), // TODO(mpcomplete): referrer? - "null", // frame_origin - "null", // main_frame_origin - extra_headers_, - load_flags_, - base::GetCurrentProcId(), - ResourceType::OBJECT, - cprequest_->context, - appcache::kNoHostId, - MSG_ROUTING_CONTROL, + request_info, renderer_id, render_view_id)); if (!bridge_.get()) diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 012a249..1f306db 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -218,23 +218,8 @@ bool IsProtocolSupportedForMedia(const GURL& url) { // static factory function ResourceLoaderBridge* ResourceLoaderBridge::Create( - const std::string& method, - const GURL& url, - const GURL& first_party_for_cookies, - const GURL& referrer, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& headers, - int load_flags, - int origin_pid, - ResourceType::Type resource_type, - int appcache_host_id, - int routing_id) { - ResourceDispatcher* dispatch = ChildThread::current()->resource_dispatcher(); - return dispatch->CreateBridge(method, url, first_party_for_cookies, referrer, - frame_origin, main_frame_origin, headers, - load_flags, origin_pid, resource_type, 0, - appcache_host_id, routing_id, -1 , -1); + const ResourceLoaderBridge::RequestInfo& request_info) { + return ChildThread::current()->CreateBridge(request_info, -1, -1); } // static factory function |