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