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

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

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.cpp
diff --git a/third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.cpp b/third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f8ae4b7957b423ebe2b3db7fccbadf1035b5819d
--- /dev/null
+++ b/third_party/WebKit/Source/modules/csspaint/PaintWorkletPendingGeneratorRegistry.cpp
@@ -0,0 +1,38 @@
+// 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.
+
+#include "modules/csspaint/PaintWorkletPendingGeneratorRegistry.h"
+
+#include "modules/csspaint/CSSPaintDefinition.h"
+
+namespace blink {
+
+void PaintWorkletPendingGeneratorRegistry::SetDefinition(
+ const String& name,
+ CSSPaintDefinition* definition) {
+ GeneratorHashSet* set = pending_generators_.at(name);
+ if (set) {
+ for (const auto& generator : *set) {
+ if (generator)
+ generator->SetDefinition(definition);
+ }
+ }
+ pending_generators_.erase(name);
+}
+
+void PaintWorkletPendingGeneratorRegistry::AddPendingGenerator(
+ const String& name,
+ CSSPaintImageGeneratorImpl* generator) {
+ Member<GeneratorHashSet>& set =
+ pending_generators_.insert(name, nullptr).stored_value->value;
+ if (!set)
+ set = new GeneratorHashSet;
+ set->insert(generator);
+}
+
+DEFINE_TRACE(PaintWorkletPendingGeneratorRegistry) {
+ visitor->Trace(pending_generators_);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698