| Index: content/browser/renderer_host/resource_dispatcher_host_impl.cc
|
| diff --git a/content/browser/renderer_host/resource_dispatcher_host_impl.cc b/content/browser/renderer_host/resource_dispatcher_host_impl.cc
|
| index 60a3c9f89b0fa983d0011475fc1776a8f521ef91..35301536f13601025264f9d54a4dc2fb5be9b0f2 100644
|
| --- a/content/browser/renderer_host/resource_dispatcher_host_impl.cc
|
| +++ b/content/browser/renderer_host/resource_dispatcher_host_impl.cc
|
| @@ -38,6 +38,7 @@
|
| #include "content/browser/renderer_host/render_view_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/renderer_host/resource_scheduler.h"
|
| #include "content/browser/renderer_host/sync_resource_handler.h"
|
| #include "content/browser/renderer_host/throttling_resource_handler.h"
|
| #include "content/browser/renderer_host/transfer_navigation_resource_throttle.h"
|
| @@ -358,7 +359,8 @@ ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()
|
| kMaxOutstandingRequestsCostPerProcess),
|
| filter_(NULL),
|
| delegate_(NULL),
|
| - allow_cross_origin_auth_prompt_(false) {
|
| + allow_cross_origin_auth_prompt_(false),
|
| + resource_scheduler_(new ResourceScheduler()) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| DCHECK(!g_resource_dispatcher_host);
|
| g_resource_dispatcher_host = this;
|
| @@ -417,7 +419,7 @@ void ResourceDispatcherHostImpl::CancelRequestsForContext(
|
| // 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.
|
| - typedef std::vector<linked_ptr<ResourceLoader> > LoaderList;
|
| + typedef std::vector<linked_ptr<ResourceLoaderImpl> > LoaderList;
|
| LoaderList loaders_to_cancel;
|
|
|
| for (LoaderMap::iterator i = pending_loaders_.begin();
|
| @@ -444,7 +446,7 @@ void ResourceDispatcherHostImpl::CancelRequestsForContext(
|
| blocked_loaders_map_.erase(i++);
|
| for (BlockedLoadersList::const_iterator it = loaders->begin();
|
| it != loaders->end(); ++it) {
|
| - linked_ptr<ResourceLoader> loader = *it;
|
| + linked_ptr<ResourceLoaderImpl> loader = *it;
|
| info = loader->GetRequestInfo();
|
| // We make the assumption that all requests on the list have the same
|
| // ResourceContext.
|
| @@ -562,7 +564,7 @@ void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest(
|
| net::URLRequest* request) {
|
| ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
|
| if (info) {
|
| - ResourceLoader* loader = GetLoader(info->GetGlobalRequestID());
|
| + ResourceLoaderImpl* loader = GetLoader(info->GetGlobalRequestID());
|
| if (loader)
|
| loader->ClearLoginDelegate();
|
| }
|
| @@ -607,7 +609,7 @@ void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest(
|
| net::URLRequest* request) {
|
| ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
|
| if (info) {
|
| - ResourceLoader* loader = GetLoader(info->GetGlobalRequestID());
|
| + ResourceLoaderImpl* loader = GetLoader(info->GetGlobalRequestID());
|
| if (loader)
|
| loader->ClearSSLClientAuthHandler();
|
| }
|
| @@ -615,7 +617,7 @@ void ResourceDispatcherHostImpl::ClearSSLClientAuthHandlerForRequest(
|
|
|
| ResourceDispatcherHostLoginDelegate*
|
| ResourceDispatcherHostImpl::CreateLoginDelegate(
|
| - ResourceLoader* loader,
|
| + ResourceLoaderImpl* loader,
|
| net::AuthChallengeInfo* auth_info) {
|
| if (!delegate_)
|
| return NULL;
|
| @@ -624,7 +626,7 @@ ResourceDispatcherHostImpl::CreateLoginDelegate(
|
| }
|
|
|
| bool ResourceDispatcherHostImpl::AcceptAuthRequest(
|
| - ResourceLoader* loader,
|
| + ResourceLoaderImpl* loader,
|
| net::AuthChallengeInfo* auth_info) {
|
| if (delegate_ && !delegate_->AcceptAuthRequest(loader->request(), auth_info))
|
| return false;
|
| @@ -647,7 +649,7 @@ bool ResourceDispatcherHostImpl::AcceptAuthRequest(
|
| }
|
|
|
| bool ResourceDispatcherHostImpl::AcceptSSLClientCertificateRequest(
|
| - ResourceLoader* loader,
|
| + ResourceLoaderImpl* loader,
|
| net::SSLCertRequestInfo* cert_info) {
|
| if (delegate_ && !delegate_->AcceptSSLClientCertificateRequest(
|
| loader->request(), cert_info)) {
|
| @@ -657,8 +659,9 @@ bool ResourceDispatcherHostImpl::AcceptSSLClientCertificateRequest(
|
| return true;
|
| }
|
|
|
| -bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader,
|
| - const GURL& url) {
|
| +bool ResourceDispatcherHostImpl::HandleExternalProtocol(
|
| + ResourceLoaderImpl* loader,
|
| + const GURL& url) {
|
| if (!delegate_)
|
| return false;
|
|
|
| @@ -677,7 +680,7 @@ bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader,
|
| return true;
|
| }
|
|
|
| -void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) {
|
| +void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoaderImpl* loader) {
|
| // Make sure we have the load state monitor running
|
| if (!update_load_states_timer_->IsRunning()) {
|
| update_load_states_timer_->Start(FROM_HERE,
|
| @@ -686,7 +689,7 @@ void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) {
|
| }
|
| }
|
|
|
| -void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader,
|
| +void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoaderImpl* loader,
|
| const GURL& new_url) {
|
| ResourceRequestInfoImpl* info = loader->GetRequestInfo();
|
|
|
| @@ -707,7 +710,8 @@ void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader,
|
| render_process_id, render_view_id, base::Passed(&detail)));
|
| }
|
|
|
| -void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
|
| +void ResourceDispatcherHostImpl::DidReceiveResponse(
|
| + ResourceLoaderImpl* loader) {
|
| ResourceRequestInfoImpl* info = loader->GetRequestInfo();
|
|
|
| int render_process_id, render_view_id;
|
| @@ -726,7 +730,7 @@ void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
|
| render_process_id, render_view_id, base::Passed(&detail)));
|
| }
|
|
|
| -void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) {
|
| +void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoaderImpl* loader) {
|
| ResourceRequestInfo* info = loader->GetRequestInfo();
|
|
|
| // Record final result of all resource loads.
|
| @@ -876,7 +880,7 @@ void ResourceDispatcherHostImpl::BeginRequest(
|
|
|
| // If the request that's coming in is being transferred from another process,
|
| // we want to reuse and resume the old loader rather than start a new one.
|
| - linked_ptr<ResourceLoader> deferred_loader;
|
| + linked_ptr<ResourceLoaderImpl> deferred_loader;
|
| {
|
| LoaderMap::iterator it = pending_loaders_.find(
|
| GlobalRequestID(request_data.transferred_request_child_id,
|
| @@ -1071,7 +1075,7 @@ void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) {
|
| }
|
|
|
| void ResourceDispatcherHostImpl::OnDataReceivedACK(int request_id) {
|
| - ResourceLoader* loader = GetLoader(filter_->child_id(), request_id);
|
| + ResourceLoaderImpl* loader = GetLoader(filter_->child_id(), request_id);
|
| if (!loader)
|
| return;
|
|
|
| @@ -1122,7 +1126,7 @@ bool ResourceDispatcherHostImpl::Send(IPC::Message* message) {
|
| }
|
|
|
| void ResourceDispatcherHostImpl::OnUploadProgressACK(int request_id) {
|
| - ResourceLoader* loader = GetLoader(filter_->child_id(), request_id);
|
| + ResourceLoaderImpl* loader = GetLoader(filter_->child_id(), request_id);
|
| if (loader)
|
| loader->OnUploadProgressACK();
|
| }
|
| @@ -1135,7 +1139,7 @@ void ResourceDispatcherHostImpl::OnFollowRedirect(
|
| int request_id,
|
| bool has_new_first_party_for_cookies,
|
| const GURL& new_first_party_for_cookies) {
|
| - ResourceLoader* loader = GetLoader(filter_->child_id(), request_id);
|
| + ResourceLoaderImpl* loader = GetLoader(filter_->child_id(), request_id);
|
| if (!loader) {
|
| DVLOG(1) << "OnFollowRedirect for invalid request";
|
| return;
|
| @@ -1189,8 +1193,8 @@ void ResourceDispatcherHostImpl::HandleSwapOutACK(
|
| const ViewMsg_SwapOut_Params& params, bool timed_out) {
|
| // Closes for cross-site transitions are handled such that the cross-site
|
| // transition continues.
|
| - ResourceLoader* loader = GetLoader(params.new_render_process_host_id,
|
| - params.new_request_id);
|
| + ResourceLoaderImpl* loader = GetLoader(params.new_render_process_host_id,
|
| + params.new_request_id);
|
| if (loader) {
|
| // The response we were meant to resume could have already been canceled.
|
| ResourceRequestInfoImpl* info = loader->GetRequestInfo();
|
| @@ -1382,6 +1386,8 @@ void ResourceDispatcherHostImpl::RemovePendingLoader(
|
| IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(),
|
| info->GetChildID());
|
|
|
| + resource_scheduler_->RemoveLoad(
|
| + info->GetChildID(), info->GetRouteID(), info->GetRequestID());
|
| pending_loaders_.erase(iter);
|
|
|
| // If we have no more pending requests, then stop the load state monitor
|
| @@ -1399,7 +1405,7 @@ void ResourceDispatcherHostImpl::CancelRequest(int child_id,
|
| return;
|
| }
|
|
|
| - ResourceLoader* loader = GetLoader(child_id, request_id);
|
| + ResourceLoaderImpl* loader = GetLoader(child_id, request_id);
|
| if (!loader) {
|
| // We probably want to remove this warning eventually, but I wanted to be
|
| // able to notice when this happens during initial development since it
|
| @@ -1487,8 +1493,8 @@ void ResourceDispatcherHostImpl::BeginRequestInternal(
|
| return;
|
| }
|
|
|
| - linked_ptr<ResourceLoader> loader(
|
| - new ResourceLoader(request.Pass(), handler.Pass(), this));
|
| + linked_ptr<ResourceLoaderImpl> loader(
|
| + new ResourceLoaderImpl(request.Pass(), handler.Pass(), this));
|
|
|
| ProcessRouteIDs pair_id(info->GetChildID(), info->GetRouteID());
|
| BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(pair_id);
|
| @@ -1503,10 +1509,10 @@ void ResourceDispatcherHostImpl::BeginRequestInternal(
|
|
|
| void ResourceDispatcherHostImpl::StartLoading(
|
| ResourceRequestInfoImpl* info,
|
| - const linked_ptr<ResourceLoader>& loader) {
|
| + const linked_ptr<ResourceLoaderImpl>& loader) {
|
| pending_loaders_[info->GetGlobalRequestID()] = loader;
|
| -
|
| - loader->StartRequest();
|
| + resource_scheduler_->ScheduleLoad(info->GetChildID(), info->GetRouteID(),
|
| + info->GetRequestID(), loader.get());
|
| }
|
|
|
| void ResourceDispatcherHostImpl::OnUserGesture(WebContentsImpl* contents) {
|
| @@ -1515,7 +1521,7 @@ void ResourceDispatcherHostImpl::OnUserGesture(WebContentsImpl* contents) {
|
|
|
| net::URLRequest* ResourceDispatcherHostImpl::GetURLRequest(
|
| const GlobalRequestID& id) {
|
| - ResourceLoader* loader = GetLoader(id);
|
| + ResourceLoaderImpl* loader = GetLoader(id);
|
| if (!loader)
|
| return NULL;
|
|
|
| @@ -1672,7 +1678,7 @@ void ResourceDispatcherHostImpl::ProcessBlockedRequestsForRoute(
|
|
|
| for (BlockedLoadersList::iterator loaders_iter = loaders->begin();
|
| loaders_iter != loaders->end(); ++loaders_iter) {
|
| - linked_ptr<ResourceLoader> loader = *loaders_iter;
|
| + linked_ptr<ResourceLoaderImpl> loader = *loaders_iter;
|
| ResourceRequestInfoImpl* info = loader->GetRequestInfo();
|
| if (cancel_requests) {
|
| IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(),
|
| @@ -1708,11 +1714,11 @@ bool ResourceDispatcherHostImpl::allow_cross_origin_auth_prompt() {
|
|
|
| bool ResourceDispatcherHostImpl::IsTransferredNavigation(
|
| const GlobalRequestID& id) const {
|
| - ResourceLoader* loader = GetLoader(id);
|
| + ResourceLoaderImpl* loader = GetLoader(id);
|
| return loader ? loader->is_transferring() : false;
|
| }
|
|
|
| -ResourceLoader* ResourceDispatcherHostImpl::GetLoader(
|
| +ResourceLoaderImpl* ResourceDispatcherHostImpl::GetLoader(
|
| const GlobalRequestID& id) const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
|
|
| @@ -1723,8 +1729,8 @@ ResourceLoader* ResourceDispatcherHostImpl::GetLoader(
|
| return i->second.get();
|
| }
|
|
|
| -ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id,
|
| - int request_id) const {
|
| +ResourceLoaderImpl* ResourceDispatcherHostImpl::GetLoader(
|
| + int child_id, int request_id) const {
|
| return GetLoader(GlobalRequestID(child_id, request_id));
|
| }
|
|
|
|
|