Chromium Code Reviews| 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 7ee88038c6ea4b3d289c0ca19eb814dbe9317a3e..dfa0b2d6d921cfb0078123e5f2c2d005cd5773d0 100644 |
| --- a/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp |
| +++ b/third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp |
| @@ -6,6 +6,8 @@ |
| #include "core/dom/Document.h" |
| #include "core/frame/LocalFrame.h" |
| +#include "core/workers/WorkerOrWorkletGlobalScope.h" |
| +#include "core/workers/WorkerThread.h" |
| #include "platform/WebFrameScheduler.h" |
| #include "platform/WebTaskRunner.h" |
| #include "public/platform/Platform.h" |
| @@ -62,9 +64,16 @@ RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) { |
| RefPtr<WebTaskRunner> TaskRunnerHelper::get( |
| TaskType type, |
| ExecutionContext* executionContext) { |
| - return get(type, executionContext && executionContext->isDocument() |
| - ? static_cast<Document*>(executionContext) |
| - : nullptr); |
| + if (!executionContext) |
| + return get(type, static_cast<Document*>(nullptr)); |
|
kinuko
2017/04/10 06:30:06
You can/should use ToDocument instead.
nhiroki
2017/04/11 10:47:54
Done.
|
| + if (executionContext->isDocument()) |
| + return get(type, static_cast<Document*>(executionContext)); |
| + if (executionContext->isWorkerOrWorkletGlobalScope()) { |
| + return get( |
| + type, |
| + static_cast<WorkerOrWorkletGlobalScope*>(executionContext)->thread()); |
| + } |
| + return get(type, static_cast<Document*>(nullptr)); |
| } |
| RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, |
| @@ -72,4 +81,36 @@ RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, |
| return get(type, scriptState ? scriptState->getExecutionContext() : nullptr); |
| } |
| +RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, |
| + WorkerThread* workerThread) { |
|
kinuko
2017/04/10 06:30:06
Could this just take WorkerOrWorkletGlobalScope in
nhiroki
2017/04/11 10:47:54
We could do the same thing as ParentFrameTaskRunne
kinuko
2017/04/12 09:47:44
Sorry my comment was probably unclear, what I felt
|
| + switch (type) { |
| + case TaskType::Timer: |
| + case TaskType::UnspecedLoading: |
| + case TaskType::Networking: |
| + case TaskType::DatabaseAccess: |
| + case TaskType::DOMManipulation: |
| + case TaskType::UserInteraction: |
| + case TaskType::HistoryTraversal: |
| + case TaskType::Embed: |
| + case TaskType::MediaElementEvent: |
| + case TaskType::CanvasBlobSerialization: |
| + case TaskType::RemoteEvent: |
| + case TaskType::WebSocket: |
| + case TaskType::Microtask: |
| + case TaskType::PostedMessage: |
| + case TaskType::UnshippedPortMessage: |
| + case TaskType::FileReading: |
| + case TaskType::Presentation: |
| + case TaskType::Sensor: |
| + case TaskType::PerformanceTimeline: |
| + case TaskType::WebGL: |
| + case TaskType::UnspecedTimer: |
| + case TaskType::MiscPlatformAPI: |
| + case TaskType::Unthrottled: |
| + return workerThread->globalScopeScheduler()->unthrottledTaskRunner(); |
|
kinuko
2017/04/10 06:30:06
Would be nice to have some comments as 'unthrottle
Sami
2017/04/10 16:58:10
+1
|
| + } |
| + NOTREACHED(); |
| + return nullptr; |
| +} |
| + |
| } // namespace blink |