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 | 18 |
19 // A MainThreadWorklet is a worklet that runs only on the main thread. | 19 // 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 | 20 // 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 | 21 // thread worklets. This and ThreadedWorklet will be merged into the base |
22 // Worklet class once threaded worklets are ready to use module loading. | 22 // Worklet class once threaded worklets are ready to use module loading. |
23 class CORE_EXPORT MainThreadWorklet : public Worklet { | 23 class CORE_EXPORT MainThreadWorklet : public Worklet { |
24 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); | 24 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); |
25 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); | 25 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); |
26 | 26 |
27 public: | 27 public: |
28 virtual ~MainThreadWorklet() = default; | 28 virtual ~MainThreadWorklet() = default; |
29 | 29 |
30 // Worklet | |
31 ScriptPromise addModule(ScriptState*, const String& module_url) final; | |
32 | |
33 // ContextLifecycleObserver | 30 // ContextLifecycleObserver |
34 void ContextDestroyed(ExecutionContext*) final; | 31 void ContextDestroyed(ExecutionContext*) final; |
35 | 32 |
36 DECLARE_VIRTUAL_TRACE(); | 33 DECLARE_VIRTUAL_TRACE(); |
37 | 34 |
38 protected: | 35 protected: |
39 explicit MainThreadWorklet(LocalFrame*); | 36 explicit MainThreadWorklet(LocalFrame*); |
40 | 37 |
41 private: | 38 private: |
| 39 // Worklet. |
42 void FetchAndInvokeScript(const KURL& module_url_record, | 40 void FetchAndInvokeScript(const KURL& module_url_record, |
43 ScriptPromiseResolver*); | 41 ScriptPromiseResolver*) override; |
44 }; | 42 }; |
45 | 43 |
46 } // namespace blink | 44 } // namespace blink |
47 | 45 |
48 #endif // MainThreadWorklet_h | 46 #endif // MainThreadWorklet_h |
OLD | NEW |