Chromium Code Reviews| Index: content/browser/loader/resource_dispatcher_host_impl.cc |
| diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc |
| index 5600a23455fc80f8f2a6592077a78be2babcb165..d6db79ffa1ea1f8ad52cdec6bd41b23b5d0c8c93 100644 |
| --- a/content/browser/loader/resource_dispatcher_host_impl.cc |
| +++ b/content/browser/loader/resource_dispatcher_host_impl.cc |
| @@ -978,6 +978,7 @@ bool ResourceDispatcherHostImpl::OnMessageReceived( |
| IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) |
| IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
| IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
| + IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, OnDidChangePriority) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| @@ -1435,8 +1436,10 @@ scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::AddStandardHandlers( |
| throttles.push_back(new PowerSaveBlockResourceThrottle()); |
| } |
| - throttles.push_back( |
| - scheduler_->ScheduleRequest(child_id, route_id, request).release()); |
| + // TODO(ricea): Stop looking this up so much. |
| + ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
| + throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, |
| + info->IsAsync(), request)); |
| handler.reset( |
| new ThrottlingResourceHandler(handler.Pass(), request, throttles.Pass())); |
| @@ -1448,6 +1451,26 @@ void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
| UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
| } |
| +void ResourceDispatcherHostImpl::OnDidChangePriority( |
| + int request_id, |
| + net::RequestPriority new_priority, |
| + int intra_priority_value) { |
| + ResourceLoader* loader = GetLoader(filter_->child_id(), request_id); |
| + // The request may go away before processing this message, so |loader| can |
| + // legitimately be null. |
| + if (!loader) |
| + return; |
| + auto* scheduled_resource_request = |
| + ResourceScheduler::ScheduledResourceRequest::ForRequest( |
| + loader->request()); |
| + // Downloads don't use the resource scheduler. |
| + // TODO(ricea): Can a DidChangePriority message for a download be legitimate? |
|
davidben
2015/08/13 23:08:52
There's two ways to get a download. One is if a no
Adam Rice
2015/08/13 23:42:28
Done.
|
| + if (!scheduled_resource_request) |
| + return; |
| + scheduled_resource_request->ChangePriority(new_priority, |
| + intra_priority_value); |
| +} |
| + |
| void ResourceDispatcherHostImpl::OnDataDownloadedACK(int request_id) { |
| // TODO(michaeln): maybe throttle DataDownloaded messages |
| } |