Hidehiko Abe | ac2e551 | 2017-11-21 09:54:46 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "components/arc/connection_notifier.h" |
| 6 | |
| 7 | #include "components/arc/connection_observer.h" |
| 8 | |
| 9 | namespace arc { |
| 10 | namespace internal { |
| 11 | |
| 12 | ConnectionNotifier::ConnectionNotifier() = default; |
| 13 | |
| 14 | ConnectionNotifier::~ConnectionNotifier() = default; |
| 15 | |
| 16 | void ConnectionNotifier::AddObserver(ConnectionObserverBase* observer) { |
| 17 | DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 18 | observer_list_.AddObserver(observer); |
| 19 | } |
| 20 | |
| 21 | void ConnectionNotifier::RemoveObserver(ConnectionObserverBase* observer) { |
| 22 | DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 23 | observer_list_.RemoveObserver(observer); |
| 24 | } |
| 25 | |
| 26 | void ConnectionNotifier::NotifyConnectionReady() { |
| 27 | DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 28 | for (auto& observer : observer_list_) |
| 29 | observer.OnConnectionReady(); |
| 30 | } |
| 31 | |
| 32 | void ConnectionNotifier::NotifyConnectionClosed() { |
| 33 | DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 34 | for (auto& observer : observer_list_) |
| 35 | observer.OnConnectionClosed(); |
| 36 | } |
| 37 | |
| 38 | } // namespace internal |
| 39 | } // namespace arc |