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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (ime_instance()) | 62 if (ime_instance()) |
63 observer->OnImeInstanceReady(); | 63 observer->OnImeInstanceReady(); |
64 if (input_instance()) | 64 if (input_instance()) |
65 observer->OnInputInstanceReady(); | 65 observer->OnInputInstanceReady(); |
66 if (notifications_instance()) | 66 if (notifications_instance()) |
67 observer->OnNotificationsInstanceReady(); | 67 observer->OnNotificationsInstanceReady(); |
68 if (power_instance()) | 68 if (power_instance()) |
69 observer->OnPowerInstanceReady(); | 69 observer->OnPowerInstanceReady(); |
70 if (process_instance()) | 70 if (process_instance()) |
71 observer->OnProcessInstanceReady(); | 71 observer->OnProcessInstanceReady(); |
72 if (video_instance()) | |
73 observer->OnVideoInstanceReady(); | |
74 } | 72 } |
75 | 73 |
76 void ArcBridgeService::RemoveObserver(Observer* observer) { | 74 void ArcBridgeService::RemoveObserver(Observer* observer) { |
77 DCHECK(CalledOnValidThread()); | 75 DCHECK(CalledOnValidThread()); |
78 observer_list_.RemoveObserver(observer); | 76 observer_list_.RemoveObserver(observer); |
79 } | 77 } |
80 | 78 |
81 void ArcBridgeService::OnAppInstanceReady(AppInstancePtr app_ptr) { | 79 void ArcBridgeService::OnAppInstanceReady(AppInstancePtr app_ptr) { |
82 DCHECK(CalledOnValidThread()); | 80 DCHECK(CalledOnValidThread()); |
83 temporary_app_ptr_ = std::move(app_ptr); | 81 temporary_app_ptr_ = std::move(app_ptr); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 296 |
299 process_ptr_.reset(); | 297 process_ptr_.reset(); |
300 FOR_EACH_OBSERVER(Observer, observer_list(), OnProcessInstanceClosed()); | 298 FOR_EACH_OBSERVER(Observer, observer_list(), OnProcessInstanceClosed()); |
301 } | 299 } |
302 | 300 |
303 void ArcBridgeService::OnSettingsInstanceReady( | 301 void ArcBridgeService::OnSettingsInstanceReady( |
304 SettingsInstancePtr settings_ptr) { | 302 SettingsInstancePtr settings_ptr) { |
305 // Obsolete interface. | 303 // Obsolete interface. |
306 } | 304 } |
307 | 305 |
308 void ArcBridgeService::OnVideoInstanceReady(VideoInstancePtr video_ptr) { | |
309 DCHECK(CalledOnValidThread()); | |
310 temporary_video_ptr_ = std::move(video_ptr); | |
311 temporary_video_ptr_.QueryVersion(base::Bind( | |
312 &ArcBridgeService::OnVideoVersionReady, weak_factory_.GetWeakPtr())); | |
313 } | |
314 | |
315 void ArcBridgeService::OnVideoVersionReady(int32_t version) { | |
316 DCHECK(CalledOnValidThread()); | |
317 video_ptr_ = std::move(temporary_video_ptr_); | |
318 video_ptr_.set_connection_error_handler(base::Bind( | |
319 &ArcBridgeService::CloseVideoChannel, weak_factory_.GetWeakPtr())); | |
320 FOR_EACH_OBSERVER(Observer, observer_list(), OnVideoInstanceReady()); | |
321 } | |
322 | |
323 void ArcBridgeService::CloseVideoChannel() { | |
324 DCHECK(CalledOnValidThread()); | |
325 if (!video_ptr_) | |
326 return; | |
327 | |
328 video_ptr_.reset(); | |
329 FOR_EACH_OBSERVER(Observer, observer_list(), OnVideoInstanceClosed()); | |
330 } | |
331 | |
332 void ArcBridgeService::SetState(State state) { | 306 void ArcBridgeService::SetState(State state) { |
333 DCHECK(CalledOnValidThread()); | 307 DCHECK(CalledOnValidThread()); |
334 // DCHECK on enum classes not supported. | 308 // DCHECK on enum classes not supported. |
335 DCHECK(state_ != state); | 309 DCHECK(state_ != state); |
336 state_ = state; | 310 state_ = state; |
337 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 311 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
338 } | 312 } |
339 | 313 |
340 void ArcBridgeService::SetAvailable(bool available) { | 314 void ArcBridgeService::SetAvailable(bool available) { |
341 DCHECK(CalledOnValidThread()); | 315 DCHECK(CalledOnValidThread()); |
(...skipping 11 matching lines...) Expand all Loading... |
353 // and notify any observers that the channel is closed. | 327 // and notify any observers that the channel is closed. |
354 CloseAppChannel(); | 328 CloseAppChannel(); |
355 CloseAuthChannel(); | 329 CloseAuthChannel(); |
356 CloseClipboardChannel(); | 330 CloseClipboardChannel(); |
357 CloseImeChannel(); | 331 CloseImeChannel(); |
358 CloseInputChannel(); | 332 CloseInputChannel(); |
359 CloseIntentHelperChannel(); | 333 CloseIntentHelperChannel(); |
360 CloseNotificationsChannel(); | 334 CloseNotificationsChannel(); |
361 ClosePowerChannel(); | 335 ClosePowerChannel(); |
362 CloseProcessChannel(); | 336 CloseProcessChannel(); |
363 CloseVideoChannel(); | |
364 } | 337 } |
365 | 338 |
366 } // namespace arc | 339 } // namespace arc |
OLD | NEW |