summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/context_lifecycle_observer.cc
blob: 9387ae065071d77ac0a084c9e0e09cb4fd099d77 (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
// Copyright 2020 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/platform/context_lifecycle_observer.h"

#include "third_party/blink/renderer/platform/context_lifecycle_notifier.h"

namespace blink {

void ContextLifecycleObserver::ObserverListWillBeCleared() {
  notifier_ = nullptr;
}

void ContextLifecycleObserver::SetContextLifecycleNotifier(
    ContextLifecycleNotifier* notifier) {
  if (notifier == notifier_)
    return;

  if (notifier_)
    notifier_->RemoveContextLifecycleObserver(this);

  notifier_ = notifier;

  if (notifier_)
    notifier_->AddContextLifecycleObserver(this);
}

void ContextLifecycleObserver::Trace(Visitor* visitor) {
  visitor->Trace(notifier_);
}

}  // namespace blink