| 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 "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/dom/ContextLifecycleObserver.h" | 10 #include "core/dom/ContextLifecycleObserver.h" |
| 11 #include "core/workers/WorkletOptions.h" |
| 11 #include "platform/bindings/ScriptWrappable.h" | 12 #include "platform/bindings/ScriptWrappable.h" |
| 12 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class LocalFrame; | 17 class LocalFrame; |
| 17 class ScriptPromiseResolver; | 18 class ScriptPromiseResolver; |
| 18 class WorkletGlobalScopeProxy; | 19 class WorkletGlobalScopeProxy; |
| 19 | 20 |
| 20 // This is the base implementation of Worklet interface defined in the spec: | 21 // This is the base implementation of Worklet interface defined in the spec: |
| 21 // https://drafts.css-houdini.org/worklets/#worklet | 22 // https://drafts.css-houdini.org/worklets/#worklet |
| 22 // Although some worklets run off the main thread, this must be created and | 23 // Although some worklets run off the main thread, this must be created and |
| 23 // destroyed on the main thread. | 24 // destroyed on the main thread. |
| 24 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, | 25 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, |
| 25 public ScriptWrappable, | 26 public ScriptWrappable, |
| 26 public ContextLifecycleObserver { | 27 public ContextLifecycleObserver { |
| 27 DEFINE_WRAPPERTYPEINFO(); | 28 DEFINE_WRAPPERTYPEINFO(); |
| 28 USING_GARBAGE_COLLECTED_MIXIN(Worklet); | 29 USING_GARBAGE_COLLECTED_MIXIN(Worklet); |
| 29 WTF_MAKE_NONCOPYABLE(Worklet); | 30 WTF_MAKE_NONCOPYABLE(Worklet); |
| 30 | 31 |
| 31 public: | 32 public: |
| 32 virtual ~Worklet() = default; | 33 virtual ~Worklet() = default; |
| 33 | 34 |
| 34 // Worklet.idl | 35 // Worklet.idl |
| 35 // addModule() imports ES6 module scripts. | 36 // addModule() imports ES6 module scripts. |
| 36 virtual ScriptPromise addModule(ScriptState*, const String& module_url); | 37 virtual ScriptPromise addModule(ScriptState*, |
| 38 const String& module_url, |
| 39 const WorkletOptions&); |
| 37 | 40 |
| 38 // Returns a proxy to WorkletGlobalScope on the context thread. | 41 // Returns a proxy to WorkletGlobalScope on the context thread. |
| 39 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; | 42 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; |
| 40 | 43 |
| 41 DECLARE_VIRTUAL_TRACE(); | 44 DECLARE_VIRTUAL_TRACE(); |
| 42 | 45 |
| 43 protected: | 46 protected: |
| 44 // The Worklet inherits the url and userAgent from the frame->document(). | 47 // The Worklet inherits the url and userAgent from the frame->document(). |
| 45 explicit Worklet(LocalFrame*); | 48 explicit Worklet(LocalFrame*); |
| 46 | 49 |
| 47 private: | 50 private: |
| 48 virtual void FetchAndInvokeScript(const KURL& module_url_record, | 51 virtual void FetchAndInvokeScript(const KURL& module_url_record, |
| 52 const WorkletOptions&, |
| 49 ScriptPromiseResolver*) = 0; | 53 ScriptPromiseResolver*) = 0; |
| 50 }; | 54 }; |
| 51 | 55 |
| 52 } // namespace blink | 56 } // namespace blink |
| 53 | 57 |
| 54 #endif // Worklet_h | 58 #endif // Worklet_h |
| OLD | NEW |