OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MainThreadWorklet_h |
| 6 #define MainThreadWorklet_h |
| 7 |
| 8 #include "core/workers/Worklet.h" |
| 9 |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 11 #include "core/CoreExport.h" |
| 12 #include "core/loader/WorkletScriptLoader.h" |
| 13 #include "platform/heap/Handle.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 class LocalFrame; |
| 18 |
| 19 // A MainThreadWorklet is a worklet that runs only on the main thread. |
| 20 // TODO(nhiroki): This is a temporary class to support module loading for main |
| 21 // thread worklets. This and ThreadedWorklet will be merged into the base |
| 22 // Worklet class once threaded worklets are ready to use module loading. |
| 23 class CORE_EXPORT MainThreadWorklet : public Worklet, |
| 24 public WorkletScriptLoader::Client { |
| 25 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorklet); |
| 26 WTF_MAKE_NONCOPYABLE(MainThreadWorklet); |
| 27 |
| 28 public: |
| 29 virtual ~MainThreadWorklet() = default; |
| 30 |
| 31 // Worklet |
| 32 ScriptPromise import(ScriptState*, const String& url) final; |
| 33 |
| 34 // WorkletScriptLoader::Client |
| 35 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*, |
| 36 const ScriptSourceCode&) final; |
| 37 |
| 38 // ContextLifecycleObserver |
| 39 void ContextDestroyed(ExecutionContext*) final; |
| 40 |
| 41 DECLARE_VIRTUAL_TRACE(); |
| 42 |
| 43 protected: |
| 44 explicit MainThreadWorklet(LocalFrame*); |
| 45 |
| 46 private: |
| 47 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>> |
| 48 loader_to_resolver_map_; |
| 49 }; |
| 50 |
| 51 } // namespace blink |
| 52 |
| 53 #endif // MainThreadWorklet_h |
OLD | NEW |