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/ScriptPromiseResolver.h" | |
| 10 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 11 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| 12 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.h" |
| 13 #include "core/loader/WorkletScriptLoader.h" | |
| 14 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 15 #include "platform/loader/fetch/ResourceFetcher.h" | |
| 16 | 13 |
| 17 namespace blink { | 14 namespace blink { |
| 18 | 15 |
| 19 class LocalFrame; | 16 class LocalFrame; |
| 20 class WorkletGlobalScopeProxy; | 17 class WorkletGlobalScopeProxy; |
| 21 | 18 |
|
falken
2017/04/17 05:35:54
nit: add a class-level comment?
nhiroki
2017/04/17 11:35:05
Done.
| |
| 22 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, | 19 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, |
| 23 public WorkletScriptLoader::Client, | |
| 24 public ScriptWrappable, | 20 public ScriptWrappable, |
| 25 public ContextLifecycleObserver { | 21 public ContextLifecycleObserver { |
| 26 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
| 27 USING_GARBAGE_COLLECTED_MIXIN(Worklet); | 23 USING_GARBAGE_COLLECTED_MIXIN(Worklet); |
| 28 WTF_MAKE_NONCOPYABLE(Worklet); | 24 WTF_MAKE_NONCOPYABLE(Worklet); |
| 29 | 25 |
| 30 public: | 26 public: |
| 31 virtual ~Worklet() = default; | 27 virtual ~Worklet() = default; |
| 32 | 28 |
| 33 virtual void Initialize() {} | 29 virtual void Initialize() {} |
| 34 virtual bool IsInitialized() const { return true; } | 30 virtual bool IsInitialized() const { return true; } |
| 35 | 31 |
| 32 virtual ScriptPromise import(ScriptState*, const String& url) = 0; | |
| 36 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; | 33 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; |
|
falken
2017/04/17 05:35:54
Can you document this interface?
nhiroki
2017/04/17 11:35:05
Done.
| |
| 37 | 34 |
| 38 // Worklet | |
| 39 ScriptPromise import(ScriptState*, const String& url); | |
| 40 | |
| 41 // WorkletScriptLoader::Client | |
| 42 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*, | |
| 43 const ScriptSourceCode&) final; | |
| 44 | |
| 45 // ContextLifecycleObserver | 35 // ContextLifecycleObserver |
| 46 void ContextDestroyed(ExecutionContext*) final; | 36 virtual void ContextDestroyed(ExecutionContext*); |
| 47 | 37 |
| 48 DECLARE_VIRTUAL_TRACE(); | 38 DECLARE_VIRTUAL_TRACE(); |
| 49 | 39 |
| 50 protected: | 40 protected: |
| 51 // The Worklet inherits the url and userAgent from the frame->document(). | 41 // The Worklet inherits the url and userAgent from the frame->document(). |
| 52 explicit Worklet(LocalFrame*); | 42 explicit Worklet(LocalFrame*); |
| 53 | 43 |
| 54 private: | |
| 55 Member<LocalFrame> frame_; | 44 Member<LocalFrame> frame_; |
| 56 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>> | |
| 57 loader_and_resolvers_; | |
| 58 }; | 45 }; |
| 59 | 46 |
| 60 } // namespace blink | 47 } // namespace blink |
| 61 | 48 |
| 62 #endif // Worklet_h | 49 #endif // Worklet_h |
| OLD | NEW |