| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 if (policy_instance()) | 81 if (policy_instance()) |
| 82 observer->OnPolicyInstanceReady(); | 82 observer->OnPolicyInstanceReady(); |
| 83 if (power_instance()) | 83 if (power_instance()) |
| 84 observer->OnPowerInstanceReady(); | 84 observer->OnPowerInstanceReady(); |
| 85 if (process_instance()) | 85 if (process_instance()) |
| 86 observer->OnProcessInstanceReady(); | 86 observer->OnProcessInstanceReady(); |
| 87 if (video_instance()) | 87 if (video_instance()) |
| 88 observer->OnVideoInstanceReady(); | 88 observer->OnVideoInstanceReady(); |
| 89 if (window_manager_instance()) | 89 if (window_manager_instance()) |
| 90 observer->OnWindowManagerInstanceReady(); | 90 observer->OnWindowManagerInstanceReady(); |
| 91 if (obb_mounter_instance()) |
| 92 observer->OnObbMounterInstanceReady(); |
| 91 } | 93 } |
| 92 | 94 |
| 93 void ArcBridgeService::RemoveObserver(Observer* observer) { | 95 void ArcBridgeService::RemoveObserver(Observer* observer) { |
| 94 DCHECK(CalledOnValidThread()); | 96 DCHECK(CalledOnValidThread()); |
| 95 observer_list_.RemoveObserver(observer); | 97 observer_list_.RemoveObserver(observer); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void ArcBridgeService::OnAppInstanceReady(mojom::AppInstancePtr app_ptr) { | 100 void ArcBridgeService::OnAppInstanceReady(mojom::AppInstancePtr app_ptr) { |
| 99 DCHECK(CalledOnValidThread()); | 101 DCHECK(CalledOnValidThread()); |
| 100 temporary_app_ptr_ = std::move(app_ptr); | 102 temporary_app_ptr_ = std::move(app_ptr); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 } | 489 } |
| 488 | 490 |
| 489 void ArcBridgeService::CloseWindowManagerChannel() { | 491 void ArcBridgeService::CloseWindowManagerChannel() { |
| 490 if (!window_manager_ptr_) | 492 if (!window_manager_ptr_) |
| 491 return; | 493 return; |
| 492 | 494 |
| 493 window_manager_ptr_.reset(); | 495 window_manager_ptr_.reset(); |
| 494 FOR_EACH_OBSERVER(Observer, observer_list(), OnWindowManagerInstanceClosed()); | 496 FOR_EACH_OBSERVER(Observer, observer_list(), OnWindowManagerInstanceClosed()); |
| 495 } | 497 } |
| 496 | 498 |
| 499 void ArcBridgeService::OnObbMounterInstanceReady( |
| 500 mojom::ObbMounterInstancePtr obb_mounter_ptr) { |
| 501 DCHECK(CalledOnValidThread()); |
| 502 temporary_obb_mounter_ptr_ = std::move(obb_mounter_ptr); |
| 503 temporary_obb_mounter_ptr_.QueryVersion(base::Bind( |
| 504 &ArcBridgeService::OnObbMounterVersionReady, |
| 505 weak_factory_.GetWeakPtr())); |
| 506 } |
| 507 |
| 508 void ArcBridgeService::OnObbMounterVersionReady(int32_t version) { |
| 509 DCHECK(CalledOnValidThread()); |
| 510 obb_mounter_ptr_ = std::move(temporary_obb_mounter_ptr_); |
| 511 obb_mounter_ptr_.set_connection_error_handler(base::Bind( |
| 512 &ArcBridgeService::CloseObbMounterChannel, |
| 513 weak_factory_.GetWeakPtr())); |
| 514 FOR_EACH_OBSERVER(Observer, observer_list(), OnObbMounterInstanceReady()); |
| 515 } |
| 516 |
| 517 void ArcBridgeService::CloseObbMounterChannel() { |
| 518 if (!obb_mounter_ptr_) |
| 519 return; |
| 520 |
| 521 obb_mounter_ptr_.reset(); |
| 522 FOR_EACH_OBSERVER(Observer, observer_list(), OnObbMounterInstanceClosed()); |
| 523 } |
| 524 |
| 497 void ArcBridgeService::SetState(State state) { | 525 void ArcBridgeService::SetState(State state) { |
| 498 DCHECK(CalledOnValidThread()); | 526 DCHECK(CalledOnValidThread()); |
| 499 // DCHECK on enum classes not supported. | 527 // DCHECK on enum classes not supported. |
| 500 DCHECK(state_ != state); | 528 DCHECK(state_ != state); |
| 501 state_ = state; | 529 state_ = state; |
| 502 VLOG(2) << "State: " << static_cast<uint32_t>(state_); | 530 VLOG(2) << "State: " << static_cast<uint32_t>(state_); |
| 503 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 531 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
| 504 } | 532 } |
| 505 | 533 |
| 506 void ArcBridgeService::SetAvailable(bool available) { | 534 void ArcBridgeService::SetAvailable(bool available) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 526 CloseImeChannel(); | 554 CloseImeChannel(); |
| 527 CloseIntentHelperChannel(); | 555 CloseIntentHelperChannel(); |
| 528 CloseMetricsChannel(); | 556 CloseMetricsChannel(); |
| 529 CloseNetChannel(); | 557 CloseNetChannel(); |
| 530 CloseNotificationsChannel(); | 558 CloseNotificationsChannel(); |
| 531 ClosePolicyChannel(); | 559 ClosePolicyChannel(); |
| 532 ClosePowerChannel(); | 560 ClosePowerChannel(); |
| 533 CloseProcessChannel(); | 561 CloseProcessChannel(); |
| 534 CloseVideoChannel(); | 562 CloseVideoChannel(); |
| 535 CloseWindowManagerChannel(); | 563 CloseWindowManagerChannel(); |
| 564 CloseObbMounterChannel(); |
| 536 } | 565 } |
| 537 | 566 |
| 538 } // namespace arc | 567 } // namespace arc |
| OLD | NEW |