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

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

Issue 2912743002: [WIP] Worklet: Merge MainThreadWorklet and ThreadedWorklet into Worklet
Patch Set: WIP 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/Worklet.h
diff --git a/third_party/WebKit/Source/core/workers/Worklet.h b/third_party/WebKit/Source/core/workers/Worklet.h
index 7c2c2f222c15afc1b253065bda4635fc6a979abe..a8f59ea117dcd74b6dbad13c901d859edfa64bfc 100644
--- a/third_party/WebKit/Source/core/workers/Worklet.h
+++ b/third_party/WebKit/Source/core/workers/Worklet.h
@@ -8,6 +8,7 @@
#include "bindings/core/v8/ScriptPromise.h"
#include "core/CoreExport.h"
#include "core/dom/ContextLifecycleObserver.h"
+#include "core/workers/WorkletGlobalScopeProxy.h"
#include "core/workers/WorkletOptions.h"
#include "platform/bindings/ScriptWrappable.h"
#include "platform/heap/Handle.h"
@@ -37,16 +38,38 @@ class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>,
const String& module_url,
const WorkletOptions&);
+ // ContextLifecycleObserver
+ void ContextDestroyed(ExecutionContext*) final;
+
DECLARE_VIRTUAL_TRACE();
protected:
// The Worklet inherits the url and userAgent from the frame->document().
explicit Worklet(LocalFrame*);
+ // Returns one of available global scopes.
+ WorkletGlobalScopeProxy* FindAvailableGlobalScope() const;
+
+ size_t GetNumberOfGlobalScopes() const { return proxies_.size(); }
+
private:
- virtual void FetchAndInvokeScript(const KURL& module_url_record,
- const WorkletOptions&,
- ScriptPromiseResolver*) = 0;
+ void FetchAndInvokeScript(const KURL& module_url_record,
+ const WorkletOptions&,
+ ScriptPromiseResolver*);
+
+ // 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

Powered by Google App Engine
This is Rietveld 408576698