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

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

Issue 2840523002: [DONT COMMIT] Worklet: Implement "addModule()" algorithm 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 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/ScriptSourceCode.h" 7 #include "bindings/core/v8/ScriptSourceCode.h"
8 #include "bindings/core/v8/V8BindingForCore.h" 8 #include "bindings/core/v8/V8BindingForCore.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // type." 67 // type."
68 // workletGlobalScopeType is encoded into the class name (e.g., PaintWorklet). 68 // workletGlobalScopeType is encoded into the class name (e.g., PaintWorklet).
69 69
70 // Step 10: "If the worklet's WorkletGlobalScopes is empty, run the following 70 // Step 10: "If the worklet's WorkletGlobalScopes is empty, run the following
71 // steps:" 71 // steps:"
72 // 10.1: "Create a WorkletGlobalScope given workletGlobalScopeType, 72 // 10.1: "Create a WorkletGlobalScope given workletGlobalScopeType,
73 // moduleResponsesMap, and outsideSettings." 73 // moduleResponsesMap, and outsideSettings."
74 // 10.2: "Add the WorkletGlobalScope to worklet's WorkletGlobalScopes." 74 // 10.2: "Add the WorkletGlobalScope to worklet's WorkletGlobalScopes."
75 // "Depending on the type of worklet the user agent may create additional 75 // "Depending on the type of worklet the user agent may create additional
76 // WorkletGlobalScopes at this time." 76 // WorkletGlobalScopes at this time."
77 // TODO(nhiroki): Create WorkletGlobalScopes at this point. 77 MayAddWorkletGlobalScopes();
78 DCHECK(!global_scope_proxies_.IsEmpty());
78 79
79 // Step 11: "Let pendingTaskStruct be a new pending tasks struct with counter 80 // Step 11: "Let pendingTaskStruct be a new pending tasks struct with counter
80 // initialized to the length of worklet's WorkletGlobalScopes." 81 // initialized to the length of worklet's WorkletGlobalScopes."
81 // TODO(nhiroki): Introduce the concept of "worklet's WorkletGlobalScopes" and
82 // use the length of it here.
83 constexpr int number_of_global_scopes = 1;
84 WorkletPendingTasks* pending_tasks = 82 WorkletPendingTasks* pending_tasks =
85 new WorkletPendingTasks(number_of_global_scopes, resolver); 83 new WorkletPendingTasks(global_scope_proxies_.size(), resolver);
86 84
87 // Step 12: "For each workletGlobalScope in the worklet's 85 // Step 12: "For each workletGlobalScope in the worklet's
88 // WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and 86 // WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and
89 // invoke a worklet script given workletGlobalScope, moduleURLRecord, 87 // invoke a worklet script given workletGlobalScope, moduleURLRecord,
90 // moduleResponsesMap, credentialOptions, outsideSettings, pendingTaskStruct, 88 // moduleResponsesMap, credentialOptions, outsideSettings, pendingTaskStruct,
91 // and promise." 89 // and promise."
92 // TODO(nhiroki): Pass the remaining parameters (e.g., credentialOptions). 90 // TODO(nhiroki): Pass the remaining parameters (e.g., credentialOptions).
93 // TODO(nhiroki): Queue a task instead of executing this here. 91 // TODO(nhiroki): Queue a task instead of executing this here.
94 GetWorkletGlobalScopeProxy()->FetchAndInvokeScript(module_url_record, 92 for (const auto& proxy : global_scope_proxies_)
95 pending_tasks); 93 proxy->FetchAndInvokeScript(module_url_record, pending_tasks);
94
96 return promise; 95 return promise;
97 } 96 }
98 97
99 void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) { 98 void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) {
100 DCHECK(IsMainThread()); 99 DCHECK(IsMainThread());
101 GetWorkletGlobalScopeProxy()->TerminateWorkletGlobalScope(); 100 for (const auto& proxy : global_scope_proxies_)
101 proxy->TerminateWorkletGlobalScope();
102 Worklet::ContextDestroyed(execution_context); 102 Worklet::ContextDestroyed(execution_context);
103 } 103 }
104 104
105 DEFINE_TRACE(MainThreadWorklet) { 105 DEFINE_TRACE(MainThreadWorklet) {
106 Worklet::Trace(visitor); 106 Worklet::Trace(visitor);
107 } 107 }
108 108
109 } // namespace blink 109 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/workers/MainThreadWorklet.h ('k') | third_party/WebKit/Source/core/workers/ThreadedWorklet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698