diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-10 22:44:13 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-10 22:44:13 +0000 |
commit | ad15f9e53eb8173ce3e4af4d6c6685979b4b9338 (patch) | |
tree | 82c5816c2ec9448921402b5366c6ef5d35f8eff3 /chrome | |
parent | 8db216ee756d4e06fbd05676b045784da3a5928c (diff) | |
download | chromium_src-ad15f9e53eb8173ce3e4af4d6c6685979b4b9338.zip chromium_src-ad15f9e53eb8173ce3e4af4d6c6685979b4b9338.tar.gz chromium_src-ad15f9e53eb8173ce3e4af4d6c6685979b4b9338.tar.bz2 |
A little cleanup of ResourceDispatcherHost to make it less renderer centric, since it's used by plugin and worker processes.
Review URL: http://codereview.chromium.org/43001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11393 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
11 files changed, 264 insertions, 282 deletions
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 25761f8..1ac8c73 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -370,9 +370,7 @@ PluginProcessHost::PluginProcessHost(MessageLoop* main_message_loop) } PluginProcessHost::~PluginProcessHost() { - // Cancel all requests for plugin processes. - // TODO(mpcomplete): use a real process ID when http://b/issue?id=1210062 is - // fixed. + // Cancel all requests for plugin process. PluginService::GetInstance()->resource_dispatcher_host()-> CancelRequestsForProcess(-1); @@ -612,10 +610,6 @@ void PluginProcessHost::OnRequestResource( const IPC::Message& message, int request_id, const ViewHostMsg_Resource_Request& request) { - // TODO(mpcomplete): we need a "process_id" mostly for a unique identifier. - // We should decouple the idea of a render_process_host_id from the unique ID - // in ResourceDispatcherHost. - int render_process_host_id = -1; URLRequestContext* context = CPBrowsingContextManager::Instance()-> ToURLRequestContext(request.request_context); // TODO(mpcomplete): remove fallback case when Gears support is prevalent. @@ -623,33 +617,30 @@ void PluginProcessHost::OnRequestResource( context = Profile::GetDefaultRequestContext(); PluginService::GetInstance()->resource_dispatcher_host()-> - BeginRequest(this, handle(), render_process_host_id, - MSG_ROUTING_CONTROL, request_id, request, context, NULL); + BeginRequest(this, ChildProcessInfo::PLUGIN_PROCESS, handle(), + -1, MSG_ROUTING_CONTROL, request_id, + request, context, NULL); } void PluginProcessHost::OnCancelRequest(int request_id) { - int render_process_host_id = -1; PluginService::GetInstance()->resource_dispatcher_host()-> - CancelRequest(render_process_host_id, request_id, true); + CancelRequest(-1, request_id, true); } void PluginProcessHost::OnDataReceivedACK(int request_id) { - int render_process_host_id = -1; PluginService::GetInstance()->resource_dispatcher_host()-> - OnDataReceivedACK(render_process_host_id, request_id); + OnDataReceivedACK(-1, request_id); } void PluginProcessHost::OnUploadProgressACK(int request_id) { - int render_process_host_id = -1; PluginService::GetInstance()->resource_dispatcher_host()-> - OnUploadProgressACK(render_process_host_id, request_id); + OnUploadProgressACK(-1, request_id); } void PluginProcessHost::OnSyncLoad( int request_id, const ViewHostMsg_Resource_Request& request, IPC::Message* sync_result) { - int render_process_host_id = -1; URLRequestContext* context = CPBrowsingContextManager::Instance()-> ToURLRequestContext(request.request_context); // TODO(mpcomplete): remove fallback case when Gears support is prevalent. @@ -657,9 +648,9 @@ void PluginProcessHost::OnSyncLoad( context = Profile::GetDefaultRequestContext(); PluginService::GetInstance()->resource_dispatcher_host()-> - BeginRequest(this, handle(), render_process_host_id, - MSG_ROUTING_CONTROL, request_id, request, context, - sync_result); + BeginRequest(this, ChildProcessInfo::PLUGIN_PROCESS, handle(), + -1, MSG_ROUTING_CONTROL, request_id, + request, context, sync_result); } void PluginProcessHost::OnGetCookies(uint32 request_context, diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc index c49666c7..e8a86ee 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.cc +++ b/chrome/browser/renderer_host/buffered_resource_handler.cc @@ -254,8 +254,8 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id, new DownloadThrottlingResourceHandler(host_, request_, request_->url(), - info->render_process_host_id, - info->render_view_id, + info->process_id, + info->route_id, request_id, in_complete); if (bytes_read_) { diff --git a/chrome/browser/renderer_host/download_resource_handler.cc b/chrome/browser/renderer_host/download_resource_handler.cc index 2187506..bef9a2e 100644 --- a/chrome/browser/renderer_host/download_resource_handler.cc +++ b/chrome/browser/renderer_host/download_resource_handler.cc @@ -56,7 +56,7 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, info->total_bytes = content_length_; info->state = DownloadItem::IN_PROGRESS; info->download_id = download_id_; - info->render_process_id = global_id_.render_process_host_id; + info->render_process_id = global_id_.process_id; info->render_view_id = render_view_id_; info->request_id = global_id_.request_id; info->content_disposition = content_disposition_; @@ -158,7 +158,7 @@ void DownloadResourceHandler::CheckWriteProgress() { StartPauseTimer(); if (is_paused_ != should_pause) { - rdh_->PauseRequest(global_id_.render_process_host_id, + rdh_->PauseRequest(global_id_.process_id, global_id_.request_id, should_pause); is_paused_ = should_pause; diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc index eabfe58..561ef18 100644 --- a/chrome/browser/renderer_host/render_widget_helper.cc +++ b/chrome/browser/renderer_host/render_widget_helper.cc @@ -184,7 +184,7 @@ void RenderWidgetHelper::OnDispatchPaintMsg(PaintMsgProxy* proxy) { void RenderWidgetHelper::OnCancelResourceRequests( int render_widget_id) { - resource_dispatcher_host_->CancelRequestsForRenderView( + resource_dispatcher_host_->CancelRequestsForRoute( render_process_id_, render_widget_id); } @@ -227,7 +227,7 @@ void RenderWidgetHelper::CreateNewWindow(int opener_id, // Block resource requests until the view is created, since the HWND might be // needed if a response ends up creating a plugin. - resource_dispatcher_host_->BlockRequestsForRenderView( + resource_dispatcher_host_->BlockRequestsForRoute( render_process_id_, *route_id); // The easiest way to reach RenderViewHost is just to send a routed message. @@ -249,7 +249,7 @@ void RenderWidgetHelper::OnCreateWindowOnUI( } void RenderWidgetHelper::OnCreateWindowOnIO(int route_id) { - resource_dispatcher_host_->ResumeBlockedRequestsForRenderView( + resource_dispatcher_host_->ResumeBlockedRequestsForRoute( render_process_id_, route_id); } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 750fa33..b4535ca 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -98,16 +98,16 @@ namespace { // ResourceDispatcherHost should service this request. A request might be // disallowed if the renderer is not authorized to restrive the request URL or // if the renderer is attempting to upload an unauthorized file. -bool ShouldServiceRequest(int render_process_host_id, +bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, + int process_id, const ViewHostMsg_Resource_Request& request_data) { - // TODO(mpcomplete): remove this when http://b/viewIssue?id=1080959 is fixed. - if (render_process_host_id == -1) + if (process_type != ChildProcessInfo::RENDER_PROCESS) return true; RendererSecurityPolicy* policy = RendererSecurityPolicy::GetInstance(); // Check if the renderer is permitted to request the requested URL. - if (!policy->CanRequestURL(render_process_host_id, request_data.url)) { + if (!policy->CanRequestURL(process_id, request_data.url)) { LOG(INFO) << "Denied unauthorized request for " << request_data.url.possibly_invalid_spec(); return false; @@ -119,7 +119,7 @@ bool ShouldServiceRequest(int render_process_host_id, std::vector<net::UploadData::Element>::const_iterator iter; for (iter = uploads.begin(); iter != uploads.end(); ++iter) { if (iter->type() == net::UploadData::TYPE_FILE && - !policy->CanUploadFile(render_process_host_id, iter->file_path())) { + !policy->CanUploadFile(process_id, iter->file_path())) { NOTREACHED() << "Denied unauthorized upload of " << iter->file_path(); return false; } @@ -153,19 +153,19 @@ ResourceDispatcherHost::~ResourceDispatcherHost() { // Clear blocked requests if any left. // Note that we have to do this in 2 passes as we cannot call - // CancelBlockedRequestsForRenderView while iterating over + // CancelBlockedRequestsForRoute while iterating over // blocked_requests_map_, as it modifies it. - std::set<ProcessRendererIDs> ids; + std::set<ProcessRouteIDs> ids; for (BlockedRequestMap::const_iterator iter = blocked_requests_map_.begin(); iter != blocked_requests_map_.end(); ++iter) { - std::pair<std::set<ProcessRendererIDs>::iterator, bool> result = + std::pair<std::set<ProcessRouteIDs>::iterator, bool> result = ids.insert(iter->first); // We should not have duplicates. DCHECK(result.second); } - for (std::set<ProcessRendererIDs>::const_iterator iter = ids.begin(); + for (std::set<ProcessRouteIDs>::const_iterator iter = ids.begin(); iter != ids.end(); ++iter) { - CancelBlockedRequestsForRenderView(iter->first, iter->second); + CancelBlockedRequestsForRoute(iter->first, iter->second); } } @@ -191,7 +191,7 @@ void ResourceDispatcherHost::OnShutdown() { } bool ResourceDispatcherHost::HandleExternalProtocol(int request_id, - int render_process_host_id, + int process_id, int tab_contents_id, const GURL& url, ResourceType::Type type, @@ -200,8 +200,7 @@ bool ResourceDispatcherHost::HandleExternalProtocol(int request_id, return false; ui_loop_->PostTask(FROM_HERE, NewRunnableFunction( - &ExternalProtocolHandler::LaunchUrl, url, render_process_host_id, - tab_contents_id)); + &ExternalProtocolHandler::LaunchUrl, url, process_id, tab_contents_id)); handler->OnResponseCompleted(request_id, URLRequestStatus( URLRequestStatus::FAILED, @@ -212,18 +211,19 @@ bool ResourceDispatcherHost::HandleExternalProtocol(int request_id, void ResourceDispatcherHost::BeginRequest( Receiver* receiver, - base::ProcessHandle render_process_handle, - int render_process_host_id, - int render_view_id, + ChildProcessInfo::ProcessType process_type, + base::ProcessHandle process_handle, + int process_id, + int route_id, int request_id, const ViewHostMsg_Resource_Request& request_data, URLRequestContext* request_context, IPC::Message* sync_result) { if (is_shutdown_ || - !ShouldServiceRequest(render_process_host_id, request_data)) { + !ShouldServiceRequest(process_type, process_id, request_data)) { // Tell the renderer that this request was disallowed. receiver->Send(new ViewMsg_Resource_RequestComplete( - render_view_id, + route_id, request_id, URLRequestStatus(URLRequestStatus::FAILED, net::ERR_ABORTED), std::string())); // No security info needed, connection was not @@ -243,14 +243,14 @@ void ResourceDispatcherHost::BeginRequest( handler = new SyncResourceHandler(receiver, request_data.url, sync_result); } else { handler = new AsyncResourceHandler(receiver, - render_process_host_id, - render_view_id, - render_process_handle, + process_id, + route_id, + process_handle, request_data.url, this); } - if (HandleExternalProtocol(request_id, render_process_host_id, render_view_id, + if (HandleExternalProtocol(request_id, process_id, route_id, request_data.url, request_data.resource_type, handler)) { return; @@ -278,25 +278,23 @@ void ResourceDispatcherHost::BeginRequest( // Install a CrossSiteResourceHandler if this request is coming from a // RenderViewHost with a pending cross-site request. We only check this for // MAIN_FRAME requests. - // TODO(mpcomplete): remove "render_process_host_id != -1" - // when http://b/viewIssue?id=1080959 is fixed. if (request_data.resource_type == ResourceType::MAIN_FRAME && - render_process_host_id != -1 && + process_type == ChildProcessInfo::RENDER_PROCESS && Singleton<CrossSiteRequestManager>::get()-> - HasPendingCrossSiteRequest(render_process_host_id, render_view_id)) { + HasPendingCrossSiteRequest(process_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 CrossSiteResourceHandler(handler, - render_process_host_id, - render_view_id, + process_id, + route_id, this); } if (safe_browsing_->enabled() && safe_browsing_->CanCheckUrl(request_data.url)) { handler = new SafeBrowsingResourceHandler(handler, - render_process_host_id, - render_view_id, + process_id, + route_id, request_data.url, request_data.resource_type, safe_browsing_, @@ -309,9 +307,10 @@ void ResourceDispatcherHost::BeginRequest( // Make extra info and read footer (contains request ID). ExtraRequestInfo* extra_info = new ExtraRequestInfo(handler, + process_type, + process_id, + route_id, request_id, - render_process_host_id, - render_view_id, request_data.mixed_content, request_data.resource_type, upload_size); @@ -325,19 +324,15 @@ void ResourceDispatcherHost::BeginRequest( // We are explicitly forcing the download of 'url'. void ResourceDispatcherHost::BeginDownload(const GURL& url, const GURL& referrer, - int render_process_host_id, - int render_view_id, + int process_id, + int route_id, URLRequestContext* request_context) { if (is_shutdown_) return; // Check if the renderer is permitted to request the requested URL. - // - // TODO(mpcomplete): remove "render_process_host_id != -1" - // when http://b/viewIssue?id=1080959 is fixed. - if (render_process_host_id != -1 && - !RendererSecurityPolicy::GetInstance()-> - CanRequestURL(render_process_host_id, url)) { + if (!RendererSecurityPolicy::GetInstance()-> + CanRequestURL(process_id, url)) { LOG(INFO) << "Denied unauthorized download request for " << url.possibly_invalid_spec(); return; @@ -352,8 +347,8 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url, scoped_refptr<ResourceHandler> handler = new DownloadResourceHandler(this, - render_process_host_id, - render_view_id, + process_id, + route_id, request_id_, url, download_file_manager_.get(), @@ -363,8 +358,8 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url, if (safe_browsing_->enabled() && safe_browsing_->CanCheckUrl(url)) { handler = new SafeBrowsingResourceHandler(handler, - render_process_host_id, - render_view_id, + process_id, + route_id, url, ResourceType::MAIN_FRAME, safe_browsing_, @@ -382,9 +377,10 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url, ExtraRequestInfo* extra_info = new ExtraRequestInfo(handler, + ChildProcessInfo::RENDER_PROCESS, + process_id, + route_id, request_id_, - render_process_host_id, - render_view_id, false, // Downloads are not considered mixed-content ResourceType::SUB_RESOURCE, 0 /* upload_size */ ); @@ -398,8 +394,8 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url, // This function is only used for saving feature. void ResourceDispatcherHost::BeginSaveFile(const GURL& url, const GURL& referrer, - int render_process_host_id, - int render_view_id, + int process_id, + int route_id, URLRequestContext* request_context) { if (is_shutdown_) return; @@ -409,8 +405,8 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, plugin_service_->LoadChromePlugins(this); scoped_refptr<ResourceHandler> handler = - new SaveFileResourceHandler(render_process_host_id, - render_view_id, + new SaveFileResourceHandler(process_id, + route_id, url, save_file_manager_.get()); request_id_--; @@ -434,9 +430,10 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, ExtraRequestInfo* extra_info = new ExtraRequestInfo(handler, + ChildProcessInfo::RENDER_PROCESS, + process_id, + route_id, request_id_, - render_process_host_id, - render_view_id, false, ResourceType::SUB_RESOURCE, 0 /* upload_size */); @@ -448,18 +445,18 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, BeginRequestInternal(request, false); } -void ResourceDispatcherHost::CancelRequest(int render_process_host_id, +void ResourceDispatcherHost::CancelRequest(int process_id, int request_id, bool from_renderer) { - CancelRequest(render_process_host_id, request_id, from_renderer, true); + CancelRequest(process_id, request_id, from_renderer, true); } -void ResourceDispatcherHost::CancelRequest(int render_process_host_id, +void ResourceDispatcherHost::CancelRequest(int process_id, int request_id, bool from_renderer, bool allow_delete) { PendingRequestList::iterator i = pending_requests_.find( - GlobalRequestID(render_process_host_id, request_id)); + GlobalRequestID(process_id, request_id)); if (i == pending_requests_.end()) { // We probably want to remove this warning eventually, but I wanted to be // able to notice when this happens during initial development since it @@ -482,7 +479,7 @@ void ResourceDispatcherHost::CancelRequest(int render_process_host_id, // TODO: removing the request in this manner means we're not notifying // anyone. We need make sure the event handlers and others are notified // so that everything is cleaned up properly. - RemovePendingRequest(info->render_process_host_id, info->request_id); + RemovePendingRequest(info->process_id, info->request_id); } else { i->second->Cancel(); } @@ -493,10 +490,10 @@ void ResourceDispatcherHost::CancelRequest(int render_process_host_id, // that. } -void ResourceDispatcherHost::OnDataReceivedACK(int render_process_host_id, +void ResourceDispatcherHost::OnDataReceivedACK(int process_id, int request_id) { PendingRequestList::iterator i = pending_requests_.find( - GlobalRequestID(render_process_host_id, request_id)); + GlobalRequestID(process_id, request_id)); if (i == pending_requests_.end()) return; @@ -512,14 +509,14 @@ void ResourceDispatcherHost::OnDataReceivedACK(int render_process_host_id, info->pending_data_count--; // Resume the request. - PauseRequest(render_process_host_id, request_id, false); + PauseRequest(process_id, request_id, false); } } -void ResourceDispatcherHost::OnUploadProgressACK(int render_process_host_id, +void ResourceDispatcherHost::OnUploadProgressACK(int process_id, int request_id) { PendingRequestList::iterator i = pending_requests_.find( - GlobalRequestID(render_process_host_id, request_id)); + GlobalRequestID(process_id, request_id)); if (i == pending_requests_.end()) return; @@ -527,10 +524,10 @@ void ResourceDispatcherHost::OnUploadProgressACK(int render_process_host_id, info->waiting_for_upload_progress_ack = false; } -bool ResourceDispatcherHost::WillSendData(int render_process_host_id, +bool ResourceDispatcherHost::WillSendData(int process_id, int request_id) { PendingRequestList::iterator i = pending_requests_.find( - GlobalRequestID(render_process_host_id, request_id)); + GlobalRequestID(process_id, request_id)); if (i == pending_requests_.end()) { NOTREACHED() << L"WillSendData for invalid request"; return false; @@ -543,17 +540,17 @@ bool ResourceDispatcherHost::WillSendData(int render_process_host_id, // We reached the max number of data messages that can be sent to // the renderer for a given request. Pause the request and wait for // the renderer to start processing them before resuming it. - PauseRequest(render_process_host_id, request_id, true); + PauseRequest(process_id, request_id, true); return false; } return true; } -void ResourceDispatcherHost::PauseRequest(int render_process_host_id, +void ResourceDispatcherHost::PauseRequest(int process_id, int request_id, bool pause) { - GlobalRequestID global_id(render_process_host_id, request_id); + GlobalRequestID global_id(process_id, request_id); PendingRequestList::iterator i = pending_requests_.find(global_id); if (i == pending_requests_.end()) { DLOG(WARNING) << "Pausing a request that wasn't found"; @@ -581,23 +578,23 @@ void ResourceDispatcherHost::PauseRequest(int render_process_host_id, } int ResourceDispatcherHost::GetOutstandingRequestsMemoryCost( - int render_process_host_id) const { + int process_id) const { OutstandingRequestsMemoryCostMap::const_iterator entry = - outstanding_requests_memory_cost_map_.find(render_process_host_id); + outstanding_requests_memory_cost_map_.find(process_id); return (entry == outstanding_requests_memory_cost_map_.end()) ? 0 : entry->second; } -void ResourceDispatcherHost::OnClosePageACK(int render_process_host_id, +void ResourceDispatcherHost::OnClosePageACK(int process_id, int request_id) { - GlobalRequestID global_id(render_process_host_id, request_id); + GlobalRequestID global_id(process_id, request_id); PendingRequestList::iterator i = pending_requests_.find(global_id); if (i == pending_requests_.end()) { // If there are no matching pending requests, then this is not a // cross-site navigation and we are just closing the tab/browser. ui_loop_->PostTask(FROM_HERE, NewRunnableFunction( &RenderViewHost::ClosePageIgnoringUnloadEvents, - render_process_host_id, + process_id, request_id)); return; } @@ -611,14 +608,13 @@ void ResourceDispatcherHost::OnClosePageACK(int render_process_host_id, // 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 render_process_host_id) { - CancelRequestsForRenderView(render_process_host_id, -1 /* cancel all */); +void ResourceDispatcherHost::CancelRequestsForProcess(int process_id) { + CancelRequestsForRoute(process_id, -1 /* cancel all */); } -void ResourceDispatcherHost::CancelRequestsForRenderView( - int render_process_host_id, - int render_view_id) { +void ResourceDispatcherHost::CancelRequestsForRoute( + int process_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 @@ -628,12 +624,12 @@ void ResourceDispatcherHost::CancelRequestsForRenderView( std::vector<GlobalRequestID> matching_requests; for (PendingRequestList::const_iterator i = pending_requests_.begin(); i != pending_requests_.end(); ++i) { - if (i->first.render_process_host_id == render_process_host_id) { + if (i->first.process_id == process_id) { ExtraRequestInfo* info = ExtraInfoForRequest(i->second); - if (!info->is_download && (render_view_id == -1 || - render_view_id == info->render_view_id)) { + if (!info->is_download && (route_id == -1 || + route_id == info->route_id)) { matching_requests.push_back( - GlobalRequestID(render_process_host_id, i->first.request_id)); + GlobalRequestID(process_id, i->first.request_id)); } } } @@ -655,36 +651,34 @@ void ResourceDispatcherHost::CancelRequestsForRenderView( } // Now deal with blocked requests if any. - if (render_view_id != -1) { - if (blocked_requests_map_.find(std::pair<int, int>(render_process_host_id, - render_view_id)) != + if (route_id != -1) { + if (blocked_requests_map_.find(std::pair<int, int>(process_id, route_id)) != blocked_requests_map_.end()) { - CancelBlockedRequestsForRenderView(render_process_host_id, - render_view_id); + CancelBlockedRequestsForRoute(process_id, route_id); } } else { - // We have to do all render views for the process |render_process_host_id|. + // We have to do all render views for the process |process_id|. // Note that we have to do this in 2 passes as we cannot call - // CancelBlockedRequestsForRenderView while iterating over + // CancelBlockedRequestsForRoute while iterating over // blocked_requests_map_, as it modifies it. - std::set<int> render_view_ids; + std::set<int> route_ids; for (BlockedRequestMap::const_iterator iter = blocked_requests_map_.begin(); iter != blocked_requests_map_.end(); ++iter) { - if (iter->first.first == render_process_host_id) - render_view_ids.insert(iter->first.second); + if (iter->first.first == process_id) + route_ids.insert(iter->first.second); } - for (std::set<int>::const_iterator iter = render_view_ids.begin(); - iter != render_view_ids.end(); ++iter) { - CancelBlockedRequestsForRenderView(render_process_host_id, *iter); + for (std::set<int>::const_iterator iter = route_ids.begin(); + iter != route_ids.end(); ++iter) { + CancelBlockedRequestsForRoute(process_id, *iter); } } } // Cancels the request and removes it from the list. -void ResourceDispatcherHost::RemovePendingRequest(int render_process_host_id, +void ResourceDispatcherHost::RemovePendingRequest(int process_id, int request_id) { PendingRequestList::iterator i = pending_requests_.find( - GlobalRequestID(render_process_host_id, request_id)); + GlobalRequestID(process_id, request_id)); if (i == pending_requests_.end()) { NOTREACHED() << "Trying to remove a request that's not here"; return; @@ -699,7 +693,7 @@ void ResourceDispatcherHost::RemovePendingRequest( // Remove the memory credit that we added when pushing the request onto // the pending list. IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost, - info->render_process_host_id); + info->process_id); // Notify the login handler that this request object is going away. if (info && info->login_handler) @@ -722,30 +716,29 @@ void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request, DCHECK(request->status().is_success()); - // TODO(mpcomplete): remove this when http://b/viewIssue?id=1080959 is fixed. - if (info->render_process_host_id != -1 && + if (info->process_type == ChildProcessInfo::RENDER_PROCESS && !RendererSecurityPolicy::GetInstance()-> - CanRequestURL(info->render_process_host_id, new_url)) { + CanRequestURL(info->process_id, new_url)) { LOG(INFO) << "Denied unauthorized request for " << new_url.possibly_invalid_spec(); // Tell the renderer that this request was disallowed. - CancelRequest(info->render_process_host_id, info->request_id, false); + CancelRequest(info->process_id, info->request_id, false); return; } - NofityReceivedRedirect(request, info->render_process_host_id, new_url); + NofityReceivedRedirect(request, info->process_id, new_url); - if (HandleExternalProtocol(info->request_id, info->render_process_host_id, - info->render_view_id, new_url, + if (HandleExternalProtocol(info->request_id, info->process_id, + info->route_id, new_url, info->resource_type, info->resource_handler)) { // The request is complete so we can remove it. - RemovePendingRequest(info->render_process_host_id, info->request_id); + RemovePendingRequest(info->process_id, info->request_id); return; } if (!info->resource_handler->OnRequestRedirected(info->request_id, new_url)) - CancelRequest(info->render_process_host_id, info->request_id, false); + CancelRequest(info->process_id, info->request_id, false); } void ResourceDispatcherHost::OnAuthRequired( @@ -787,7 +780,7 @@ void ResourceDispatcherHost::OnResponseStarted(URLRequest* request) { MaybeUpdateUploadProgress(info, request); if (!CompleteResponseStarted(request)) { - CancelRequest(info->render_process_host_id, info->request_id, false); + CancelRequest(info->process_id, info->request_id, false); } else { // Start reading. int bytes_read = 0; @@ -822,7 +815,7 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) { int cert_id = CertStore::GetSharedInstance()->StoreCert( request->ssl_info().cert, - info->render_process_host_id); + info->process_id); int cert_status = request->ssl_info().cert_status; // EV certificate verification could be expensive. We don't want to spend // time performing EV certificate verification on all resources because @@ -844,16 +837,16 @@ bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) { request->ssl_info().security_bits == 0)); } - NotifyResponseStarted(request, info->render_process_host_id); + NotifyResponseStarted(request, info->process_id); return info->resource_handler->OnResponseStarted(info->request_id, response.get()); } int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost( - int cost, int render_process_host_id) { + int cost, int process_id) { // Retrieve the previous value (defaulting to 0 if not found). OutstandingRequestsMemoryCostMap::iterator prev_entry = - outstanding_requests_memory_cost_map_.find(render_process_host_id); + outstanding_requests_memory_cost_map_.find(process_id); int new_cost = 0; if (prev_entry != outstanding_requests_memory_cost_map_.end()) new_cost = prev_entry->second; @@ -864,7 +857,7 @@ int ResourceDispatcherHost::IncrementOutstandingRequestsMemoryCost( if (new_cost == 0) outstanding_requests_memory_cost_map_.erase(prev_entry); else - outstanding_requests_memory_cost_map_[render_process_host_id] = new_cost; + outstanding_requests_memory_cost_map_[process_id] = new_cost; return new_cost; } @@ -915,7 +908,7 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request, info->memory_cost = CalculateApproximateMemoryCost(request); int memory_cost = IncrementOutstandingRequestsMemoryCost( info->memory_cost, - info->render_process_host_id); + info->process_id); // If enqueing/starting this request will exceed our per-process memory // bound, abort it right away. @@ -926,14 +919,13 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request, // TODO(eroman): this is kinda funky -- we insert the unstarted request into // |pending_requests_| simply to please OnResponseCompleted(). - GlobalRequestID global_id(info->render_process_host_id, info->request_id); + GlobalRequestID global_id(info->process_id, info->request_id); pending_requests_[global_id] = request; OnResponseCompleted(request); return; } - std::pair<int, int> pair_id(info->render_process_host_id, - info->render_view_id); + std::pair<int, int> pair_id(info->process_id, info->route_id); BlockedRequestMap::const_iterator iter = blocked_requests_map_.find(pair_id); if (iter != blocked_requests_map_.end()) { // The request should be blocked. @@ -941,7 +933,7 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request, return; } - GlobalRequestID global_id(info->render_process_host_id, info->request_id); + GlobalRequestID global_id(info->process_id, info->request_id); pending_requests_[global_id] = request; if (mixed_content) { // We don't start the request in that case. The SSLManager will potentially @@ -1077,7 +1069,7 @@ void ResourceDispatcherHost::OnReadCompleted(URLRequest* request, // thread and starving other IO operations from running. info->paused_read_bytes = bytes_read; info->is_paused = true; - GlobalRequestID id(info->render_process_host_id, info->request_id); + GlobalRequestID id(info->process_id, info->request_id); MessageLoop::current()->PostTask( FROM_HERE, method_runner_.NewRunnableMethod( @@ -1113,7 +1105,7 @@ bool ResourceDispatcherHost::CompleteRead(URLRequest* request, // Pass in false as the last arg to indicate we don't want |request| // deleted. We do this as callers of us assume |request| is valid after we // return. - CancelRequest(info->render_process_host_id, info->request_id, false, false); + CancelRequest(info->process_id, info->request_id, false, false); return false; } @@ -1128,7 +1120,7 @@ void ResourceDispatcherHost::OnResponseCompleted(URLRequest* request) { const net::SSLInfo& ssl_info = request->ssl_info(); if (ssl_info.cert != NULL) { int cert_id = CertStore::GetSharedInstance()-> - StoreCert(ssl_info.cert, info->render_process_host_id); + StoreCert(ssl_info.cert, info->process_id); security_info = SSLManager::SerializeSecurityInfo(cert_id, ssl_info.cert_status, ssl_info.security_bits); @@ -1137,10 +1129,10 @@ void ResourceDispatcherHost::OnResponseCompleted(URLRequest* request) { if (info->resource_handler->OnResponseCompleted(info->request_id, request->status(), security_info)) { - NotifyResponseCompleted(request, info->render_process_host_id); + NotifyResponseCompleted(request, info->process_id); // The request is complete so we can remove it. - RemovePendingRequest(info->render_process_host_id, info->request_id); + RemovePendingRequest(info->process_id, info->request_id); } // If the handler's OnResponseCompleted returns false, we are deferring the // call until later. We will notify the world and clean up when we resume. @@ -1177,16 +1169,14 @@ class NotificationTask : public Task { ResourceRequestDetails* details) : type_(type), details_(details) { - if (!tab_util::GetTabContentsID(request, - &render_process_host_id_, - &tab_contents_id_)) + if (!tab_util::GetTabContentsID(request, &process_id_, &tab_contents_id_)) NOTREACHED(); } void Run() { // Find the tab associated with this request. TabContents* tab_contents = - tab_util::GetWebContentsByID(render_process_host_id_, tab_contents_id_); + tab_util::GetWebContentsByID(process_id_, tab_contents_id_); if (tab_contents) { // Issue the notification. @@ -1199,7 +1189,7 @@ class NotificationTask : public Task { private: // These IDs let us find the correct tab on the UI thread. - int render_process_host_id_; + int process_id_; int tab_contents_id_; // The type and details of the notification. @@ -1207,10 +1197,10 @@ class NotificationTask : public Task { scoped_ptr<ResourceRequestDetails> details_; }; -static int GetCertID(URLRequest* request, int render_process_host_id) { +static int GetCertID(URLRequest* request, int process_id) { if (request->ssl_info().cert) { return CertStore::GetSharedInstance()->StoreCert(request->ssl_info().cert, - render_process_host_id); + process_id); } // If there is no SSL info attached to this request, we must either be a non // secure request, or the request has been canceled or failed (before the SSL @@ -1225,7 +1215,7 @@ static int GetCertID(URLRequest* request, int render_process_host_id) { } void ResourceDispatcherHost::NotifyResponseStarted(URLRequest* request, - int render_process_host_id) { + int process_id) { // Notify the observers on the IO thread. FOR_EACH_OBSERVER(Observer, observer_list_, OnRequestStarted(this, request)); @@ -1233,12 +1223,12 @@ void ResourceDispatcherHost::NotifyResponseStarted(URLRequest* request, ui_loop_->PostTask(FROM_HERE, new NotificationTask(NotificationType::RESOURCE_RESPONSE_STARTED, request, new ResourceRequestDetails(request, - GetCertID(request, render_process_host_id)))); + GetCertID(request, process_id)))); } void ResourceDispatcherHost::NotifyResponseCompleted( URLRequest* request, - int render_process_host_id) { + int process_id) { // Notify the observers on the IO thread. FOR_EACH_OBSERVER(Observer, observer_list_, OnResponseCompleted(this, request)); @@ -1248,17 +1238,17 @@ void ResourceDispatcherHost::NotifyResponseCompleted( new NotificationTask(NotificationType::RESOURCE_RESPONSE_COMPLETED, request, new ResourceRequestDetails(request, - GetCertID(request, render_process_host_id)))); + GetCertID(request, process_id)))); } void ResourceDispatcherHost::NofityReceivedRedirect(URLRequest* request, - int render_process_host_id, + int process_id, const GURL& new_url) { // Notify the observers on the IO thread. FOR_EACH_OBSERVER(Observer, observer_list_, OnReceivedRedirect(this, request, new_url)); - int cert_id = GetCertID(request, render_process_host_id); + int cert_id = GetCertID(request, process_id); // Notify the observers on the UI thread. ui_loop_->PostTask(FROM_HERE, @@ -1336,8 +1326,7 @@ void ResourceDispatcherHost::UpdateLoadStates() { if (info->last_load_state != load_state) { info->last_load_state = load_state; - std::pair<int, int> key(info->render_process_host_id, - info->render_view_id); + std::pair<int, int> key(info->process_id, info->route_id); net::LoadState to_insert; LoadInfoMap::iterator existing = info_map.find(key); if (existing == info_map.end()) { @@ -1391,36 +1380,33 @@ void ResourceDispatcherHost::MaybeUpdateUploadProgress(ExtraRequestInfo *info, } } -void ResourceDispatcherHost::BlockRequestsForRenderView( - int render_process_host_id, - int render_view_id) { - std::pair<int, int> key(render_process_host_id, render_view_id); +void ResourceDispatcherHost::BlockRequestsForRoute( + int process_id, + int route_id) { + std::pair<int, int> key(process_id, route_id); DCHECK(blocked_requests_map_.find(key) == blocked_requests_map_.end()) << - "BlockRequestsForRenderView called multiple time for the same RVH"; + "BlockRequestsForRoute called multiple time for the same RVH"; blocked_requests_map_[key] = new BlockedRequestsList(); } -void ResourceDispatcherHost::ResumeBlockedRequestsForRenderView( - int render_process_host_id, - int render_view_id) { - ProcessBlockedRequestsForRenderView(render_process_host_id, - render_view_id, false); +void ResourceDispatcherHost::ResumeBlockedRequestsForRoute( + int process_id, + int route_id) { + ProcessBlockedRequestsForRoute(process_id, route_id, false); } -void ResourceDispatcherHost::CancelBlockedRequestsForRenderView( - int render_process_host_id, - int render_view_id) { - ProcessBlockedRequestsForRenderView(render_process_host_id, - render_view_id, true); +void ResourceDispatcherHost::CancelBlockedRequestsForRoute( + int process_id, + int route_id) { + ProcessBlockedRequestsForRoute(process_id, route_id, true); } -void ResourceDispatcherHost::ProcessBlockedRequestsForRenderView( - int render_process_host_id, - int render_view_id, +void ResourceDispatcherHost::ProcessBlockedRequestsForRoute( + int process_id, + int route_id, bool cancel_requests) { BlockedRequestMap::iterator iter = - blocked_requests_map_.find(std::pair<int, int>(render_process_host_id, - render_view_id)); + blocked_requests_map_.find(std::pair<int, int>(process_id, route_id)); if (iter == blocked_requests_map_.end()) { NOTREACHED(); return; @@ -1437,7 +1423,7 @@ void ResourceDispatcherHost::ProcessBlockedRequestsForRenderView( // the blocked list. ExtraRequestInfo* info = ExtraInfoForRequest(req_iter->url_request); IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost, - info->render_process_host_id); + info->process_id); if (cancel_requests) delete req_iter->url_request; else diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h index 0caf6ab..931401e 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.h +++ b/chrome/browser/renderer_host/resource_dispatcher_host.h @@ -3,9 +3,9 @@ // found in the LICENSE file. // This is the browser side of the resource dispatcher, it receives requests -// from the RenderProcessHosts, and dispatches them to URLRequests. It then -// fowards the messages from the URLRequests back to the correct process for -// handling. +// from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and +// dispatches them to URLRequests. It then fowards the messages from the +// URLRequests back to the correct process for handling. // // See http://dev.chromium.org/developers/design-documents/multi-process-resource-loading @@ -18,6 +18,7 @@ #include "base/process.h" #include "base/timer.h" #include "chrome/browser/renderer_host/resource_handler.h" +#include "chrome/common/child_process_info.h" #include "chrome/common/filter_policy.h" #include "chrome/common/ipc_message.h" #include "net/url_request/url_request.h" @@ -38,7 +39,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate { public: // Implemented by the client of ResourceDispatcherHost to receive messages in // response to a resource load. The messages are intended to be forwarded to - // the ResourceDispatcher in the renderer process via an IPC channel that the + // the ResourceDispatcher in the child process via an IPC channel that the // client manages. // // NOTE: This class unfortunately cannot be named 'Delegate' because that @@ -55,18 +56,20 @@ class ResourceDispatcherHost : public URLRequest::Delegate { friend class ResourceDispatcherHost; public: ExtraRequestInfo(ResourceHandler* handler, + ChildProcessInfo::ProcessType process_type, + int process_id, + int route_id, int request_id, - int render_process_host_id, - int render_view_id, bool mixed_content, ResourceType::Type resource_type, uint64 upload_size) : resource_handler(handler), cross_site_handler(NULL), login_handler(NULL), + process_type(process_type), + process_id(process_id), + route_id(route_id), request_id(request_id), - render_process_host_id(render_process_host_id), - render_view_id(render_view_id), pending_data_count(0), is_download(false), pause_count(0), @@ -93,11 +96,13 @@ class ResourceDispatcherHost : public URLRequest::Delegate { LoginHandler* login_handler; - int request_id; + ChildProcessInfo::ProcessType process_type; + + int process_id; - int render_process_host_id; + int route_id; - int render_view_id; + int request_id; int pending_data_count; @@ -163,20 +168,18 @@ class ResourceDispatcherHost : public URLRequest::Delegate { // Uniquely identifies a URLRequest. struct GlobalRequestID { - GlobalRequestID() : render_process_host_id(-1), request_id(-1) { - } - GlobalRequestID(int render_process_host_id, int request_id) - : render_process_host_id(render_process_host_id), - request_id(request_id) { + GlobalRequestID() : process_id(-1), request_id(-1) { } + GlobalRequestID(int process_id, int request_id) + : process_id(process_id), request_id(request_id) { } - int render_process_host_id; + int process_id; int request_id; bool operator<(const GlobalRequestID& other) const { - if (render_process_host_id == other.render_process_host_id) + if (process_id == other.process_id) return request_id < other.request_id; - return render_process_host_id < other.render_process_host_id; + return process_id < other.process_id; } }; @@ -190,59 +193,60 @@ class ResourceDispatcherHost : public URLRequest::Delegate { void Shutdown(); // Begins a resource request with the given params on behalf of the specified - // render view. Responses will be dispatched through the given receiver. The - // RenderProcessHost ID is used to lookup TabContents from routing_id's. - // request_context is the cookie/cache context to be used for this request. + // child process. Responses will be dispatched through the given receiver. The + // process ID is used to lookup TabContents from routing_id's in the case of a + // request from a renderer. request_context is the cookie/cache context to be + // used for this request. // // 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 BeginRequest(Receiver* receiver, - base::ProcessHandle render_process_handle, - int render_process_host_id, - int render_view_id, + ChildProcessInfo::ProcessType process_type, + base::ProcessHandle process_handle, + int process_id, + int route_id, int request_id, const ViewHostMsg_Resource_Request& request, URLRequestContext* request_context, IPC::Message* sync_result); // Initiates a download from the browser process (as opposed to a resource - // request from the renderer). + // request from the renderer or another child process). void BeginDownload(const GURL& url, const GURL& referrer, - int render_process_host_id, - int render_view_id, + int process_id, + int route_id, URLRequestContext* request_context); // Initiates a save file from the browser process (as opposed to a resource - // request from the renderer). + // request from the renderer or another child process). void BeginSaveFile(const GURL& url, const GURL& referrer, - int render_process_host_id, - int render_view_id, + int process_id, + int route_id, URLRequestContext* request_context); // Cancels the given request if it still exists. We ignore cancels from the // renderer in the event of a download. - void CancelRequest(int render_process_host_id, + void CancelRequest(int process_id, int request_id, bool from_renderer); // Decrements the pending_data_count for the request and resumes // the request if it was paused due to too many pending data // messages sent. - void OnDataReceivedACK(int render_process_host_id, int request_id); + void OnDataReceivedACK(int process_id, int request_id); // Resets the waiting_for_upload_progress_ack flag. - void OnUploadProgressACK(int render_process_host_id, int request_id); + void OnUploadProgressACK(int process_id, int request_id); // Returns true if it's ok to send the data. If there are already too many // data messages pending, it pauses the request and returns false. In this // case the caller should not send the data. - bool WillSendData(int render_process_host_id, int request_id); + bool WillSendData(int process_id, int request_id); // Pauses or resumes network activity for a particular request. - void PauseRequest(int render_process_host_id, int request_id, bool pause); + void PauseRequest(int process_id, int request_id, bool pause); // Returns the number of pending requests. This is designed for the unittests int pending_requests() const { @@ -250,8 +254,8 @@ class ResourceDispatcherHost : public URLRequest::Delegate { } // Intended for unit-tests only. Returns the memory cost of all the - // outstanding requests (pending and blocked) for |render_process_host_id|. - int GetOutstandingRequestsMemoryCost(int render_process_host_id) const; + // outstanding requests (pending and blocked) for |process_id|. + int GetOutstandingRequestsMemoryCost(int process_id) const; // Intended for unit-tests only. Overrides the outstanding requests bound. void set_max_outstanding_requests_cost_per_process(int limit) { @@ -281,15 +285,14 @@ class ResourceDispatcherHost : public URLRequest::Delegate { MessageLoop* ui_loop() const { return ui_loop_; } // Called when the onunload handler for a cross-site request has finished. - void OnClosePageACK(int render_process_host_id, int request_id); + void OnClosePageACK(int process_id, int request_id); // Force cancels any pending requests for the given process. - void CancelRequestsForProcess(int render_process_host_id); + void CancelRequestsForProcess(int process_id); - // Force cancels any pending requests for the given render view. This method - // acts like CancelRequestsForProcess when render_view_id is -1. - void CancelRequestsForRenderView(int render_process_host_id, - int render_view_id); + // Force cancels any pending requests for the given route id. This method + // acts like CancelRequestsForProcess when route_id is -1. + void CancelRequestsForRoute(int process_id, int route_id); // URLRequest::Delegate virtual void OnReceivedRedirect(URLRequest* request, @@ -336,24 +339,21 @@ class ResourceDispatcherHost : public URLRequest::Delegate { const std::string& content_disposition); // Notifies our observers that a request has been cancelled. - void NotifyResponseCompleted(URLRequest* request, int render_process_host_id); + void NotifyResponseCompleted(URLRequest* request, int process_id); - void RemovePendingRequest(int render_process_host_id, int request_id); + void RemovePendingRequest(int process_id, int request_id); - // Causes all new requests for the render view identified by - // |render_process_host_id| and |render_view_id| to be blocked (not being - // started) until ResumeBlockedRequestsForRenderView or - // CancelBlockedRequestsForRenderView is called. - void BlockRequestsForRenderView(int render_process_host_id, - int render_view_id); + // Causes all new requests for the route identified by + // |process_id| and |route_id| to be blocked (not being + // started) until ResumeBlockedRequestsForRoute or + // CancelBlockedRequestsForRoute is called. + void BlockRequestsForRoute(int process_id, int route_id); - // Resumes any blocked request for the specified RenderView. - void ResumeBlockedRequestsForRenderView(int render_process_host_id, - int render_view_id); + // Resumes any blocked request for the specified route id. + void ResumeBlockedRequestsForRoute(int process_id, int route_id); - // Cancels any blocked request for the specified RenderView. - void CancelBlockedRequestsForRenderView(int render_process_host_id, - int render_view_id); + // Cancels any blocked request for the specified route id. + void CancelBlockedRequestsForRoute(int process_id, int route_id); private: FRIEND_TEST(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies); @@ -401,7 +401,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate { // Cancels the given request if it still exists. We ignore cancels from the // renderer in the event of a download. If |allow_delete| is true and no IO // is pending, the request is removed and deleted. - void CancelRequest(int render_process_host_id, + void CancelRequest(int process_id, int request_id, bool from_renderer, bool allow_delete); @@ -409,14 +409,14 @@ class ResourceDispatcherHost : public URLRequest::Delegate { // Helper function for regular and download requests. void BeginRequestInternal(URLRequest* request, bool mixed_content); - // Updates the "cost" of outstanding requests for |render_process_host_id|. + // Updates the "cost" of outstanding requests for |process_id|. // The "cost" approximates how many bytes are consumed by all the in-memory // data structures supporting this request (URLRequest object, // HttpNetworkTransaction, etc...). // The value of |cost| is added to the running total, and the resulting // sum is returned. int IncrementOutstandingRequestsMemoryCost(int cost, - int render_process_host_id); + int process_id); // Estimate how much heap space |request| will consume to run. static int CalculateApproximateMemoryCost(URLRequest* request); @@ -436,17 +436,17 @@ class ResourceDispatcherHost : public URLRequest::Delegate { void RemovePendingRequest(const PendingRequestList::iterator& iter); // Notify our observers that we started receiving a response for a request. - void NotifyResponseStarted(URLRequest* request, int render_process_host_id); + void NotifyResponseStarted(URLRequest* request, int process_id); // Notify our observers that a request has been redirected. void NofityReceivedRedirect(URLRequest* request, - int render_process_host_id, + int process_id, const GURL& new_url); // Tries to handle the url with an external protocol. If the request is // handled, the function returns true. False otherwise. bool HandleExternalProtocol(int request_id, - int render_process_host_id, + int process_id, int tab_contents_id, const GURL& url, ResourceType::Type resource_type, @@ -457,9 +457,9 @@ class ResourceDispatcherHost : public URLRequest::Delegate { void MaybeUpdateUploadProgress(ExtraRequestInfo *info, URLRequest *request); // Resumes or cancels (if |cancel_requests| is true) any blocked requests. - void ProcessBlockedRequestsForRenderView(int render_process_host_id, - int render_view_id, - bool cancel_requests); + void ProcessBlockedRequestsForRoute(int process_id, + int route_id, + bool cancel_requests); PendingRequestList pending_requests_; @@ -485,8 +485,8 @@ class ResourceDispatcherHost : public URLRequest::Delegate { scoped_refptr<SafeBrowsingService> safe_browsing_; - // Request ID for non-renderer initiated requests. request_ids generated by - // the renderer process are counted up from 0, while browser created requests + // Request ID for browser initiated requests. request_ids generated by + // child processes are counted up from 0, while browser created requests // start at -2 and go down from there. (We need to start at -2 because -1 is // used as a special value all over the resource_dispatcher_host for // uninitialized variables.) This way, we no longer have the unlikely (but @@ -506,17 +506,17 @@ class ResourceDispatcherHost : public URLRequest::Delegate { bool is_shutdown_; typedef std::vector<BlockedRequest> BlockedRequestsList; - typedef std::pair<int, int> ProcessRendererIDs; - typedef std::map<ProcessRendererIDs, BlockedRequestsList*> BlockedRequestMap; + typedef std::pair<int, int> ProcessRouteIDs; + typedef std::map<ProcessRouteIDs, BlockedRequestsList*> BlockedRequestMap; BlockedRequestMap blocked_requests_map_; - // Maps the render_process_host_ids to the approximate number of bytes + // Maps the process_ids to the approximate number of bytes // being used to service its resource requests. No entry implies 0 cost. typedef std::map<int, int> OutstandingRequestsMemoryCostMap; OutstandingRequestsMemoryCostMap outstanding_requests_memory_cost_map_; // |max_outstanding_requests_cost_per_process_| is the upper bound on how - // many outstanding requests can be issued per render process host. + // many outstanding requests can be issued per child process host. // The constraint is expressed in terms of bytes (where the cost of // individual requests is given by CalculateApproximateMemoryCost). // The total number of outstanding requests is roughly: diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc index 55df67c..2d05ffb 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -144,7 +144,8 @@ void ResourceDispatcherHostTest::MakeTestRequest(int render_process_id, const GURL& url) { ViewHostMsg_Resource_Request request = CreateResourceRequest("GET", url); - host_.BeginRequest(this, base::GetCurrentProcessHandle(), render_process_id, + host_.BeginRequest(this, ChildProcessInfo::RENDER_PROCESS, + base::GetCurrentProcessHandle(), render_process_id, render_view_id, request_id, request, NULL, NULL); KickOffRequest(); } @@ -286,8 +287,9 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) { EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); - host_.BeginRequest(&test_receiver, base::GetCurrentProcessHandle(), 0, - MSG_ROUTING_NONE, 1, request, NULL, NULL); + host_.BeginRequest(&test_receiver, ChildProcessInfo::RENDER_PROCESS, + base::GetCurrentProcessHandle(), 0, MSG_ROUTING_NONE, 1, + request, NULL, NULL); KickOffRequest(); // request 2 goes to us @@ -295,8 +297,9 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) { // request 3 goes to the test delegate request.url = URLRequestTestJob::test_url_3(); - host_.BeginRequest(&test_receiver, base::GetCurrentProcessHandle(), 0, - MSG_ROUTING_NONE, 3, request, NULL, NULL); + host_.BeginRequest(&test_receiver, ChildProcessInfo::RENDER_PROCESS, + base::GetCurrentProcessHandle(), 0, MSG_ROUTING_NONE, 3, + request, NULL, NULL); KickOffRequest(); // TODO(mbelshe): @@ -333,9 +336,9 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) { TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) { EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); - host_.BlockRequestsForRenderView(0, 1); - host_.BlockRequestsForRenderView(0, 2); - host_.BlockRequestsForRenderView(0, 3); + host_.BlockRequestsForRoute(0, 1); + host_.BlockRequestsForRoute(0, 2); + host_.BlockRequestsForRoute(0, 3); MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1()); MakeTestRequest(0, 1, 2, URLRequestTestJob::test_url_2()); @@ -358,7 +361,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) { CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); // Resume requests for RVH 1 and flush pending requests. - host_.ResumeBlockedRequestsForRenderView(0, 1); + host_.ResumeBlockedRequestsForRoute(0, 1); KickOffRequest(); while (URLRequestTestJob::ProcessOnePendingMessage()); @@ -377,8 +380,8 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) { CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); // Now resumes requests for all RVH (2 and 3). - host_.ResumeBlockedRequestsForRenderView(0, 2); - host_.ResumeBlockedRequestsForRenderView(0, 3); + host_.ResumeBlockedRequestsForRoute(0, 2); + host_.ResumeBlockedRequestsForRoute(0, 3); KickOffRequest(); while (URLRequestTestJob::ProcessOnePendingMessage()); @@ -395,7 +398,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) { TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) { EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); - host_.BlockRequestsForRenderView(0, 1); + host_.BlockRequestsForRoute(0, 1); MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1()); MakeTestRequest(0, 1, 2, URLRequestTestJob::test_url_2()); @@ -416,7 +419,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) { CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); // Cancel requests for RVH 1. - host_.CancelBlockedRequestsForRenderView(0, 1); + host_.CancelBlockedRequestsForRoute(0, 1); KickOffRequest(); while (URLRequestTestJob::ProcessOnePendingMessage()); @@ -432,7 +435,7 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) { EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(1)); - host_.BlockRequestsForRenderView(1, 0); + host_.BlockRequestsForRoute(1, 0); MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1()); MakeTestRequest(1, 0, 2, URLRequestTestJob::test_url_2()); @@ -466,9 +469,9 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) { // If this test turns the Purify bot red, check the ResourceDispatcherHost // destructor to make sure the blocked requests are deleted. TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { - host_.BlockRequestsForRenderView(0, 1); - host_.BlockRequestsForRenderView(0, 2); - host_.BlockRequestsForRenderView(1, 1); + host_.BlockRequestsForRoute(0, 1); + host_.BlockRequestsForRoute(0, 2); + host_.BlockRequestsForRoute(1, 1); MakeTestRequest(0, 0, 1, URLRequestTestJob::test_url_1()); MakeTestRequest(0, 1, 2, URLRequestTestJob::test_url_2()); diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 8492cc6..9783936 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -330,6 +330,7 @@ void ResourceMessageFilter::OnRequestResource( int request_id, const ViewHostMsg_Resource_Request& request) { resource_dispatcher_host_->BeginRequest(this, + ChildProcessInfo::RENDER_PROCESS, render_handle_, render_process_host_id_, message.routing_id(), @@ -365,6 +366,7 @@ void ResourceMessageFilter::OnSyncLoad( const ViewHostMsg_Resource_Request& request, IPC::Message* sync_result) { resource_dispatcher_host_->BeginRequest(this, + ChildProcessInfo::RENDER_PROCESS, render_handle_, render_process_host_id_, sync_result->routing_id(), diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc index 123deaa..26e4fde 100644 --- a/chrome/browser/ssl/ssl_manager.cc +++ b/chrome/browser/ssl/ssl_manager.cc @@ -243,7 +243,7 @@ SSLManager::ErrorHandler::ErrorHandler(ResourceDispatcherHost* rdh, ResourceDispatcherHost::ExtraRequestInfo* info = ResourceDispatcherHost::ExtraInfoForRequest(request); - request_id_.render_process_host_id = info->render_process_host_id; + request_id_.process_id = info->process_id; request_id_.request_id = info->request_id; if (!tab_util::GetTabContentsID(request, diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index b935b64..4d56420 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -37,15 +37,15 @@ class ResourceRequestTask : public Task { virtual void Run() { switch (action_) { case BLOCK: - resource_dispatcher_host_->BlockRequestsForRenderView( + resource_dispatcher_host_->BlockRequestsForRoute( process_id_, render_view_host_id_); break; case RESUME: - resource_dispatcher_host_->ResumeBlockedRequestsForRenderView( + resource_dispatcher_host_->ResumeBlockedRequestsForRoute( process_id_, render_view_host_id_); break; case CANCEL: - resource_dispatcher_host_->CancelBlockedRequestsForRenderView( + resource_dispatcher_host_->CancelBlockedRequestsForRoute( process_id_, render_view_host_id_); break; default: diff --git a/chrome/browser/tab_contents/tab_util.cc b/chrome/browser/tab_contents/tab_util.cc index 3437f1c..5c53ddb 100644 --- a/chrome/browser/tab_contents/tab_util.cc +++ b/chrome/browser/tab_contents/tab_util.cc @@ -22,8 +22,8 @@ bool tab_util::GetTabContentsID(URLRequest* request, if (!info) return false; - *render_process_id = info->render_process_host_id; - *render_view_id = info->render_view_id; + *render_process_id = info->process_id; + *render_view_id = info->route_id; return true; } |