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

Side by Side Diff: third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp

Issue 2870273002: Worklet: Enable TaskRunnerHelper to handle MainThreadWorkletGlobalScope (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/TaskRunnerHelper.h" 5 #include "core/dom/TaskRunnerHelper.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ExecutionContext.h" 8 #include "core/dom/ExecutionContext.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/workers/MainThreadWorkletGlobalScope.h"
10 #include "core/workers/WorkerOrWorkletGlobalScope.h" 11 #include "core/workers/WorkerOrWorkletGlobalScope.h"
11 #include "core/workers/WorkerThread.h" 12 #include "core/workers/WorkerThread.h"
12 #include "platform/WebFrameScheduler.h" 13 #include "platform/WebFrameScheduler.h"
13 #include "platform/WebTaskRunner.h" 14 #include "platform/WebTaskRunner.h"
14 #include "public/platform/Platform.h" 15 #include "public/platform/Platform.h"
15 #include "public/platform/WebThread.h" 16 #include "public/platform/WebThread.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, LocalFrame* frame) { 20 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, LocalFrame* frame) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 NOTREACHED(); 60 NOTREACHED();
60 return nullptr; 61 return nullptr;
61 } 62 }
62 63
63 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, Document* document) { 64 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, Document* document) {
64 return Get(type, document ? document->GetFrame() : nullptr); 65 return Get(type, document ? document->GetFrame() : nullptr);
65 } 66 }
66 67
67 RefPtr<WebTaskRunner> TaskRunnerHelper::Get( 68 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(
68 TaskType type, 69 TaskType type,
69 ExecutionContext* executionContext) { 70 ExecutionContext* execution_context) {
70 if (!executionContext) 71 if (!execution_context)
71 return Get(type, ToDocument(executionContext)); 72 return Get(type, ToDocument(execution_context));
72 if (executionContext->IsDocument()) 73 if (execution_context->IsDocument())
73 return Get(type, ToDocument(executionContext)); 74 return Get(type, ToDocument(execution_context));
74 if (executionContext->IsWorkerOrWorkletGlobalScope()) 75 if (execution_context->IsMainThreadWorkletGlobalScope()) {
75 return Get(type, ToWorkerOrWorkletGlobalScope(executionContext)); 76 return Get(type,
76 executionContext = nullptr; 77 ToMainThreadWorkletGlobalScope(execution_context)->GetFrame());
77 return Get(type, ToDocument(executionContext)); 78 }
79 if (execution_context->IsWorkerOrWorkletGlobalScope())
80 return Get(type, ToWorkerOrWorkletGlobalScope(execution_context));
81 execution_context = nullptr;
82 return Get(type, ToDocument(execution_context));
kinuko (google) 2017/05/10 01:04:46 would Get(type, ToDocument(nullptr)) work? actual
nhiroki 2017/05/10 01:15:41 I tried it before but the compiler complained: htt
78 } 83 }
79 84
80 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, 85 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type,
81 ScriptState* script_state) { 86 ScriptState* script_state) {
82 return Get(type, 87 return Get(type,
83 script_state ? ExecutionContext::From(script_state) : nullptr); 88 script_state ? ExecutionContext::From(script_state) : nullptr);
84 } 89 }
85 90
86 RefPtr<WebTaskRunner> TaskRunnerHelper::Get( 91 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(
87 TaskType type, 92 TaskType type,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // TODO(nhiroki): Identify which tasks can be throttled / suspendable and 126 // TODO(nhiroki): Identify which tasks can be throttled / suspendable and
122 // move them into other task runners. See also comments in 127 // move them into other task runners. See also comments in
123 // Get(LocalFrame). (https://crbug.com/670534) 128 // Get(LocalFrame). (https://crbug.com/670534)
124 return worker_thread->GetGlobalScopeScheduler()->UnthrottledTaskRunner(); 129 return worker_thread->GetGlobalScopeScheduler()->UnthrottledTaskRunner();
125 } 130 }
126 NOTREACHED(); 131 NOTREACHED();
127 return nullptr; 132 return nullptr;
128 } 133 }
129 134
130 } // namespace blink 135 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698