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

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

Issue 2840523002: [DONT COMMIT] Worklet: Implement "addModule()" algorithm for main thread worklets (Closed)
Patch Set: rebase 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"
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 // Called when addModule() is called for the first time. 33 // Called when addModule() is called for the first time.
33 virtual void Initialize() = 0; 34 virtual void Initialize() = 0;
34 virtual bool IsInitialized() const = 0; 35 virtual bool IsInitialized() const = 0;
35 36
36 // Worklet 37 // Worklet
37 ScriptPromise addModule(ScriptState*, const String& module_url) final; 38 ScriptPromise addModule(ScriptState*, const String& module_url) final;
38 39
39 // WorkletScriptLoader::Client 40 // WorkletScriptLoader::Client
40 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*, 41 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*,
41 const ScriptSourceCode&) final; 42 const ScriptSourceCode&) final;
42 43
43 // ContextLifecycleObserver 44 // ContextLifecycleObserver
44 void ContextDestroyed(ExecutionContext*) final; 45 void ContextDestroyed(ExecutionContext*) final;
45 46
47 // Returns a proxy to WorkletGlobalScope on the context thread.
48 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0;
49
46 DECLARE_VIRTUAL_TRACE(); 50 DECLARE_VIRTUAL_TRACE();
47 51
48 protected: 52 protected:
49 explicit ThreadedWorklet(LocalFrame*); 53 explicit ThreadedWorklet(LocalFrame*);
50 54
51 private: 55 private:
52 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>> 56 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>>
53 loader_to_resolver_map_; 57 loader_to_resolver_map_;
54 }; 58 };
55 59
56 } // namespace blink 60 } // namespace blink
57 61
58 #endif // ThreadedWorklet_h 62 #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