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 |
55 void ArcBridgeService::SetState(State state) { | 162 void ArcBridgeService::SetState(State state) { |
56 DCHECK(CalledOnValidThread()); | 163 DCHECK(CalledOnValidThread()); |
57 DCHECK_NE(state_, state); | 164 DCHECK_NE(state_, state); |
58 state_ = state; | 165 state_ = state; |
59 VLOG(2) << "State: " << static_cast<uint32_t>(state_); | 166 VLOG(2) << "State: " << static_cast<uint32_t>(state_); |
60 if (state_ == State::READY) | 167 if (state_ == State::READY) |
61 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeReady()); | 168 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeReady()); |
62 else if (state == State::STOPPED) | 169 else if (state == State::STOPPED) |
63 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeStopped()); | 170 FOR_EACH_OBSERVER(Observer, observer_list(), OnBridgeStopped()); |
64 } | 171 } |
65 | 172 |
66 void ArcBridgeService::SetAvailable(bool available) { | 173 void ArcBridgeService::SetAvailable(bool available) { |
67 DCHECK(CalledOnValidThread()); | 174 DCHECK(CalledOnValidThread()); |
68 DCHECK_NE(available_, available); | 175 DCHECK_NE(available_, available); |
69 available_ = available; | 176 available_ = available; |
70 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); | 177 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); |
71 } | 178 } |
72 | 179 |
73 bool ArcBridgeService::CalledOnValidThread() { | 180 bool ArcBridgeService::CalledOnValidThread() { |
74 return thread_checker_.CalledOnValidThread(); | 181 return thread_checker_.CalledOnValidThread(); |
75 } | 182 } |
76 | 183 |
| 184 void ArcBridgeService::CloseAllChannels() { |
| 185 // Call all the error handlers of all the channels to both close the channel |
| 186 // and notify any observers that the channel is closed. |
| 187 app_.CloseChannel(); |
| 188 audio_.CloseChannel(); |
| 189 auth_.CloseChannel(); |
| 190 bluetooth_.CloseChannel(); |
| 191 clipboard_.CloseChannel(); |
| 192 crash_collector_.CloseChannel(); |
| 193 file_system_.CloseChannel(); |
| 194 ime_.CloseChannel(); |
| 195 intent_helper_.CloseChannel(); |
| 196 metrics_.CloseChannel(); |
| 197 net_.CloseChannel(); |
| 198 notifications_.CloseChannel(); |
| 199 obb_mounter_.CloseChannel(); |
| 200 policy_.CloseChannel(); |
| 201 power_.CloseChannel(); |
| 202 process_.CloseChannel(); |
| 203 storage_manager_.CloseChannel(); |
| 204 video_.CloseChannel(); |
| 205 window_manager_.CloseChannel(); |
| 206 } |
| 207 |
77 } // namespace arc | 208 } // namespace arc |
OLD | NEW |