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

Unified Diff: content/browser/loader/mojo_async_resource_handler.cc

Issue 2646343007: [Mojo-Loading] Implement URLLoader::SetPriority (Closed)
Patch Set: fix 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
Index: content/browser/loader/mojo_async_resource_handler.cc
diff --git a/content/browser/loader/mojo_async_resource_handler.cc b/content/browser/loader/mojo_async_resource_handler.cc
index 75abb83a1c563f4c14d44aa0e84ea234540a5bc2..b44b027747e385d5b49a5d8f126b164ff6c72e3a 100644
--- a/content/browser/loader/mojo_async_resource_handler.cc
+++ b/content/browser/loader/mojo_async_resource_handler.cc
@@ -19,6 +19,7 @@
#include "content/browser/loader/resource_controller.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/loader/resource_request_info_impl.h"
+#include "content/browser/loader/resource_scheduler.h"
#include "content/common/resource_request_completion_status.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/browser/resource_dispatcher_host_delegate.h"
@@ -28,6 +29,7 @@
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
#include "net/base/mime_sniffer.h"
+#include "net/base/request_priority.h"
#include "net/url_request/redirect_info.h"
namespace content {
@@ -63,6 +65,27 @@ void NotReached(mojom::URLLoaderAssociatedRequest mojo_request,
NOTREACHED();
}
+net::RequestPriority NetRequestPriorityForMojoRequestPriority(
+ mojom::RequestPriority priority) {
+ switch (priority) {
+ case mojom::RequestPriority::kThrottled:
+ return net::THROTTLED;
+ case mojom::RequestPriority::kIdle:
+ return net::IDLE;
+ case mojom::RequestPriority::kLowest:
+ return net::LOWEST;
+ case mojom::RequestPriority::kLow:
+ return net::LOW;
+ case mojom::RequestPriority::kMedium:
+ return net::MEDIUM;
+ case mojom::RequestPriority::kHighest:
+ return net::HIGHEST;
dcheng 2017/01/24 19:07:18 Can we add an EnumTraits and typemap this instead?
yhirano 2017/01/27 07:53:55 Done.
+ }
+
+ NOTREACHED();
+ return static_cast<net::RequestPriority>(priority);
+}
+
} // namespace
// This class is for sharing the ownership of a ScopedDataPipeProducerHandle
@@ -327,6 +350,13 @@ void MojoAsyncResourceHandler::FollowRedirect() {
controller()->Resume();
}
+void MojoAsyncResourceHandler::SetPriority(mojom::RequestPriority priority,
+ int32_t intra_priority_value) {
+ ResourceDispatcherHostImpl::Get()->scheduler()->ReprioritizeRequest(
+ request(), NetRequestPriorityForMojoRequestPriority(priority),
+ intra_priority_value);
+}
+
void MojoAsyncResourceHandler::OnWritableForTesting() {
OnWritable(MOJO_RESULT_OK);
}

Powered by Google App Engine
This is Rietveld 408576698