summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/csspaint/paint_worklet_pending_generator_registry.cc
blob: 6aa143838b604dc90094c8f6db7e826a3274e5cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 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 "third_party/blink/renderer/modules/csspaint/paint_worklet_pending_generator_registry.h"

#include "third_party/blink/renderer/modules/csspaint/css_paint_definition.h"

namespace blink {

void PaintWorkletPendingGeneratorRegistry::NotifyGeneratorReady(
    const String& name) {
  GeneratorHashSet* set = pending_generators_.at(name);
  if (set) {
    for (const auto& generator : *set) {
      if (generator)
        generator->NotifyGeneratorReady();
    }
  }
  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);
}

void PaintWorkletPendingGeneratorRegistry::Trace(blink::Visitor* visitor) {
  visitor->Trace(pending_generators_);
}

}  // namespace blink