OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Worklet_h | 5 #ifndef Worklet_h |
6 #define Worklet_h | 6 #define Worklet_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
11 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.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 WorkletGlobalScopeProxy; | |
18 | 17 |
19 // This is the base implementation of Worklet interface defined in the spec: | 18 // This is the base implementation of Worklet interface defined in the spec: |
20 // https://drafts.css-houdini.org/worklets/#worklet | 19 // https://drafts.css-houdini.org/worklets/#worklet |
21 // Although some worklets run off the main thread, this must be created and | 20 // Although some worklets run off the main thread, this must be created and |
22 // destroyed on the main thread. | 21 // destroyed on the main thread. |
23 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, | 22 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, |
24 public ScriptWrappable, | 23 public ScriptWrappable, |
25 public ContextLifecycleObserver { | 24 public ContextLifecycleObserver { |
26 DEFINE_WRAPPERTYPEINFO(); | 25 DEFINE_WRAPPERTYPEINFO(); |
27 USING_GARBAGE_COLLECTED_MIXIN(Worklet); | 26 USING_GARBAGE_COLLECTED_MIXIN(Worklet); |
28 WTF_MAKE_NONCOPYABLE(Worklet); | 27 WTF_MAKE_NONCOPYABLE(Worklet); |
29 | 28 |
30 public: | 29 public: |
31 virtual ~Worklet() = default; | 30 virtual ~Worklet() = default; |
32 | 31 |
33 // Worklet.idl | 32 // Worklet.idl |
34 // addModule() imports ES6 module scripts. | 33 // addModule() imports ES6 module scripts. |
35 virtual ScriptPromise addModule(ScriptState*, const String& module_url) = 0; | 34 virtual ScriptPromise addModule(ScriptState*, const String& module_url) = 0; |
36 | 35 |
37 // Returns a proxy to WorkletGlobalScope on the context thread. | |
38 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; | |
39 | |
40 // ContextLifecycleObserver | 36 // ContextLifecycleObserver |
41 virtual void ContextDestroyed(ExecutionContext*); | 37 virtual void ContextDestroyed(ExecutionContext*); |
42 | 38 |
43 DECLARE_VIRTUAL_TRACE(); | 39 DECLARE_VIRTUAL_TRACE(); |
44 | 40 |
45 protected: | 41 protected: |
46 // The Worklet inherits the url and userAgent from the frame->document(). | 42 // The Worklet inherits the url and userAgent from the frame->document(). |
47 explicit Worklet(LocalFrame*); | 43 explicit Worklet(LocalFrame*); |
48 | 44 |
49 Member<LocalFrame> frame_; | 45 Member<LocalFrame> frame_; |
50 }; | 46 }; |
51 | 47 |
52 } // namespace blink | 48 } // namespace blink |
53 | 49 |
54 #endif // Worklet_h | 50 #endif // Worklet_h |
OLD | NEW |