| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/arc/arc_bridge_service.h" | 5 #include "components/arc/arc_bridge_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 void ArcBridgeService::AddObserver(Observer* observer) { | 49 void ArcBridgeService::AddObserver(Observer* observer) { |
| 50 DCHECK(CalledOnValidThread()); | 50 DCHECK(CalledOnValidThread()); |
| 51 observer_list_.AddObserver(observer); | 51 observer_list_.AddObserver(observer); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ArcBridgeService::RemoveObserver(Observer* observer) { | 54 void ArcBridgeService::RemoveObserver(Observer* observer) { |
| 55 DCHECK(CalledOnValidThread()); | 55 DCHECK(CalledOnValidThread()); |
| 56 observer_list_.RemoveObserver(observer); | 56 observer_list_.RemoveObserver(observer); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ArcBridgeService::OnAppInstanceReady(AppInstancePtr app_ptr) { | 59 void ArcBridgeService::AddNotificationObserver(NotificationObserver* observer) { |
| 60 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
| 61 app_ptr_ = std::move(app_ptr); | 61 notification_observer_list_.AddObserver(observer); |
| 62 FOR_EACH_OBSERVER(Observer, observer_list(), OnAppInstanceReady()); | |
| 63 } | 62 } |
| 64 | 63 |
| 65 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) { | 64 void ArcBridgeService::RemoveNotificationObserver( |
| 65 NotificationObserver* observer) { |
| 66 DCHECK(CalledOnValidThread()); | 66 DCHECK(CalledOnValidThread()); |
| 67 input_ptr_ = std::move(input_ptr); | 67 notification_observer_list_.RemoveObserver(observer); |
| 68 FOR_EACH_OBSERVER(Observer, observer_list(), OnInputInstanceReady()); | |
| 69 } | 68 } |
| 70 | 69 |
| 71 void ArcBridgeService::OnNotificationsInstanceReady( | 70 void ArcBridgeService::AddAppObserver(AppObserver* observer) { |
| 72 NotificationsInstancePtr notifications_ptr) { | |
| 73 DCHECK(CalledOnValidThread()); | 71 DCHECK(CalledOnValidThread()); |
| 74 notifications_ptr_ = std::move(notifications_ptr); | 72 app_observer_list_.AddObserver(observer); |
| 75 FOR_EACH_OBSERVER(Observer, observer_list(), OnNotificationsInstanceReady()); | |
| 76 } | 73 } |
| 77 | 74 |
| 78 void ArcBridgeService::OnPowerInstanceReady(PowerInstancePtr power_ptr) { | 75 void ArcBridgeService::RemoveAppObserver(AppObserver* observer) { |
| 79 DCHECK(CalledOnValidThread()); | 76 DCHECK(CalledOnValidThread()); |
| 80 power_ptr_ = std::move(power_ptr); | 77 app_observer_list_.RemoveObserver(observer); |
| 81 FOR_EACH_OBSERVER(Observer, observer_list(), OnPowerInstanceReady()); | |
| 82 } | 78 } |
| 83 | 79 |
| 84 void ArcBridgeService::OnProcessInstanceReady(ProcessInstancePtr process_ptr) { | 80 void ArcBridgeService::AddProcessObserver(ProcessObserver* observer) { |
| 85 DCHECK(CalledOnValidThread()); | 81 DCHECK(CalledOnValidThread()); |
| 86 process_ptr_ = std::move(process_ptr); | 82 process_observer_list_.AddObserver(observer); |
| 87 FOR_EACH_OBSERVER(Observer, observer_list(), OnProcessInstanceReady()); | |
| 88 } | 83 } |
| 89 | 84 |
| 90 void ArcBridgeService::OnSettingsInstanceReady( | 85 void ArcBridgeService::RemoveProcessObserver(ProcessObserver* observer) { |
| 91 SettingsInstancePtr settings_ptr) { | |
| 92 DCHECK(CalledOnValidThread()); | 86 DCHECK(CalledOnValidThread()); |
| 93 settings_ptr_ = std::move(settings_ptr); | 87 process_observer_list_.RemoveObserver(observer); |
| 94 FOR_EACH_OBSERVER(Observer, observer_list(), OnSettingsInstanceReady()); | |
| 95 } | 88 } |
| 96 | 89 |
| 97 void ArcBridgeService::SetState(State state) { | 90 void ArcBridgeService::SetState(State state) { |
| 98 DCHECK(CalledOnValidThread()); | 91 DCHECK(CalledOnValidThread()); |
| 99 // DCHECK on enum classes not supported. | 92 // DCHECK on enum classes not supported. |
| 100 DCHECK(state_ != state); | 93 DCHECK(state_ != state); |
| 101 state_ = state; | 94 state_ = state; |
| 102 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 95 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
| 103 } | 96 } |
| 104 | 97 |
| 105 void ArcBridgeService::SetAvailable(bool available) { | 98 void ArcBridgeService::SetAvailable(bool available) { |
| 106 DCHECK(CalledOnValidThread()); | 99 DCHECK(CalledOnValidThread()); |
| 107 DCHECK(available_ != available); | 100 DCHECK(available_ != available); |
| 108 available_ = available; | 101 available_ = available; |
| 109 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); | 102 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); |
| 110 } | 103 } |
| 111 | 104 |
| 112 bool ArcBridgeService::CalledOnValidThread() { | 105 bool ArcBridgeService::CalledOnValidThread() { |
| 113 return thread_checker_.CalledOnValidThread(); | 106 return thread_checker_.CalledOnValidThread(); |
| 114 } | 107 } |
| 115 | 108 |
| 116 } // namespace arc | 109 } // namespace arc |
| OLD | NEW |