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

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

Issue 2819153003: Worklet: Separate Worklet into MainThreadWorklet and ThreadedWorklet (Closed)
Patch Set: update comments Created 3 years, 8 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 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 "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptWrappable.h" 9 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "core/CoreExport.h" 10 #include "core/CoreExport.h"
12 #include "core/dom/ContextLifecycleObserver.h" 11 #include "core/dom/ContextLifecycleObserver.h"
13 #include "core/loader/WorkletScriptLoader.h"
14 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
15 #include "platform/loader/fetch/ResourceFetcher.h"
16 13
17 namespace blink { 14 namespace blink {
18 15
19 class LocalFrame; 16 class LocalFrame;
20 class WorkletGlobalScopeProxy; 17 class WorkletGlobalScopeProxy;
21 18
19 // This is the base implementation of Worklet interface defined in the spec:
20 // https://drafts.css-houdini.org/worklets/#worklet
21 // Although some worklets run off the main thread, this must be created and
22 // destroyed on the main thread.
22 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, 23 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>,
23 public WorkletScriptLoader::Client,
24 public ScriptWrappable, 24 public ScriptWrappable,
25 public ContextLifecycleObserver { 25 public ContextLifecycleObserver {
26 DEFINE_WRAPPERTYPEINFO(); 26 DEFINE_WRAPPERTYPEINFO();
27 USING_GARBAGE_COLLECTED_MIXIN(Worklet); 27 USING_GARBAGE_COLLECTED_MIXIN(Worklet);
28 WTF_MAKE_NONCOPYABLE(Worklet); 28 WTF_MAKE_NONCOPYABLE(Worklet);
29 29
30 public: 30 public:
31 virtual ~Worklet() = default; 31 virtual ~Worklet() = default;
32 32
33 virtual void Initialize() {} 33 virtual void Initialize() {}
34 virtual bool IsInitialized() const { return true; } 34 virtual bool IsInitialized() const { return true; }
35 35
36 // Worklet.idl
37 // import() imports ES6 module scripts.
38 virtual ScriptPromise import(ScriptState*, const String& url) = 0;
39
40 // Returns a proxy to WorkletGlobalScope on the context thread.
36 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; 41 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0;
37 42
38 // Worklet
39 ScriptPromise import(ScriptState*, const String& url);
40
41 // WorkletScriptLoader::Client
42 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*,
43 const ScriptSourceCode&) final;
44
45 // ContextLifecycleObserver 43 // ContextLifecycleObserver
46 void ContextDestroyed(ExecutionContext*) final; 44 virtual void ContextDestroyed(ExecutionContext*);
47 45
48 DECLARE_VIRTUAL_TRACE(); 46 DECLARE_VIRTUAL_TRACE();
49 47
50 protected: 48 protected:
51 // The Worklet inherits the url and userAgent from the frame->document(). 49 // The Worklet inherits the url and userAgent from the frame->document().
52 explicit Worklet(LocalFrame*); 50 explicit Worklet(LocalFrame*);
53 51
54 private:
55 Member<LocalFrame> frame_; 52 Member<LocalFrame> frame_;
56 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>>
57 loader_and_resolvers_;
58 }; 53 };
59 54
60 } // namespace blink 55 } // namespace blink
61 56
62 #endif // Worklet_h 57 #endif // Worklet_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/workers/ThreadedWorklet.cpp ('k') | third_party/WebKit/Source/core/workers/Worklet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698