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

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

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.h
diff --git a/third_party/WebKit/Source/core/workers/MainThreadWorklet.h b/third_party/WebKit/Source/core/workers/MainThreadWorklet.h
index 998ab298423c43e06d00262cea343ab3d212918f..1b6fb78a858b0ce671c09a507c3a25129c80f02b 100644
--- a/third_party/WebKit/Source/core/workers/MainThreadWorklet.h
+++ b/third_party/WebKit/Source/core/workers/MainThreadWorklet.h
@@ -9,12 +9,14 @@
#include "bindings/core/v8/ScriptPromise.h"
#include "core/CoreExport.h"
+#include "core/workers/WorkletGlobalScopeManager.h"
#include "platform/heap/Handle.h"
namespace blink {
class LocalFrame;
class ScriptPromiseResolver;
+class WorkletGlobalScopeProxy;
// A MainThreadWorklet is a worklet that runs only on the main thread.
// TODO(nhiroki): This is a temporary class to support module loading for main
@@ -30,6 +32,10 @@ class CORE_EXPORT MainThreadWorklet : public Worklet {
// ContextLifecycleObserver
void ContextDestroyed(ExecutionContext*) final;
+ WorkletGlobalScopeManager& GetGlobalScopeManager() {
+ return *global_scope_manager_;
+ }
+
DECLARE_VIRTUAL_TRACE();
protected:
@@ -40,6 +46,14 @@ class CORE_EXPORT MainThreadWorklet : public Worklet {
void FetchAndInvokeScript(const KURL& module_url_record,
const WorkletOptions&,
ScriptPromiseResolver*) override;
+
+ // Returns true if there are no global scopes or additional global scopes are
+ // necessary. CreateGlobalScope() will be called in that case. Each worklet
+ // can define how to pool global scopes here.
+ virtual bool NeedsToCreateGlobalScope() = 0;
+ virtual std::unique_ptr<WorkletGlobalScopeProxy> CreateGlobalScope() = 0;
+
+ Member<WorkletGlobalScopeManager> global_scope_manager_;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698