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

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

Issue 2826313003: Worklet: Enable module script loading for main thread worklets (Closed)
Patch Set: rebase 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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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* executionContext) {
70 if (!executionContext) 71 if (!executionContext)
71 return Get(type, ToDocument(executionContext)); 72 return Get(type, ToDocument(executionContext));
72 if (executionContext->IsDocument()) 73 if (executionContext->IsDocument())
73 return Get(type, ToDocument(executionContext)); 74 return Get(type, ToDocument(executionContext));
75 if (executionContext->IsMainThreadWorkletGlobalScope()) {
76 return Get(type,
77 ToMainThreadWorkletGlobalScope(executionContext)->GetFrame());
78 }
74 if (executionContext->IsWorkerOrWorkletGlobalScope()) 79 if (executionContext->IsWorkerOrWorkletGlobalScope())
75 return Get(type, ToWorkerOrWorkletGlobalScope(executionContext)); 80 return Get(type, ToWorkerOrWorkletGlobalScope(executionContext));
76 executionContext = nullptr; 81 executionContext = nullptr;
77 return Get(type, ToDocument(executionContext)); 82 return Get(type, ToDocument(executionContext));
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);
(...skipping 37 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

Powered by Google App Engine
This is Rietveld 408576698