Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Side by Side Diff: third_party/WebKit/Source/core/workers/ThreadedWorklet.h

Issue 2878833002: Worklet: Move common code of addModule from Main/ThreadedWorklet to Worklet (Closed)
Patch Set: fix crashes Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 ThreadedWorklet_h 5 #ifndef ThreadedWorklet_h
6 #define ThreadedWorklet_h 6 #define ThreadedWorklet_h
7 7
8 #include "core/workers/Worklet.h" 8 #include "core/workers/Worklet.h"
9 9
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 11 matching lines...) Expand all
22 // worklets. This and MainThreadWorklet will be merged into the base Worklet 22 // worklets. This and MainThreadWorklet will be merged into the base Worklet
23 // class once threaded worklets are also ready to use module loading. 23 // class once threaded worklets are also ready to use module loading.
24 class CORE_EXPORT ThreadedWorklet : public Worklet, 24 class CORE_EXPORT ThreadedWorklet : public Worklet,
25 public WorkletScriptLoader::Client { 25 public WorkletScriptLoader::Client {
26 USING_GARBAGE_COLLECTED_MIXIN(ThreadedWorklet); 26 USING_GARBAGE_COLLECTED_MIXIN(ThreadedWorklet);
27 WTF_MAKE_NONCOPYABLE(ThreadedWorklet); 27 WTF_MAKE_NONCOPYABLE(ThreadedWorklet);
28 28
29 public: 29 public:
30 virtual ~ThreadedWorklet() = default; 30 virtual ~ThreadedWorklet() = default;
31 31
32 // Called when addModule() is called for the first time.
33 virtual void Initialize() = 0;
34 virtual bool IsInitialized() const = 0;
35
36 // Worklet
37 ScriptPromise addModule(ScriptState*, const String& module_url) final;
38
39 // WorkletScriptLoader::Client 32 // WorkletScriptLoader::Client
40 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*, 33 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*,
41 const ScriptSourceCode&) final; 34 const ScriptSourceCode&) final;
42 35
43 // ContextLifecycleObserver 36 // ContextLifecycleObserver
44 void ContextDestroyed(ExecutionContext*) final; 37 void ContextDestroyed(ExecutionContext*) final;
45 38
46 DECLARE_VIRTUAL_TRACE(); 39 DECLARE_VIRTUAL_TRACE();
47 40
48 protected: 41 protected:
49 explicit ThreadedWorklet(LocalFrame*); 42 explicit ThreadedWorklet(LocalFrame*);
50 43
51 private: 44 private:
45 // Worklet
46 void FetchAndInvokeScript(const KURL& module_url_record,
47 ScriptPromiseResolver*) override;
48
49 // Called when addModule() is called for the first time.
50 virtual void Initialize() = 0;
51 virtual bool IsInitialized() const = 0;
52
53 Member<LocalFrame> frame_;
54
52 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>> 55 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>>
53 loader_to_resolver_map_; 56 loader_to_resolver_map_;
54 }; 57 };
55 58
56 } // namespace blink 59 } // namespace blink
57 60
58 #endif // ThreadedWorklet_h 61 #endif // ThreadedWorklet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698