Chromium Code Reviews| 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/fetch/ScriptResource.h" |
| 12 #include "core/workers/WorkerScriptLoader.h" | |
| 13 #include "modules/ModulesExport.h" | 12 #include "modules/ModulesExport.h" |
| 14 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 15 | 14 |
| 16 namespace blink { | 15 namespace blink { |
| 17 | 16 |
| 18 class ExecutionContext; | 17 class LocalFrame; |
| 19 class ScriptPromiseResolver; | 18 class Resource; |
| 20 class WorkerScriptLoader; | 19 class ResourceFetcher; |
| 21 class WorkletGlobalScopeProxy; | 20 class WorkletGlobalScopeProxy; |
| 21 class WorkletScriptLoader; | |
| 22 | 22 |
| 23 class MODULES_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, public ScriptWrappable, public ActiveDOMObject { | 23 class MODULES_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, public ScriptWrappable, public ActiveDOMObject { |
| 24 DEFINE_WRAPPERTYPEINFO(); | 24 DEFINE_WRAPPERTYPEINFO(); |
| 25 USING_GARBAGE_COLLECTED_MIXIN(Worklet); | 25 USING_GARBAGE_COLLECTED_MIXIN(Worklet); |
| 26 WTF_MAKE_NONCOPYABLE(Worklet); | 26 WTF_MAKE_NONCOPYABLE(Worklet); |
| 27 public: | 27 public: |
| 28 virtual WorkletGlobalScopeProxy* workletGlobalScopeProxy() const = 0; | 28 virtual WorkletGlobalScopeProxy* workletGlobalScopeProxy() const = 0; |
| 29 | 29 |
| 30 // Worklet | 30 // Worklet |
| 31 ScriptPromise import(ScriptState*, const String& url); | 31 ScriptPromise import(ScriptState*, const String& url); |
| 32 | 32 |
| 33 void notifyFinished(Resource*); | |
| 34 | |
| 33 // ActiveDOMObject | 35 // ActiveDOMObject |
| 34 void stop() final; | 36 void stop() final; |
| 35 | 37 |
| 36 DECLARE_VIRTUAL_TRACE(); | 38 DECLARE_VIRTUAL_TRACE(); |
| 37 | 39 |
| 38 protected: | 40 protected: |
| 39 // The ExecutionContext argument is the parent document of the Worklet. The | 41 // The Worklet inherits the url and userAgent from the frame->document(). |
| 40 // Worklet inherits the url and userAgent from the document. | 42 explicit Worklet(LocalFrame*); |
| 41 explicit Worklet(ExecutionContext*); | |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 void onResponse(WorkerScriptLoader*); | 45 ResourceFetcher* fetcher() const { return m_fetcher.get(); } |
| 45 void onFinished(WorkerScriptLoader*, ScriptPromiseResolver*); | |
| 46 | 46 |
| 47 Vector<RefPtr<WorkerScriptLoader>> m_scriptLoaders; | 47 Member<ResourceFetcher> m_fetcher; |
| 48 HeapVector<Member<ScriptPromiseResolver>> m_resolvers; | 48 HeapVector<Member<Resource>> m_resources; |
|
yhirano
2016/08/01 10:56:28
It seems having m_resources is not necessary if we
Gleb Lanbin
2016/08/01 19:49:51
Done.
| |
| 49 HeapVector<Member<WorkletScriptLoader>> m_scriptLoaders; | |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 } // namespace blink | 52 } // namespace blink |
| 52 | 53 |
| 53 #endif // Worklet_h | 54 #endif // Worklet_h |
| OLD | NEW |