OLD | NEW |
---|---|
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 // ContextLifecycleObserver | 31 // ContextLifecycleObserver |
31 void ContextDestroyed(ExecutionContext*) final; | 32 void ContextDestroyed(ExecutionContext*) final; |
32 | 33 |
33 DECLARE_VIRTUAL_TRACE(); | 34 DECLARE_VIRTUAL_TRACE(); |
34 | 35 |
35 protected: | 36 protected: |
36 explicit MainThreadWorklet(LocalFrame*); | 37 explicit MainThreadWorklet(LocalFrame*); |
37 | 38 |
39 WTF::HashSet<std::unique_ptr<WorkletGlobalScopeProxy>>& GetProxies() { | |
kouhei (in TOK)
2017/05/12 16:37:10
I'd want to avoid this as much as possible.
Pleas
falken
2017/05/15 05:14:48
For my edification, what is "this" that you want t
nhiroki
2017/05/22 00:52:33
I guess he'd like to avoid exposing a reference to
kinuko
2017/05/22 02:51:04
Fwiw I think it's still possible to expose this ki
nhiroki
2017/05/24 05:12:21
Fair enough.
| |
40 return global_scope_proxies_; | |
41 } | |
42 | |
38 private: | 43 private: |
39 // Worklet. | 44 // Worklet. |
40 void FetchAndInvokeScript(const KURL& module_url_record, | 45 void FetchAndInvokeScript(const KURL& module_url_record, |
41 const WorkletOptions&, | 46 const WorkletOptions&, |
42 ScriptPromiseResolver*) override; | 47 ScriptPromiseResolver*) override; |
48 | |
49 // Returns true if there are no global scopes or additional global scopes are | |
50 // necessary. CreateGlobalScope() will be called in that case. Each worklet | |
51 // can define how to pool global scopes here. | |
52 virtual bool NeedsToCreateGlobalScope() = 0; | |
53 virtual std::unique_ptr<WorkletGlobalScopeProxy> CreateGlobalScope() = 0; | |
54 | |
55 // "A Worklet has a list of the worklet's WorkletGlobalScopes. Initially this | |
56 // list is empty; it is populated when the user agent chooses to create its | |
57 // WorkletGlobalScope." | |
58 // https://drafts.css-houdini.org/worklets/#worklet-section | |
59 // TODO(nhiroki): Make (Paint)WorkletGlobalScopeProxy GC-managed object to | |
60 // avoid that GC graphs are disjointed (https://crbug.com/719775). | |
61 WTF::HashSet<std::unique_ptr<WorkletGlobalScopeProxy>> global_scope_proxies_; | |
43 }; | 62 }; |
44 | 63 |
45 } // namespace blink | 64 } // namespace blink |
46 | 65 |
47 #endif // MainThreadWorklet_h | 66 #endif // MainThreadWorklet_h |
OLD | NEW |