| Index: third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
|
| diff --git a/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp b/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
|
| index 4d2c6f10b6428927b613355010abc027c280d6a6..3fbd50f64a4bc7de1ff23d0a19a8bb283e241ad5 100644
|
| --- a/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
|
| +++ b/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
|
| @@ -74,15 +74,13 @@ ScriptPromise MainThreadWorklet::addModule(ScriptState* script_state,
|
| // 10.2: "Add the WorkletGlobalScope to worklet's WorkletGlobalScopes."
|
| // "Depending on the type of worklet the user agent may create additional
|
| // WorkletGlobalScopes at this time."
|
| - // TODO(nhiroki): Create WorkletGlobalScopes at this point.
|
| + MayAddWorkletGlobalScopes();
|
| + DCHECK(!global_scope_proxies_.IsEmpty());
|
|
|
| // Step 11: "Let pendingTaskStruct be a new pending tasks struct with counter
|
| // initialized to the length of worklet's WorkletGlobalScopes."
|
| - // TODO(nhiroki): Introduce the concept of "worklet's WorkletGlobalScopes" and
|
| - // use the length of it here.
|
| - constexpr int number_of_global_scopes = 1;
|
| WorkletPendingTasks* pending_tasks =
|
| - new WorkletPendingTasks(number_of_global_scopes, resolver);
|
| + new WorkletPendingTasks(global_scope_proxies_.size(), resolver);
|
|
|
| // Step 12: "For each workletGlobalScope in the worklet's
|
| // WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and
|
| @@ -91,14 +89,16 @@ ScriptPromise MainThreadWorklet::addModule(ScriptState* script_state,
|
| // and promise."
|
| // TODO(nhiroki): Pass the remaining parameters (e.g., credentialOptions).
|
| // TODO(nhiroki): Queue a task instead of executing this here.
|
| - GetWorkletGlobalScopeProxy()->FetchAndInvokeScript(module_url_record,
|
| - pending_tasks);
|
| + for (const auto& proxy : global_scope_proxies_)
|
| + proxy->FetchAndInvokeScript(module_url_record, pending_tasks);
|
| +
|
| return promise;
|
| }
|
|
|
| void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) {
|
| DCHECK(IsMainThread());
|
| - GetWorkletGlobalScopeProxy()->TerminateWorkletGlobalScope();
|
| + for (const auto& proxy : global_scope_proxies_)
|
| + proxy->TerminateWorkletGlobalScope();
|
| Worklet::ContextDestroyed(execution_context);
|
| }
|
|
|
|
|