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/ActiveDOMObject.h" | 11 #include "core/dom/ActiveDOMObject.h" |
12 #include "core/fetch/ScriptResource.h" | 12 #include "core/fetch/ScriptResource.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 ResourceFetcher; | 18 class ResourceFetcher; |
19 class WorkletGlobalScopeProxy; | 19 class WorkletGlobalScopeProxy; |
20 class WorkletScriptLoader; | 20 class WorkletScriptLoader; |
21 | 21 |
22 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, public Sc
riptWrappable, public ActiveDOMObject { | 22 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, public Sc
riptWrappable, public ActiveDOMObject { |
23 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
24 USING_GARBAGE_COLLECTED_MIXIN(Worklet); | 24 USING_GARBAGE_COLLECTED_MIXIN(Worklet); |
25 WTF_MAKE_NONCOPYABLE(Worklet); | 25 WTF_MAKE_NONCOPYABLE(Worklet); |
26 public: | 26 public: |
| 27 virtual void initialize() {} |
| 28 virtual bool isInitialized() const { return true; } |
| 29 |
27 virtual WorkletGlobalScopeProxy* workletGlobalScopeProxy() const = 0; | 30 virtual WorkletGlobalScopeProxy* workletGlobalScopeProxy() const = 0; |
28 | 31 |
29 // Worklet | 32 // Worklet |
30 ScriptPromise import(ScriptState*, const String& url); | 33 ScriptPromise import(ScriptState*, const String& url); |
31 | 34 |
32 void notifyFinished(WorkletScriptLoader*); | 35 void notifyFinished(WorkletScriptLoader*); |
33 | 36 |
34 // ActiveDOMObject | 37 // ActiveDOMObject |
35 void stop() final; | 38 void stop() final; |
36 | 39 |
37 DECLARE_VIRTUAL_TRACE(); | 40 DECLARE_VIRTUAL_TRACE(); |
38 | 41 |
39 protected: | 42 protected: |
40 // The Worklet inherits the url and userAgent from the frame->document(). | 43 // The Worklet inherits the url and userAgent from the frame->document(). |
41 explicit Worklet(LocalFrame*); | 44 explicit Worklet(LocalFrame*); |
42 | 45 |
43 private: | 46 private: |
44 ResourceFetcher* fetcher() const { return m_fetcher.get(); } | 47 ResourceFetcher* fetcher() const { return m_fetcher.get(); } |
45 | 48 |
46 Member<ResourceFetcher> m_fetcher; | 49 Member<ResourceFetcher> m_fetcher; |
47 HeapHashSet<Member<WorkletScriptLoader>> m_scriptLoaders; | 50 HeapHashSet<Member<WorkletScriptLoader>> m_scriptLoaders; |
48 }; | 51 }; |
49 | 52 |
50 } // namespace blink | 53 } // namespace blink |
51 | 54 |
52 #endif // Worklet_h | 55 #endif // Worklet_h |
OLD | NEW |