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/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
11 #include "core/CoreExport.h" | 11 #include "core/CoreExport.h" |
12 #include "core/workers/WorkletObjectProxy.h" | 12 #include "core/workers/WorkletObjectProxy.h" |
13 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class LocalFrame; | 17 class LocalFrame; |
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 public WorkletObjectProxy { | 25 public WorkletObjectProxy { |
25 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); | 26 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); |
26 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); | 27 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); |
27 | 28 |
28 public: | 29 public: |
29 virtual ~MainThreadWorklet() = default; | 30 virtual ~MainThreadWorklet() = default; |
30 | 31 |
31 // Worklet | 32 // Worklet |
32 ScriptPromise addModule(ScriptState*, const String& url) final; | 33 ScriptPromise addModule(ScriptState*, const String& url) final; |
33 | 34 |
34 // ContextLifecycleObserver | 35 // ContextLifecycleObserver |
35 void ContextDestroyed(ExecutionContext*) final; | 36 void ContextDestroyed(ExecutionContext*) final; |
36 | 37 |
37 // WorkletObjectProxy | 38 // WorkletObjectProxy |
38 void DidFetchAndInvokeScript(int32_t request_id, bool success) final; | 39 void DidFetchAndInvokeScript(int32_t request_id, bool success) final; |
39 | 40 |
40 DECLARE_VIRTUAL_TRACE(); | 41 DECLARE_VIRTUAL_TRACE(); |
41 | 42 |
42 protected: | 43 protected: |
43 explicit MainThreadWorklet(LocalFrame*); | 44 explicit MainThreadWorklet(LocalFrame*); |
44 | 45 |
46 virtual void CreateWorkletGlobalScope(); | |
47 | |
48 // "A Worklet has a list of the worklet's WorkletGlobalScopes. Initially this | |
kouhei (in TOK)
2017/04/25 11:55:18
Provide link to the spec
| |
49 // list is empty; it is populated when the user agent chooses to create its | |
50 // WorkletGlobalScope." | |
51 WTF::HashSet<std::unique_ptr<WorkletGlobalScopeProxy>> global_scope_proxies_; | |
52 | |
45 private: | 53 private: |
46 HeapHashMap<int32_t /* request_id */, Member<ScriptPromiseResolver>> | 54 struct PendingTasks; |
47 resolver_map_; | 55 // TODO(nhiroki): We could replace |request_id| with |url|. |
56 HeapHashMap<int32_t /* request_id */, Member<PendingTasks>> | |
57 pending_tasks_map_; | |
48 }; | 58 }; |
49 | 59 |
50 } // namespace blink | 60 } // namespace blink |
51 | 61 |
52 #endif // MainThreadWorklet_h | 62 #endif // MainThreadWorklet_h |
OLD | NEW |