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

Side by Side Diff: third_party/WebKit/Source/core/workers/MainThreadWorklet.h

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MainThreadWorklet_h 5 #ifndef MainThreadWorklet_h
6 #define MainThreadWorklet_h 6 #define MainThreadWorklet_h
7 7
8 #include "core/workers/Worklet.h" 8 #include "core/workers/Worklet.h"
9 9
10 #include "bindings/core/v8/ScriptPromise.h" 10 #include "bindings/core/v8/ScriptPromise.h"
11 #include "core/CoreExport.h" 11 #include "core/CoreExport.h"
12 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class LocalFrame; 16 class LocalFrame;
17 class ScriptPromiseResolver; 17 class ScriptPromiseResolver;
18 class WorkletGlobalScopeProxy;
18 19
19 // A MainThreadWorklet is a worklet that runs only on the main thread. 20 // A MainThreadWorklet is a worklet that runs only on the main thread.
20 // TODO(nhiroki): This is a temporary class to support module loading for main 21 // TODO(nhiroki): This is a temporary class to support module loading for main
21 // thread worklets. This and ThreadedWorklet will be merged into the base 22 // thread worklets. This and ThreadedWorklet will be merged into the base
22 // Worklet class once threaded worklets are ready to use module loading. 23 // Worklet class once threaded worklets are ready to use module loading.
23 class CORE_EXPORT MainThreadWorklet : public Worklet { 24 class CORE_EXPORT MainThreadWorklet : public Worklet {
24 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); 25 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet);
25 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); 26 WTF_MAKE_NONCOPYABLE(MainThreadWorklet);
26 27
27 public: 28 public:
28 virtual ~MainThreadWorklet() = default; 29 virtual ~MainThreadWorklet() = default;
29 30
30 // Worklet 31 // Worklet
31 ScriptPromise addModule(ScriptState*, const String& module_url) final; 32 ScriptPromise addModule(ScriptState*, const String& module_url) final;
32 33
33 // ContextLifecycleObserver 34 // ContextLifecycleObserver
34 void ContextDestroyed(ExecutionContext*) final; 35 void ContextDestroyed(ExecutionContext*) final;
35 36
36 DECLARE_VIRTUAL_TRACE(); 37 DECLARE_VIRTUAL_TRACE();
37 38
38 protected: 39 protected:
39 explicit MainThreadWorklet(LocalFrame*); 40 explicit MainThreadWorklet(LocalFrame*);
40 41
42 // Creates WorkletGlobalScope and adds it into |global_scope_proxies_| if
43 // there are not global scopes or additional global scopes are necessary.
44 virtual void AddWorkletGlobalScopesIfNeeded() = 0;
kouhei (in TOK) 2017/05/08 13:13:19 Can we have a virtual WorkletGlobalScopeProxy* Cre
nhiroki 2017/05/10 09:01:31 Replaced this with NeedsToCreateGlobalScope() and
45
46 // "A Worklet has a list of the worklet's WorkletGlobalScopes. Initially this
47 // list is empty; it is populated when the user agent chooses to create its
48 // WorkletGlobalScope."
49 // https://drafts.css-houdini.org/worklets/#worklet-section
50 // TODO(nhiroki): Make (Paint)WorkletGlobalScopeProxy GC-managed object to
51 // avoid that GC graphs are disjointed (PaintWorkletGlobalScopeProxy has a
52 // persistent holder for PaintWorkletGlobalscope).
kouhei (in TOK) 2017/05/08 13:13:19 +1. Can we give a crbug # to this?
nhiroki 2017/05/10 09:01:31 Added a crbug link.
53 WTF::HashSet<std::unique_ptr<WorkletGlobalScopeProxy>> global_scope_proxies_;
54
41 private: 55 private:
42 void FetchAndInvokeScript(const KURL& module_url_record, 56 void FetchAndInvokeScript(const KURL& module_url_record,
43 ScriptPromiseResolver*); 57 ScriptPromiseResolver*);
44 }; 58 };
45 59
46 } // namespace blink 60 } // namespace blink
47 61
48 #endif // MainThreadWorklet_h 62 #endif // MainThreadWorklet_h
OLDNEW
« 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