| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 void ArcBridgeService::AddObserver(Observer* observer) { | 45 void ArcBridgeService::AddObserver(Observer* observer) { |
| 46 DCHECK(CalledOnValidThread()); | 46 DCHECK(CalledOnValidThread()); |
| 47 observer_list_.AddObserver(observer); | 47 observer_list_.AddObserver(observer); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void ArcBridgeService::RemoveObserver(Observer* observer) { | 50 void ArcBridgeService::RemoveObserver(Observer* observer) { |
| 51 DCHECK(CalledOnValidThread()); | 51 DCHECK(CalledOnValidThread()); |
| 52 observer_list_.RemoveObserver(observer); | 52 observer_list_.RemoveObserver(observer); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ArcBridgeService::OnAppInstanceReady(mojom::AppInstancePtr app_ptr) { | |
| 56 DCHECK(CalledOnValidThread()); | |
| 57 app_.OnInstanceReady(std::move(app_ptr)); | |
| 58 } | |
| 59 | |
| 60 void ArcBridgeService::OnAudioInstanceReady(mojom::AudioInstancePtr audio_ptr) { | |
| 61 DCHECK(CalledOnValidThread()); | |
| 62 audio_.OnInstanceReady(std::move(audio_ptr)); | |
| 63 } | |
| 64 | |
| 65 void ArcBridgeService::OnAuthInstanceReady(mojom::AuthInstancePtr auth_ptr) { | |
| 66 DCHECK(CalledOnValidThread()); | |
| 67 auth_.OnInstanceReady(std::move(auth_ptr)); | |
| 68 } | |
| 69 | |
| 70 void ArcBridgeService::OnBluetoothInstanceReady( | |
| 71 mojom::BluetoothInstancePtr bluetooth_ptr) { | |
| 72 DCHECK(CalledOnValidThread()); | |
| 73 bluetooth_.OnInstanceReady(std::move(bluetooth_ptr)); | |
| 74 } | |
| 75 | |
| 76 void ArcBridgeService::OnClipboardInstanceReady( | |
| 77 mojom::ClipboardInstancePtr clipboard_ptr) { | |
| 78 DCHECK(CalledOnValidThread()); | |
| 79 clipboard_.OnInstanceReady(std::move(clipboard_ptr)); | |
| 80 } | |
| 81 | |
| 82 void ArcBridgeService::OnCrashCollectorInstanceReady( | |
| 83 mojom::CrashCollectorInstancePtr crash_collector_ptr) { | |
| 84 DCHECK(CalledOnValidThread()); | |
| 85 crash_collector_.OnInstanceReady(std::move(crash_collector_ptr)); | |
| 86 } | |
| 87 | |
| 88 void ArcBridgeService::OnFileSystemInstanceReady( | |
| 89 mojom::FileSystemInstancePtr file_system_ptr) { | |
| 90 DCHECK(CalledOnValidThread()); | |
| 91 file_system_.OnInstanceReady(std::move(file_system_ptr)); | |
| 92 } | |
| 93 | |
| 94 void ArcBridgeService::OnImeInstanceReady(mojom::ImeInstancePtr ime_ptr) { | |
| 95 DCHECK(CalledOnValidThread()); | |
| 96 ime_.OnInstanceReady(std::move(ime_ptr)); | |
| 97 } | |
| 98 | |
| 99 void ArcBridgeService::OnIntentHelperInstanceReady( | |
| 100 mojom::IntentHelperInstancePtr intent_helper_ptr) { | |
| 101 DCHECK(CalledOnValidThread()); | |
| 102 intent_helper_.OnInstanceReady(std::move(intent_helper_ptr)); | |
| 103 } | |
| 104 | |
| 105 void ArcBridgeService::OnMetricsInstanceReady( | |
| 106 mojom::MetricsInstancePtr metrics_ptr) { | |
| 107 DCHECK(CalledOnValidThread()); | |
| 108 metrics_.OnInstanceReady(std::move(metrics_ptr)); | |
| 109 } | |
| 110 | |
| 111 void ArcBridgeService::OnNetInstanceReady(mojom::NetInstancePtr net_ptr) { | |
| 112 DCHECK(CalledOnValidThread()); | |
| 113 net_.OnInstanceReady(std::move(net_ptr)); | |
| 114 } | |
| 115 | |
| 116 void ArcBridgeService::OnNotificationsInstanceReady( | |
| 117 mojom::NotificationsInstancePtr notifications_ptr) { | |
| 118 DCHECK(CalledOnValidThread()); | |
| 119 notifications_.OnInstanceReady(std::move(notifications_ptr)); | |
| 120 } | |
| 121 | |
| 122 void ArcBridgeService::OnObbMounterInstanceReady( | |
| 123 mojom::ObbMounterInstancePtr obb_mounter_ptr) { | |
| 124 DCHECK(CalledOnValidThread()); | |
| 125 obb_mounter_.OnInstanceReady(std::move(obb_mounter_ptr)); | |
| 126 } | |
| 127 | |
| 128 void ArcBridgeService::OnPolicyInstanceReady( | |
| 129 mojom::PolicyInstancePtr policy_ptr) { | |
| 130 DCHECK(CalledOnValidThread()); | |
| 131 policy_.OnInstanceReady(std::move(policy_ptr)); | |
| 132 } | |
| 133 | |
| 134 void ArcBridgeService::OnPowerInstanceReady(mojom::PowerInstancePtr power_ptr) { | |
| 135 DCHECK(CalledOnValidThread()); | |
| 136 power_.OnInstanceReady(std::move(power_ptr)); | |
| 137 } | |
| 138 | |
| 139 void ArcBridgeService::OnProcessInstanceReady( | |
| 140 mojom::ProcessInstancePtr process_ptr) { | |
| 141 DCHECK(CalledOnValidThread()); | |
| 142 process_.OnInstanceReady(std::move(process_ptr)); | |
| 143 } | |
| 144 | |
| 145 void ArcBridgeService::OnStorageManagerInstanceReady( | |
| 146 mojom::StorageManagerInstancePtr storage_manager_ptr) { | |
| 147 DCHECK(CalledOnValidThread()); | |
| 148 storage_manager_.OnInstanceReady(std::move(storage_manager_ptr)); | |
| 149 } | |
| 150 | |
| 151 void ArcBridgeService::OnVideoInstanceReady(mojom::VideoInstancePtr video_ptr) { | |
| 152 DCHECK(CalledOnValidThread()); | |
| 153 video_.OnInstanceReady(std::move(video_ptr)); | |
| 154 } | |
| 155 | |
| 156 void ArcBridgeService::OnWindowManagerInstanceReady( | |
| 157 mojom::WindowManagerInstancePtr window_manager_ptr) { | |
| 158 DCHECK(CalledOnValidThread()); | |
| 159 window_manager_.OnInstanceReady(std::move(window_manager_ptr)); | |
| 160 } | |
| 161 | |
| 162 void ArcBridgeService::SetState(State state) { | 55 void ArcBridgeService::SetState(State state) { |
| 163 DCHECK(CalledOnValidThread()); | 56 DCHECK(CalledOnValidThread()); |
| 164 // DCHECK on enum classes not supported. | 57 // DCHECK on enum classes not supported. |
| 165 DCHECK(state_ != state); | 58 DCHECK(state_ != state); |
| 166 state_ = state; | 59 state_ = state; |
| 167 VLOG(2) << "State: " << static_cast<uint32_t>(state_); | 60 VLOG(2) << "State: " << static_cast<uint32_t>(state_); |
| 168 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 61 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
| 169 if (state_ == State::READY) | 62 if (state_ == State::READY) |
| 170 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeReady()); | 63 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeReady()); |
| 171 else if (state == State::STOPPED) | 64 else if (state == State::STOPPED) |
| 172 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeStopped()); | 65 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeStopped()); |
| 173 } | 66 } |
| 174 | 67 |
| 175 void ArcBridgeService::SetAvailable(bool available) { | 68 void ArcBridgeService::SetAvailable(bool available) { |
| 176 DCHECK(CalledOnValidThread()); | 69 DCHECK(CalledOnValidThread()); |
| 177 DCHECK(available_ != available); | 70 DCHECK(available_ != available); |
| 178 available_ = available; | 71 available_ = available; |
| 179 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); | 72 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); |
| 180 } | 73 } |
| 181 | 74 |
| 182 bool ArcBridgeService::CalledOnValidThread() { | 75 bool ArcBridgeService::CalledOnValidThread() { |
| 183 return thread_checker_.CalledOnValidThread(); | 76 return thread_checker_.CalledOnValidThread(); |
| 184 } | 77 } |
| 185 | 78 |
| 186 void ArcBridgeService::CloseAllChannels() { | |
| 187 // Call all the error handlers of all the channels to both close the channel | |
| 188 // and notify any observers that the channel is closed. | |
| 189 app_.CloseChannel(); | |
| 190 audio_.CloseChannel(); | |
| 191 auth_.CloseChannel(); | |
| 192 bluetooth_.CloseChannel(); | |
| 193 clipboard_.CloseChannel(); | |
| 194 crash_collector_.CloseChannel(); | |
| 195 file_system_.CloseChannel(); | |
| 196 ime_.CloseChannel(); | |
| 197 intent_helper_.CloseChannel(); | |
| 198 metrics_.CloseChannel(); | |
| 199 net_.CloseChannel(); | |
| 200 notifications_.CloseChannel(); | |
| 201 obb_mounter_.CloseChannel(); | |
| 202 policy_.CloseChannel(); | |
| 203 power_.CloseChannel(); | |
| 204 process_.CloseChannel(); | |
| 205 storage_manager_.CloseChannel(); | |
| 206 video_.CloseChannel(); | |
| 207 window_manager_.CloseChannel(); | |
| 208 } | |
| 209 | |
| 210 } // namespace arc | 79 } // namespace arc |
| OLD | NEW |