summaryrefslogtreecommitdiff
path: root/chromium/components/arc/connection_notifier.cc
blob: b3b1e17aab07958153c9c4154840d0fb6d16f40f (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
38
39
// 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 "components/arc/connection_notifier.h"

#include "components/arc/connection_observer.h"

namespace arc {
namespace internal {

ConnectionNotifier::ConnectionNotifier() = default;

ConnectionNotifier::~ConnectionNotifier() = default;

void ConnectionNotifier::AddObserver(ConnectionObserverBase* observer) {
  DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
  observer_list_.AddObserver(observer);
}

void ConnectionNotifier::RemoveObserver(ConnectionObserverBase* observer) {
  DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
  observer_list_.RemoveObserver(observer);
}

void ConnectionNotifier::NotifyConnectionReady() {
  DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
  for (auto& observer : observer_list_)
    observer.OnConnectionReady();
}

void ConnectionNotifier::NotifyConnectionClosed() {
  DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
  for (auto& observer : observer_list_)
    observer.OnConnectionClosed();
}

}  // namespace internal
}  // namespace arc