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

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

Issue 2840523002: [DONT COMMIT] Worklet: Implement "addModule()" algorithm for main thread worklets (Closed)
Patch Set: 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/ScriptWrappable.h" 9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/CoreExport.h" 10 #include "core/CoreExport.h"
11 #include "core/dom/ContextLifecycleObserver.h" 11 #include "core/dom/ContextLifecycleObserver.h"
12 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class LocalFrame; 16 class LocalFrame;
17 class WorkletGlobalScopeProxy;
18 17
19 // This is the base implementation of Worklet interface defined in the spec: 18 // This is the base implementation of Worklet interface defined in the spec:
20 // https://drafts.css-houdini.org/worklets/#worklet 19 // https://drafts.css-houdini.org/worklets/#worklet
21 // Although some worklets run off the main thread, this must be created and 20 // Although some worklets run off the main thread, this must be created and
22 // destroyed on the main thread. 21 // destroyed on the main thread.
23 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, 22 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>,
24 public ScriptWrappable, 23 public ScriptWrappable,
25 public ContextLifecycleObserver { 24 public ContextLifecycleObserver {
26 DEFINE_WRAPPERTYPEINFO(); 25 DEFINE_WRAPPERTYPEINFO();
27 USING_GARBAGE_COLLECTED_MIXIN(Worklet); 26 USING_GARBAGE_COLLECTED_MIXIN(Worklet);
28 WTF_MAKE_NONCOPYABLE(Worklet); 27 WTF_MAKE_NONCOPYABLE(Worklet);
29 28
30 public: 29 public:
31 virtual ~Worklet() = default; 30 virtual ~Worklet() = default;
32 31
33 virtual void Initialize() {} 32 virtual void Initialize() {}
34 virtual bool IsInitialized() const { return true; } 33 virtual bool IsInitialized() const { return true; }
35 34
36 // Worklet.idl 35 // Worklet.idl
37 // addModule() imports ES6 module scripts. 36 // addModule() imports ES6 module scripts.
38 virtual ScriptPromise addModule(ScriptState*, const String& url) = 0; 37 virtual ScriptPromise addModule(ScriptState*, const String& url) = 0;
39 38
40 // Returns a proxy to WorkletGlobalScope on the context thread.
41 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0;
42
43 // ContextLifecycleObserver 39 // ContextLifecycleObserver
44 virtual void ContextDestroyed(ExecutionContext*); 40 virtual void ContextDestroyed(ExecutionContext*);
45 41
46 DECLARE_VIRTUAL_TRACE(); 42 DECLARE_VIRTUAL_TRACE();
47 43
48 protected: 44 protected:
49 // The Worklet inherits the url and userAgent from the frame->document(). 45 // The Worklet inherits the url and userAgent from the frame->document().
50 explicit Worklet(LocalFrame*); 46 explicit Worklet(LocalFrame*);
51 47
52 Member<LocalFrame> frame_; 48 Member<LocalFrame> frame_;
53 }; 49 };
54 50
55 } // namespace blink 51 } // namespace blink
56 52
57 #endif // Worklet_h 53 #endif // Worklet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698