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

Side by Side Diff: third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp

Issue 2910953002: Worklet: Enqueue tasks into outsideSetting's event loop (Closed)
Patch Set: add comments Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/workers/MainThreadWorklet.h" 5 #include "core/workers/MainThreadWorklet.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/ScriptSourceCode.h" 8 #include "bindings/core/v8/ScriptSourceCode.h"
9 #include "bindings/core/v8/V8BindingForCore.h" 9 #include "bindings/core/v8/V8BindingForCore.h"
10 #include "core/dom/Document.h"
10 #include "core/frame/LocalFrame.h" 11 #include "core/frame/LocalFrame.h"
12 #include "core/workers/ParentFrameTaskRunners.h"
11 #include "core/workers/WorkletGlobalScopeProxy.h" 13 #include "core/workers/WorkletGlobalScopeProxy.h"
12 #include "core/workers/WorkletPendingTasks.h" 14 #include "core/workers/WorkletPendingTasks.h"
13 #include "platform/wtf/WTF.h" 15 #include "platform/wtf/WTF.h"
14 #include "public/platform/WebURLRequest.h" 16 #include "public/platform/WebURLRequest.h"
15 17
16 namespace blink { 18 namespace blink {
17 19
18 namespace { 20 namespace {
19 21
20 WebURLRequest::FetchCredentialsMode ParseCredentialsOption( 22 WebURLRequest::FetchCredentialsMode ParseCredentialsOption(
(...skipping 28 matching lines...) Expand all
49 DCHECK(IsMainThread()); 51 DCHECK(IsMainThread());
50 if (!GetExecutionContext()) 52 if (!GetExecutionContext())
51 return; 53 return;
52 54
53 // Step 6: "Let credentialOptions be the credentials member of options." 55 // Step 6: "Let credentialOptions be the credentials member of options."
54 // TODO(nhiroki): Add tests for credentialOptions (https://crbug.com/710837). 56 // TODO(nhiroki): Add tests for credentialOptions (https://crbug.com/710837).
55 WebURLRequest::FetchCredentialsMode credentials_mode = 57 WebURLRequest::FetchCredentialsMode credentials_mode =
56 ParseCredentialsOption(options.credentials()); 58 ParseCredentialsOption(options.credentials());
57 59
58 // Step 7: "Let outsideSettings be the relevant settings object of this." 60 // Step 7: "Let outsideSettings be the relevant settings object of this."
59 // TODO(nhiroki): outsideSettings will be used for posting a task to the 61 // In the specification, outsideSettings is used for posting a task to the
60 // document's responsible event loop. We could use a task runner for the 62 // document's responsible event loop. In our implementation,
61 // purpose. 63 // ParentFrameTaskRunners does this.
kinuko 2017/05/30 02:32:58 Do we want to pass the entire ParentFrameTaskRunne
nhiroki 2017/05/30 04:03:40 We don't need the entire task runners. Changed.
64 auto task_runners = ParentFrameTaskRunners::Create(
65 ToDocument(GetExecutionContext())->GetFrame());
62 66
63 // Step 8: "Let moduleResponsesMap be worklet's module responses map." 67 // Step 8: "Let moduleResponsesMap be worklet's module responses map."
64 // TODO(nhiroki): Implement moduleResponsesMap (https://crbug.com/627945). 68 // TODO(nhiroki): Implement moduleResponsesMap (https://crbug.com/627945).
65 69
66 // Step 9: "Let workletGlobalScopeType be worklet's worklet global scope 70 // Step 9: "Let workletGlobalScopeType be worklet's worklet global scope
67 // type." 71 // type."
68 // workletGlobalScopeType is encoded into the class name (e.g., PaintWorklet). 72 // workletGlobalScopeType is encoded into the class name (e.g., PaintWorklet).
69 73
70 // Step 10: "If the worklet's WorkletGlobalScopes is empty, run the following 74 // Step 10: "If the worklet's WorkletGlobalScopes is empty, run the following
71 // steps:" 75 // steps:"
(...skipping 12 matching lines...) Expand all
84 new WorkletPendingTasks(GetNumberOfGlobalScopes(), resolver); 88 new WorkletPendingTasks(GetNumberOfGlobalScopes(), resolver);
85 89
86 // Step 12: "For each workletGlobalScope in the worklet's 90 // Step 12: "For each workletGlobalScope in the worklet's
87 // WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and 91 // WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and
88 // invoke a worklet script given workletGlobalScope, moduleURLRecord, 92 // invoke a worklet script given workletGlobalScope, moduleURLRecord,
89 // moduleResponsesMap, credentialOptions, outsideSettings, pendingTaskStruct, 93 // moduleResponsesMap, credentialOptions, outsideSettings, pendingTaskStruct,
90 // and promise." 94 // and promise."
91 // TODO(nhiroki): Queue a task instead of executing this here. 95 // TODO(nhiroki): Queue a task instead of executing this here.
92 for (const auto& proxy : proxies_) { 96 for (const auto& proxy : proxies_) {
93 proxy->FetchAndInvokeScript(module_url_record, credentials_mode, 97 proxy->FetchAndInvokeScript(module_url_record, credentials_mode,
94 pending_tasks); 98 task_runners, pending_tasks);
95 } 99 }
96 } 100 }
97 101
98 void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) { 102 void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) {
99 DCHECK(IsMainThread()); 103 DCHECK(IsMainThread());
100 for (const auto& proxy : proxies_) 104 for (const auto& proxy : proxies_)
101 proxy->TerminateWorkletGlobalScope(); 105 proxy->TerminateWorkletGlobalScope();
102 } 106 }
103 107
104 DEFINE_TRACE(MainThreadWorklet) { 108 DEFINE_TRACE(MainThreadWorklet) {
105 Worklet::Trace(visitor); 109 Worklet::Trace(visitor);
106 } 110 }
107 111
108 } // namespace blink 112 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698