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

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

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: fix wrong dcheck 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..72b1bc696d81119516e0e6067d2d6fb14decc9f9 100644
--- a/third_party/WebKit/Source/core/workers/MainThreadWorklet.h
+++ b/third_party/WebKit/Source/core/workers/MainThreadWorklet.h
@@ -15,6 +15,7 @@ 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
@@ -35,11 +36,30 @@ class CORE_EXPORT MainThreadWorklet : public Worklet {
protected:
explicit MainThreadWorklet(LocalFrame*);
+ // Returns one of available global scopes.
+ WorkletGlobalScopeProxy* FindAvailableGlobalScope() const;
+
+ size_t GetNumberOfGlobalScopes() const { return proxies_.size(); }
+
private:
// 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;
+
+ // "A Worklet has a list of the worklet's WorkletGlobalScopes. Initially this
+ // list is empty; it is populated when the user agent chooses to create its
+ // WorkletGlobalScope."
+ // https://drafts.css-houdini.org/worklets/#worklet-section
+ // TODO(nhiroki): Make (Paint)WorkletGlobalScopeProxy GC-managed object to
+ // avoid that GC graphs are disjointed (https://crbug.com/719775).
+ HashSet<std::unique_ptr<WorkletGlobalScopeProxy>> proxies_;
};
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698