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/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/dom/ActiveDOMObject.h" |
| 11 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 12 #include "core/workers/WorkerScriptLoader.h" |
9 #include "modules/worklet/WorkletGlobalScope.h" | 13 #include "modules/worklet/WorkletGlobalScope.h" |
10 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
11 | 15 |
12 namespace blink { | 16 namespace blink { |
13 | 17 |
14 class ExecutionContext; | 18 class ExecutionContext; |
| 19 class ScriptPromiseResolver; |
| 20 class WorkerScriptLoader; |
15 | 21 |
16 class Worklet final : public GarbageCollectedFinalized<Worklet>, public ScriptWr
appable { | 22 class Worklet final : public GarbageCollectedFinalized<Worklet>, public ScriptWr
appable, public ActiveDOMObject { |
| 23 DEFINE_WRAPPERTYPEINFO(); |
| 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Worklet); |
17 WTF_MAKE_NONCOPYABLE(Worklet); | 25 WTF_MAKE_NONCOPYABLE(Worklet); |
18 DEFINE_WRAPPERTYPEINFO(); | |
19 public: | 26 public: |
20 // The ExecutionContext argument is the parent document of the Worklet. The | 27 // The ExecutionContext argument is the parent document of the Worklet. The |
21 // Worklet inherits the url and userAgent, from the document. | 28 // Worklet inherits the url and userAgent, from the document. |
22 static Worklet* create(ExecutionContext*); | 29 static Worklet* create(ExecutionContext*); |
23 | 30 |
| 31 ScriptPromise import(ScriptState*, const String& url); |
| 32 |
| 33 // ActiveDOMObject |
| 34 void stop() final; |
| 35 |
24 DECLARE_TRACE(); | 36 DECLARE_TRACE(); |
25 | 37 |
26 private: | 38 private: |
27 explicit Worklet(ExecutionContext*); | 39 explicit Worklet(ExecutionContext*); |
28 | 40 |
| 41 void onResponse(); |
| 42 void onFinished(WorkerScriptLoader*, ScriptPromiseResolver*); |
| 43 |
29 RefPtrWillBeMember<WorkletGlobalScope> m_workletGlobalScope; | 44 RefPtrWillBeMember<WorkletGlobalScope> m_workletGlobalScope; |
| 45 Vector<RefPtr<WorkerScriptLoader>> m_scriptLoaders; |
| 46 HeapVector<Member<ScriptPromiseResolver>> m_resolvers; |
30 }; | 47 }; |
31 | 48 |
32 } // namespace blink | 49 } // namespace blink |
33 | 50 |
34 #endif // Worklet_h | 51 #endif // Worklet_h |
OLD | NEW |