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" | |
13 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
14 | 13 |
15 namespace blink { | 14 namespace blink { |
16 | 15 |
17 class LocalFrame; | 16 class LocalFrame; |
18 | 17 |
19 // A MainThreadWorklet is a worklet that runs only on the main thread. | 18 // 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 | 19 // 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 | 20 // thread worklets. This and ThreadedWorklet will be merged into the base |
22 // Worklet class once threaded worklets are ready to use module loading. | 21 // Worklet class once threaded worklets are ready to use module loading. |
23 class CORE_EXPORT MainThreadWorklet : public Worklet, | 22 class CORE_EXPORT MainThreadWorklet : public Worklet { |
24 public WorkletObjectProxy { | |
25 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); | 23 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); |
26 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); | 24 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); |
27 | 25 |
28 public: | 26 public: |
29 virtual ~MainThreadWorklet() = default; | 27 virtual ~MainThreadWorklet() = default; |
30 | 28 |
31 // Worklet | 29 // Worklet |
32 ScriptPromise addModule(ScriptState*, const String& url) final; | 30 ScriptPromise addModule(ScriptState*, const String& module_url) final; |
33 | 31 |
34 // ContextLifecycleObserver | 32 // ContextLifecycleObserver |
35 void ContextDestroyed(ExecutionContext*) final; | 33 void ContextDestroyed(ExecutionContext*) final; |
36 | 34 |
37 // WorkletObjectProxy | |
38 void DidFetchAndInvokeScript(int32_t request_id, bool success) final; | |
39 | |
40 DECLARE_VIRTUAL_TRACE(); | 35 DECLARE_VIRTUAL_TRACE(); |
41 | 36 |
42 protected: | 37 protected: |
43 explicit MainThreadWorklet(LocalFrame*); | 38 explicit MainThreadWorklet(LocalFrame*); |
44 | |
45 private: | |
46 HeapHashMap<int32_t /* request_id */, Member<ScriptPromiseResolver>> | |
47 resolver_map_; | |
48 }; | 39 }; |
49 | 40 |
50 } // namespace blink | 41 } // namespace blink |
51 | 42 |
52 #endif // MainThreadWorklet_h | 43 #endif // MainThreadWorklet_h |
OLD | NEW |