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

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

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: fix wrong dcheck Created 3 years, 6 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"
11 #include "core/CoreExport.h" 11 #include "core/CoreExport.h"
12 #include "core/loader/WorkletScriptLoader.h" 12 #include "core/loader/WorkletScriptLoader.h"
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class LocalFrame; 17 class LocalFrame;
18 class WorkletGlobalScopeProxy;
18 19
19 // A ThreadedWorklet is a worklet that runs off the main thread. 20 // A ThreadedWorklet is a worklet that runs off the main thread.
20 // TODO(nhiroki): This is a temporary class to keep classic script loading for 21 // TODO(nhiroki): This is a temporary class to keep classic script loading for
21 // threaded worklets while module loading is being implemented for main thread 22 // threaded worklets while module loading is being implemented for main thread
22 // worklets. This and MainThreadWorklet will be merged into the base Worklet 23 // worklets. This and MainThreadWorklet will be merged into the base Worklet
23 // class once threaded worklets are also ready to use module loading. 24 // class once threaded worklets are also ready to use module loading.
24 class CORE_EXPORT ThreadedWorklet : public Worklet, 25 class CORE_EXPORT ThreadedWorklet : public Worklet,
25 public WorkletScriptLoader::Client { 26 public WorkletScriptLoader::Client {
26 USING_GARBAGE_COLLECTED_MIXIN(ThreadedWorklet); 27 USING_GARBAGE_COLLECTED_MIXIN(ThreadedWorklet);
27 WTF_MAKE_NONCOPYABLE(ThreadedWorklet); 28 WTF_MAKE_NONCOPYABLE(ThreadedWorklet);
28 29
29 public: 30 public:
30 virtual ~ThreadedWorklet() = default; 31 virtual ~ThreadedWorklet() = default;
31 32
32 // WorkletScriptLoader::Client 33 // WorkletScriptLoader::Client
33 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*, 34 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*,
34 const ScriptSourceCode&) final; 35 const ScriptSourceCode&) final;
35 36
36 // ContextLifecycleObserver 37 // ContextLifecycleObserver
37 void ContextDestroyed(ExecutionContext*) final; 38 void ContextDestroyed(ExecutionContext*) final;
38 39
40 // Returns a proxy to WorkletGlobalScope on the context thread.
41 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0;
42
39 DECLARE_VIRTUAL_TRACE(); 43 DECLARE_VIRTUAL_TRACE();
40 44
41 protected: 45 protected:
42 explicit ThreadedWorklet(LocalFrame*); 46 explicit ThreadedWorklet(LocalFrame*);
43 47
44 private: 48 private:
45 // Worklet 49 // Worklet
46 void FetchAndInvokeScript(const KURL& module_url_record, 50 void FetchAndInvokeScript(const KURL& module_url_record,
47 const WorkletOptions&, 51 const WorkletOptions&,
48 ScriptPromiseResolver*) override; 52 ScriptPromiseResolver*) override;
49 53
50 // Called when addModule() is called for the first time. 54 // Called when addModule() is called for the first time.
51 virtual void Initialize() = 0; 55 virtual void Initialize() = 0;
52 virtual bool IsInitialized() const = 0; 56 virtual bool IsInitialized() const = 0;
53 57
54 Member<LocalFrame> frame_; 58 Member<LocalFrame> frame_;
55 59
56 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>> 60 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>>
57 loader_to_resolver_map_; 61 loader_to_resolver_map_;
58 }; 62 };
59 63
60 } // namespace blink 64 } // namespace blink
61 65
62 #endif // ThreadedWorklet_h 66 #endif // ThreadedWorklet_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/workers/MainThreadWorklet.cpp ('k') | third_party/WebKit/Source/core/workers/Worklet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698