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

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

Issue 2819153003: Worklet: Separate Worklet into MainThreadWorklet and ThreadedWorklet (Closed)
Patch Set: address review 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 // Regardless of worklet types, this must be created and destroyed on the main
falken 2017/04/18 03:37:53 "Although some worklets run off the main thread, t
nhiroki 2017/04/18 04:05:20 Done.
22 // 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 // https://drafts.css-houdini.org/worklets/#dom-worklet-import
falken 2017/04/18 03:37:53 nit: Ah, I see. Maybe this should additionally say
nhiroki 2017/04/18 04:05:20 I see. The original code has "// Worklet" but I th
37 virtual ScriptPromise import(ScriptState*, const String& url) = 0;
38
39 // Returns a proxy to WorkletGlobalScope on the context thread.
36 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0; 40 virtual WorkletGlobalScopeProxy* GetWorkletGlobalScopeProxy() const = 0;
37 41
38 // Worklet
39 ScriptPromise import(ScriptState*, const String& url);
40
41 // WorkletScriptLoader::Client
42 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*,
43 const ScriptSourceCode&) final;
44
45 // ContextLifecycleObserver 42 // ContextLifecycleObserver
46 void ContextDestroyed(ExecutionContext*) final; 43 virtual void ContextDestroyed(ExecutionContext*);
47 44
48 DECLARE_VIRTUAL_TRACE(); 45 DECLARE_VIRTUAL_TRACE();
49 46
50 protected: 47 protected:
51 // The Worklet inherits the url and userAgent from the frame->document(). 48 // The Worklet inherits the url and userAgent from the frame->document().
52 explicit Worklet(LocalFrame*); 49 explicit Worklet(LocalFrame*);
53 50
54 private:
55 Member<LocalFrame> frame_; 51 Member<LocalFrame> frame_;
56 HeapHashMap<Member<WorkletScriptLoader>, Member<ScriptPromiseResolver>>
57 loader_and_resolvers_;
58 }; 52 };
59 53
60 } // namespace blink 54 } // namespace blink
61 55
62 #endif // Worklet_h 56 #endif // Worklet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698