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

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

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: add more class-level comments 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..6e123efc18bb0d6c5e7c7c9f8c49c6d8d711ff89 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).
+ WTF::HashSet<std::unique_ptr<WorkletGlobalScopeProxy>> proxies_;
haraken 2017/05/29 07:38:48 WTF:: is not needed.
nhiroki 2017/05/29 08:52:00 Done.
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698