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

Unified Diff: third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp

Issue 2209023002: Introduce TaskRunnerHelper::get() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 4 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 | « third_party/WebKit/Source/core/dom/TaskRunnerHelper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
diff --git a/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp b/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
index 55719983cdee79e401b0e91401cb498f910475d0..5d6de3e72d2db434f4f3ed1cbe423ab34454c8f7 100644
--- a/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
+++ b/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp
@@ -13,6 +13,49 @@
namespace blink {
+WebTaskRunner* TaskRunnerHelper::get(TaskType type, LocalFrame* frame)
+{
+ // TODO(haraken): Optimize the mapping from TaskTypes to task runners.
+ switch (type) {
+ case TaskType::DOMManipulation:
+ case TaskType::UserInteraction:
+ case TaskType::HistoryTraversal:
+ case TaskType::Embed:
+ case TaskType::MediaElementEvent:
+ case TaskType::CanvasBlobSerialization:
+ case TaskType::RemoteEvent:
+ case TaskType::WebSocket:
kinuko 2016/08/11 14:21:58 IIRC some of WebSocket tasks are posted as loading
Sami 2016/08/11 14:52:46 Good point -- we probably want to fix that.
+ case TaskType::Microtask:
+ case TaskType::PostedMessage:
+ case TaskType::UnshippedPortMessage:
+ case TaskType::Timer:
+ case TaskType::Internal:
+ return frame ? frame->frameScheduler()->timerTaskRunner() : Platform::current()->currentThread()->getWebTaskRunner();
+ case TaskType::Networking:
+ return frame ? frame->frameScheduler()->loadingTaskRunner() : Platform::current()->currentThread()->getWebTaskRunner();
+ case TaskType::Unthrottled:
+ return frame ? frame->frameScheduler()->unthrottledTaskRunner() : Platform::current()->currentThread()->getWebTaskRunner();
+ default:
+ NOTREACHED();
+ }
+ return nullptr;
+}
+
+WebTaskRunner* TaskRunnerHelper::get(TaskType type, Document* document)
+{
+ return get(type, document ? document->frame() : nullptr);
+}
+
+WebTaskRunner* TaskRunnerHelper::get(TaskType type, ExecutionContext* executionContext)
+{
+ return get(type, executionContext && executionContext->isDocument() ? static_cast<Document*>(executionContext) : nullptr);
+}
+
+WebTaskRunner* TaskRunnerHelper::get(TaskType type, ScriptState* scriptState)
+{
+ return get(type, scriptState ? scriptState->getExecutionContext() : nullptr);
+}
+
WebTaskRunner* TaskRunnerHelper::getUnthrottledTaskRunner(LocalFrame* frame)
{
return frame ? frame->frameScheduler()->unthrottledTaskRunner() : Platform::current()->currentThread()->getWebTaskRunner();
« no previous file with comments | « third_party/WebKit/Source/core/dom/TaskRunnerHelper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698