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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 void ArcBridgeService::CloseSettingsChannel() { | 197 void ArcBridgeService::CloseSettingsChannel() { |
198 DCHECK(CalledOnValidThread()); | 198 DCHECK(CalledOnValidThread()); |
199 if (!settings_ptr_) | 199 if (!settings_ptr_) |
200 return; | 200 return; |
201 | 201 |
202 settings_ptr_.reset(); | 202 settings_ptr_.reset(); |
203 FOR_EACH_OBSERVER(Observer, observer_list(), OnSettingsInstanceClosed()); | 203 FOR_EACH_OBSERVER(Observer, observer_list(), OnSettingsInstanceClosed()); |
204 } | 204 } |
205 | 205 |
| 206 void ArcBridgeService::OnVideoInstanceReady(VideoInstancePtr video_ptr) { |
| 207 DCHECK(CalledOnValidThread()); |
| 208 temporary_video_ptr_ = std::move(video_ptr); |
| 209 temporary_video_ptr_.QueryVersion(base::Bind( |
| 210 &ArcBridgeService::OnVideoVersionReady, weak_factory_.GetWeakPtr())); |
| 211 } |
| 212 |
| 213 void ArcBridgeService::OnVideoVersionReady(int32_t version) { |
| 214 video_ptr_ = std::move(temporary_video_ptr_); |
| 215 FOR_EACH_OBSERVER(Observer, observer_list(), OnVideoInstanceReady()); |
| 216 video_ptr_.set_connection_error_handler(base::Bind( |
| 217 &ArcBridgeService::CloseVideoChannel, weak_factory_.GetWeakPtr())); |
| 218 } |
| 219 |
| 220 void ArcBridgeService::CloseVideoChannel() { |
| 221 DCHECK(CalledOnValidThread()); |
| 222 if (!video_ptr_) |
| 223 return; |
| 224 |
| 225 video_ptr_.reset(); |
| 226 FOR_EACH_OBSERVER(Observer, observer_list(), OnVideoInstanceClosed()); |
| 227 } |
| 228 |
206 void ArcBridgeService::SetState(State state) { | 229 void ArcBridgeService::SetState(State state) { |
207 DCHECK(CalledOnValidThread()); | 230 DCHECK(CalledOnValidThread()); |
208 // DCHECK on enum classes not supported. | 231 // DCHECK on enum classes not supported. |
209 DCHECK(state_ != state); | 232 DCHECK(state_ != state); |
210 state_ = state; | 233 state_ = state; |
211 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 234 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
212 } | 235 } |
213 | 236 |
214 void ArcBridgeService::SetAvailable(bool available) { | 237 void ArcBridgeService::SetAvailable(bool available) { |
215 DCHECK(CalledOnValidThread()); | 238 DCHECK(CalledOnValidThread()); |
216 DCHECK(available_ != available); | 239 DCHECK(available_ != available); |
217 available_ = available; | 240 available_ = available; |
218 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); | 241 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); |
219 } | 242 } |
220 | 243 |
221 bool ArcBridgeService::CalledOnValidThread() { | 244 bool ArcBridgeService::CalledOnValidThread() { |
222 return thread_checker_.CalledOnValidThread(); | 245 return thread_checker_.CalledOnValidThread(); |
223 } | 246 } |
224 | 247 |
225 void ArcBridgeService::CloseAllChannels() { | 248 void ArcBridgeService::CloseAllChannels() { |
226 // Call all the error handlers of all the channels to both close the channel | 249 // Call all the error handlers of all the channels to both close the channel |
227 // and notify any observers that the channel is closed. | 250 // and notify any observers that the channel is closed. |
228 CloseAppChannel(); | 251 CloseAppChannel(); |
229 CloseInputChannel(); | 252 CloseInputChannel(); |
230 CloseNotificationsChannel(); | 253 CloseNotificationsChannel(); |
231 ClosePowerChannel(); | 254 ClosePowerChannel(); |
232 CloseProcessChannel(); | 255 CloseProcessChannel(); |
233 CloseSettingsChannel(); | 256 CloseSettingsChannel(); |
| 257 CloseVideoChannel(); |
234 } | 258 } |
235 | 259 |
236 } // namespace arc | 260 } // namespace arc |
OLD | NEW |