| 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::AddNotificationObserver(NotificationObserver* observer) { | 59 void ArcBridgeService::OnAppInstanceReady(AppInstancePtr app_ptr) { |
| 60 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
| 61 notification_observer_list_.AddObserver(observer); | 61 app_ptr_ = std::move(app_ptr); |
| 62 FOR_EACH_OBSERVER(Observer, observer_list(), OnAppInstanceReady()); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void ArcBridgeService::RemoveNotificationObserver( | 65 void ArcBridgeService::OnInputInstanceReady(InputInstancePtr input_ptr) { |
| 65 NotificationObserver* observer) { | |
| 66 DCHECK(CalledOnValidThread()); | 66 DCHECK(CalledOnValidThread()); |
| 67 notification_observer_list_.RemoveObserver(observer); | 67 input_ptr_ = std::move(input_ptr); |
| 68 FOR_EACH_OBSERVER(Observer, observer_list(), OnInputInstanceReady()); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void ArcBridgeService::AddAppObserver(AppObserver* observer) { | 71 void ArcBridgeService::OnNotificationsInstanceReady( |
| 72 NotificationsInstancePtr notifications_ptr) { |
| 71 DCHECK(CalledOnValidThread()); | 73 DCHECK(CalledOnValidThread()); |
| 72 app_observer_list_.AddObserver(observer); | 74 notifications_ptr_ = std::move(notifications_ptr); |
| 75 FOR_EACH_OBSERVER(Observer, observer_list(), OnNotificationsInstanceReady()); |
| 73 } | 76 } |
| 74 | 77 |
| 75 void ArcBridgeService::RemoveAppObserver(AppObserver* observer) { | 78 void ArcBridgeService::OnPowerInstanceReady(PowerInstancePtr power_ptr) { |
| 76 DCHECK(CalledOnValidThread()); | 79 DCHECK(CalledOnValidThread()); |
| 77 app_observer_list_.RemoveObserver(observer); | 80 power_ptr_ = std::move(power_ptr); |
| 81 FOR_EACH_OBSERVER(Observer, observer_list(), OnPowerInstanceReady()); |
| 78 } | 82 } |
| 79 | 83 |
| 80 void ArcBridgeService::AddProcessObserver(ProcessObserver* observer) { | 84 void ArcBridgeService::OnProcessInstanceReady(ProcessInstancePtr process_ptr) { |
| 81 DCHECK(CalledOnValidThread()); | 85 DCHECK(CalledOnValidThread()); |
| 82 process_observer_list_.AddObserver(observer); | 86 process_ptr_ = std::move(process_ptr); |
| 87 FOR_EACH_OBSERVER(Observer, observer_list(), OnProcessInstanceReady()); |
| 83 } | 88 } |
| 84 | 89 |
| 85 void ArcBridgeService::RemoveProcessObserver(ProcessObserver* observer) { | 90 void ArcBridgeService::OnSettingsInstanceReady( |
| 91 SettingsInstancePtr settings_ptr) { |
| 86 DCHECK(CalledOnValidThread()); | 92 DCHECK(CalledOnValidThread()); |
| 87 process_observer_list_.RemoveObserver(observer); | 93 settings_ptr_ = std::move(settings_ptr); |
| 94 FOR_EACH_OBSERVER(Observer, observer_list(), OnSettingsInstanceReady()); |
| 88 } | 95 } |
| 89 | 96 |
| 90 void ArcBridgeService::SetState(State state) { | 97 void ArcBridgeService::SetState(State state) { |
| 91 DCHECK(CalledOnValidThread()); | 98 DCHECK(CalledOnValidThread()); |
| 92 // DCHECK on enum classes not supported. | 99 // DCHECK on enum classes not supported. |
| 93 DCHECK(state_ != state); | 100 DCHECK(state_ != state); |
| 94 state_ = state; | 101 state_ = state; |
| 95 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 102 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
| 96 } | 103 } |
| 97 | 104 |
| 98 void ArcBridgeService::SetAvailable(bool available) { | 105 void ArcBridgeService::SetAvailable(bool available) { |
| 99 DCHECK(CalledOnValidThread()); | 106 DCHECK(CalledOnValidThread()); |
| 100 DCHECK(available_ != available); | 107 DCHECK(available_ != available); |
| 101 available_ = available; | 108 available_ = available; |
| 102 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); | 109 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); |
| 103 } | 110 } |
| 104 | 111 |
| 105 bool ArcBridgeService::CalledOnValidThread() { | 112 bool ArcBridgeService::CalledOnValidThread() { |
| 106 return thread_checker_.CalledOnValidThread(); | 113 return thread_checker_.CalledOnValidThread(); |
| 107 } | 114 } |
| 108 | 115 |
| 109 } // namespace arc | 116 } // namespace arc |
| OLD | NEW |