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

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.h

Issue 2830603003: Worklet: Move WorkletScriptLoader from MainThreadWorklet to MainThreadWorkletGlobalScope (Closed)
Patch Set: const auto& 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 PaintWorkletGlobalScope_h 5 #ifndef PaintWorkletGlobalScope_h
6 #define PaintWorkletGlobalScope_h 6 #define PaintWorkletGlobalScope_h
7 7
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/workers/MainThreadWorkletGlobalScope.h" 10 #include "core/workers/MainThreadWorkletGlobalScope.h"
11 #include "modules/ModulesExport.h" 11 #include "modules/ModulesExport.h"
12 #include "platform/graphics/ImageBuffer.h" 12 #include "platform/graphics/ImageBuffer.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class CSSPaintDefinition; 16 class CSSPaintDefinition;
17 class CSSPaintImageGeneratorImpl; 17 class CSSPaintImageGeneratorImpl;
18 class ExceptionState; 18 class ExceptionState;
19 19
20 class MODULES_EXPORT PaintWorkletGlobalScope final 20 class MODULES_EXPORT PaintWorkletGlobalScope final
21 : public MainThreadWorkletGlobalScope { 21 : public MainThreadWorkletGlobalScope {
22 DEFINE_WRAPPERTYPEINFO(); 22 DEFINE_WRAPPERTYPEINFO();
23 USING_GARBAGE_COLLECTED_MIXIN(PaintWorkletGlobalScope); 23 USING_GARBAGE_COLLECTED_MIXIN(PaintWorkletGlobalScope);
24 24
25 public: 25 public:
26 static PaintWorkletGlobalScope* Create(LocalFrame*, 26 static PaintWorkletGlobalScope* Create(LocalFrame*,
27 const KURL&, 27 const KURL&,
28 const String& user_agent, 28 const String& user_agent,
29 PassRefPtr<SecurityOrigin>, 29 PassRefPtr<SecurityOrigin>,
30 v8::Isolate*); 30 v8::Isolate*,
31 WorkletObjectProxy*);
31 ~PaintWorkletGlobalScope() override; 32 ~PaintWorkletGlobalScope() override;
32 void Dispose() final; 33 void Dispose() final;
33 34
34 bool IsPaintWorkletGlobalScope() const final { return true; } 35 bool IsPaintWorkletGlobalScope() const final { return true; }
35 void registerPaint(const String& name, 36 void registerPaint(const String& name,
36 const ScriptValue& ctor, 37 const ScriptValue& ctor,
37 ExceptionState&); 38 ExceptionState&);
38 39
39 CSSPaintDefinition* FindDefinition(const String& name); 40 CSSPaintDefinition* FindDefinition(const String& name);
40 void AddPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*); 41 void AddPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*);
41 42
42 DECLARE_VIRTUAL_TRACE(); 43 DECLARE_VIRTUAL_TRACE();
43 44
44 private: 45 private:
45 PaintWorkletGlobalScope(LocalFrame*, 46 PaintWorkletGlobalScope(LocalFrame*,
46 const KURL&, 47 const KURL&,
47 const String& user_agent, 48 const String& user_agent,
48 PassRefPtr<SecurityOrigin>, 49 PassRefPtr<SecurityOrigin>,
49 v8::Isolate*); 50 v8::Isolate*,
51 WorkletObjectProxy*);
50 52
51 typedef HeapHashMap<String, Member<CSSPaintDefinition>> DefinitionMap; 53 typedef HeapHashMap<String, Member<CSSPaintDefinition>> DefinitionMap;
52 DefinitionMap paint_definitions_; 54 DefinitionMap paint_definitions_;
53 55
54 // The map of CSSPaintImageGeneratorImpl which are waiting for a 56 // The map of CSSPaintImageGeneratorImpl which are waiting for a
55 // CSSPaintDefinition to be registered. The global scope is expected to 57 // CSSPaintDefinition to be registered. The global scope is expected to
56 // outlive the generators hence are held onto with a WeakMember. 58 // outlive the generators hence are held onto with a WeakMember.
57 typedef HeapHashSet<WeakMember<CSSPaintImageGeneratorImpl>> GeneratorHashSet; 59 typedef HeapHashSet<WeakMember<CSSPaintImageGeneratorImpl>> GeneratorHashSet;
58 typedef HeapHashMap<String, Member<GeneratorHashSet>> PendingGeneratorMap; 60 typedef HeapHashMap<String, Member<GeneratorHashSet>> PendingGeneratorMap;
59 PendingGeneratorMap pending_generators_; 61 PendingGeneratorMap pending_generators_;
60 }; 62 };
61 63
62 DEFINE_TYPE_CASTS(PaintWorkletGlobalScope, 64 DEFINE_TYPE_CASTS(PaintWorkletGlobalScope,
63 ExecutionContext, 65 ExecutionContext,
64 context, 66 context,
65 context->IsPaintWorkletGlobalScope(), 67 context->IsPaintWorkletGlobalScope(),
66 context.IsPaintWorkletGlobalScope()); 68 context.IsPaintWorkletGlobalScope());
67 69
68 } // namespace blink 70 } // namespace blink
69 71
70 #endif // PaintWorkletGlobalScope_h 72 #endif // PaintWorkletGlobalScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698