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

Unified Diff: third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: clean up 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 side-by-side diff with in-line comments
Download patch
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 43ac12846daf9ddca9a6050301035f5223636844..1b1c7d1de6b2f8b36c7740695cc215b59a0ef7b3 100644
--- a/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
+++ b/third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp
@@ -31,7 +31,8 @@ WebURLRequest::FetchCredentialsMode ParseCredentialsOption(
} // namespace
-MainThreadWorklet::MainThreadWorklet(LocalFrame* frame) : Worklet(frame) {}
+MainThreadWorklet::MainThreadWorklet(LocalFrame* frame)
+ : Worklet(frame), global_scope_manager_(new WorkletGlobalScopeManager) {}
// Implementation of the second half of the "addModule(moduleURL, options)"
// algorithm:
@@ -67,15 +68,15 @@ void MainThreadWorklet::FetchAndInvokeScript(const KURL& module_url_record,
// 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.
+ while (NeedsToCreateGlobalScope())
+ GetGlobalScopeManager().AddGlobalScope(CreateGlobalScope());
+ DCHECK_LT(0u, GetGlobalScopeManager().GetNumberOfGlobalScopes());
// 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;
+ size_t length = GetGlobalScopeManager().GetNumberOfGlobalScopes();
WorkletPendingTasks* pending_tasks =
- new WorkletPendingTasks(number_of_global_scopes, resolver);
+ new WorkletPendingTasks(length, resolver);
// Step 12: "For each workletGlobalScope in the worklet's
// WorkletGlobalScopes, queue a task on the workletGlobalScope to fetch and
@@ -83,16 +84,17 @@ void MainThreadWorklet::FetchAndInvokeScript(const KURL& module_url_record,
// moduleResponsesMap, credentialOptions, outsideSettings, pendingTaskStruct,
// and promise."
// TODO(nhiroki): Queue a task instead of executing this here.
- GetWorkletGlobalScopeProxy()->FetchAndInvokeScript(
+ GetGlobalScopeManager().AddModuleToGlobalScopes(
module_url_record, credentials_mode, pending_tasks);
}
void MainThreadWorklet::ContextDestroyed(ExecutionContext* execution_context) {
DCHECK(IsMainThread());
- GetWorkletGlobalScopeProxy()->TerminateWorkletGlobalScope();
+ GetGlobalScopeManager().TerminateGlobalScopes();
}
DEFINE_TRACE(MainThreadWorklet) {
+ visitor->Trace(global_scope_manager_);
Worklet::Trace(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698