Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: content/child/resource_dispatcher.cc

Issue 2646343007: [Mojo-Loading] Implement URLLoader::SetPriority (Closed)
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_fetch_dispatcher.cc ('k') | content/common/url_loader.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/resource_dispatcher.cc
diff --git a/content/child/resource_dispatcher.cc b/content/child/resource_dispatcher.cc
index 09c7db9058e1b113afaf00134802bd9c250c9251..c54aa6290224f5d789f9a14a3a0ee6aed1495dec 100644
--- a/content/child/resource_dispatcher.cc
+++ b/content/child/resource_dispatcher.cc
@@ -87,6 +87,27 @@ void CheckSchemeForReferrerPolicy(const ResourceRequest& request) {
}
}
+mojom::RequestPriority MojoRequestPriorityForNetRequestPriority(
+ net::RequestPriority priority) {
+ switch (priority) {
+ case net::THROTTLED:
+ return mojom::RequestPriority::kThrottled;
+ case net::IDLE:
+ return mojom::RequestPriority::kIdle;
+ case net::LOWEST:
+ return mojom::RequestPriority::kLowest;
+ case net::LOW:
+ return mojom::RequestPriority::kLow;
+ case net::MEDIUM:
+ return mojom::RequestPriority::kMedium;
+ case net::HIGHEST:
+ return mojom::RequestPriority::kHighest;
+ }
+
+ NOTREACHED();
+ return static_cast<mojom::RequestPriority>(priority);
+}
kinuko 2017/01/25 03:48:31 Could these use enum traits?
yhirano 2017/01/27 07:53:55 Done.
+
} // namespace
ResourceDispatcher::ResourceDispatcher(
@@ -508,9 +529,16 @@ void ResourceDispatcher::SetDefersLoading(int request_id, bool value) {
void ResourceDispatcher::DidChangePriority(int request_id,
net::RequestPriority new_priority,
int intra_priority_value) {
- DCHECK(base::ContainsKey(pending_requests_, request_id));
- message_sender_->Send(new ResourceHostMsg_DidChangePriority(
- request_id, new_priority, intra_priority_value));
+ PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
+ DCHECK(request_info);
+ if (request_info->url_loader) {
+ request_info->url_loader->SetPriority(
+ MojoRequestPriorityForNetRequestPriority(new_priority),
+ intra_priority_value);
+ } else {
+ message_sender_->Send(new ResourceHostMsg_DidChangePriority(
+ request_id, new_priority, intra_priority_value));
+ }
}
void ResourceDispatcher::OnTransferSizeUpdated(int request_id,
« no previous file with comments | « content/browser/service_worker/service_worker_fetch_dispatcher.cc ('k') | content/common/url_loader.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698