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

Unified Diff: third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.h

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: fix wrong dcheck 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.h
diff --git a/third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.h b/third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.h
new file mode 100644
index 0000000000000000000000000000000000000000..9604fd16425912a1518b1896814129704b6fd825
--- /dev/null
+++ b/third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.h
@@ -0,0 +1,42 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PaintWorkletPendingGeneratorRegistry_h
+#define PaintWorkletPendingGeneratorRegistry_h
+
+#include "modules/csspaint/CSSPaintImageGeneratorImpl.h"
+#include "platform/heap/Heap.h"
+#include "platform/heap/HeapAllocator.h"
+
+namespace blink {
+
+class CSSPaintDefinition;
+
+// Keeps pending CSSPaintImageGeneratorImpls until corresponding
+// CSSPaintDefinitions are registered. This is primarily owned by the
+// PaintWorklet instance.
+class PaintWorkletPendingGeneratorRegistry
+ : public GarbageCollected<PaintWorkletPendingGeneratorRegistry> {
+ WTF_MAKE_NONCOPYABLE(PaintWorkletPendingGeneratorRegistry);
+
+ public:
+ PaintWorkletPendingGeneratorRegistry() = default;
+
+ void SetDefinition(const String& name, CSSPaintDefinition*);
+ void AddPendingGenerator(const String& name, CSSPaintImageGeneratorImpl*);
+
+ DECLARE_TRACE();
+
+ private:
+ // The map of CSSPaintImageGeneratorImpl which are waiting for a
+ // CSSPaintDefinition to be registered. Owners of this registry is expected to
+ // outlive the generators hence are held onto with a WeakMember.
+ using GeneratorHashSet = HeapHashSet<WeakMember<CSSPaintImageGeneratorImpl>>;
+ using PendingGeneratorMap = HeapHashMap<String, Member<GeneratorHashSet>>;
+ PendingGeneratorMap pending_generators_;
+};
+
+} // namespace blink
+
+#endif // PaintWorkletPendingGeneratorRegistry_h

Powered by Google App Engine
This is Rietveld 408576698