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

Side by Side Diff: third_party/WebKit/Source/core/workers/Worklet.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 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 "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/dom/ContextLifecycleObserver.h" 10 #include "core/dom/ContextLifecycleObserver.h"
11 #include "platform/bindings/ScriptWrappable.h" 11 #include "platform/bindings/ScriptWrappable.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 ScriptPromiseResolver;
17 class WorkletGlobalScopeProxy; 18 class WorkletGlobalScopeProxy;
18 19
19 // This is the base implementation of Worklet interface defined in the spec: 20 // This is the base implementation of Worklet interface defined in the spec:
20 // https://drafts.css-houdini.org/worklets/#worklet 21 // https://drafts.css-houdini.org/worklets/#worklet
21 // Although some worklets run off the main thread, this must be created and 22 // Although some worklets run off the main thread, this must be created and
22 // destroyed on the main thread. 23 // destroyed on the main thread.
23 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>, 24 class CORE_EXPORT Worklet : public GarbageCollectedFinalized<Worklet>,
24 public ScriptWrappable, 25 public ScriptWrappable,
25 public ContextLifecycleObserver { 26 public ContextLifecycleObserver {
26 DEFINE_WRAPPERTYPEINFO(); 27 DEFINE_WRAPPERTYPEINFO();
27 USING_GARBAGE_COLLECTED_MIXIN(Worklet); 28 USING_GARBAGE_COLLECTED_MIXIN(Worklet);
28 WTF_MAKE_NONCOPYABLE(Worklet); 29 WTF_MAKE_NONCOPYABLE(Worklet);
29 30
30 public: 31 public:
31 virtual ~Worklet() = default; 32 virtual ~Worklet() = default;
32 33
33 // Worklet.idl 34 // Worklet.idl
34 // addModule() imports ES6 module scripts. 35 // addModule() imports ES6 module scripts.
35 virtual ScriptPromise addModule(ScriptState*, const String& module_url) = 0; 36 virtual ScriptPromise addModule(ScriptState*, const String& module_url);
36 37
37 // Returns a proxy to WorkletGlobalScope on the context thread. 38 // Returns a proxy to WorkletGlobalScope on the context thread.
38 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; 39 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0;
39 40
40 // ContextLifecycleObserver
41 virtual void ContextDestroyed(ExecutionContext*);
42
43 DECLARE_VIRTUAL_TRACE(); 41 DECLARE_VIRTUAL_TRACE();
44 42
45 protected: 43 protected:
46 // The Worklet inherits the url and userAgent from the frame->document(). 44 // The Worklet inherits the url and userAgent from the frame->document().
47 explicit Worklet(LocalFrame*); 45 explicit Worklet(LocalFrame*);
48 46
49 Member<LocalFrame> frame_; 47 private:
48 virtual void FetchAndInvokeScript(const KURL& module_url_record,
49 ScriptPromiseResolver*) = 0;
50 }; 50 };
51 51
52 } // namespace blink 52 } // namespace blink
53 53
54 #endif // Worklet_h 54 #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