| 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/power/arc_power_bridge.h" | 5 #include "components/arc/power/arc_power_bridge.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "chromeos/dbus/power_policy_controller.h" | 12 #include "chromeos/dbus/power_policy_controller.h" |
| 13 #include "components/arc/arc_service_manager.h" | 13 #include "components/arc/arc_service_manager.h" |
| 14 | 14 |
| 15 namespace arc { | 15 namespace arc { |
| 16 | 16 |
| 17 ArcPowerBridge::ArcPowerBridge(ArcBridgeService* bridge_service) | 17 ArcPowerBridge::ArcPowerBridge(ArcBridgeService* bridge_service) |
| 18 : ArcService(bridge_service), binding_(this) { | 18 : ArcService(bridge_service), binding_(this) { |
| 19 arc_bridge_service()->AddObserver(this); | 19 arc_bridge_service()->power()->AddObserver(this); |
| 20 } | 20 } |
| 21 | 21 |
| 22 ArcPowerBridge::~ArcPowerBridge() { | 22 ArcPowerBridge::~ArcPowerBridge() { |
| 23 arc_bridge_service()->RemoveObserver(this); | 23 arc_bridge_service()->power()->RemoveObserver(this); |
| 24 ReleaseAllDisplayWakeLocks(); | 24 ReleaseAllDisplayWakeLocks(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void ArcPowerBridge::OnPowerInstanceReady() { | 27 void ArcPowerBridge::OnInstanceReady() { |
| 28 mojom::PowerInstance* power_instance = arc_bridge_service()->power_instance(); | 28 mojom::PowerInstance* power_instance = |
| 29 arc_bridge_service()->power()->instance(); |
| 29 if (!power_instance) { | 30 if (!power_instance) { |
| 30 LOG(ERROR) << "OnPowerInstanceReady called, but no power instance found"; | 31 LOG(ERROR) << "OnPowerInstanceReady called, but no power instance found"; |
| 31 return; | 32 return; |
| 32 } | 33 } |
| 33 | 34 |
| 34 power_instance->Init(binding_.CreateInterfacePtrAndBind()); | 35 power_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 35 ash::Shell::GetInstance()->display_configurator()->AddObserver(this); | 36 ash::Shell::GetInstance()->display_configurator()->AddObserver(this); |
| 36 } | 37 } |
| 37 | 38 |
| 38 void ArcPowerBridge::OnPowerInstanceClosed() { | 39 void ArcPowerBridge::OnInstanceClosed() { |
| 39 ash::Shell::GetInstance()->display_configurator()->RemoveObserver(this); | 40 ash::Shell::GetInstance()->display_configurator()->RemoveObserver(this); |
| 40 ReleaseAllDisplayWakeLocks(); | 41 ReleaseAllDisplayWakeLocks(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void ArcPowerBridge::OnPowerStateChanged( | 44 void ArcPowerBridge::OnPowerStateChanged( |
| 44 chromeos::DisplayPowerState power_state) { | 45 chromeos::DisplayPowerState power_state) { |
| 45 mojom::PowerInstance* power_instance = arc_bridge_service()->power_instance(); | 46 mojom::PowerInstance* power_instance = |
| 47 arc_bridge_service()->power()->instance(); |
| 46 if (!power_instance) { | 48 if (!power_instance) { |
| 47 LOG(ERROR) << "PowerInstance is not available"; | 49 LOG(ERROR) << "PowerInstance is not available"; |
| 48 return; | 50 return; |
| 49 } | 51 } |
| 50 | 52 |
| 51 bool enabled = (power_state != chromeos::DISPLAY_POWER_ALL_OFF); | 53 bool enabled = (power_state != chromeos::DISPLAY_POWER_ALL_OFF); |
| 52 power_instance->SetInteractive(enabled); | 54 power_instance->SetInteractive(enabled); |
| 53 } | 55 } |
| 54 | 56 |
| 55 void ArcPowerBridge::OnAcquireDisplayWakeLock(mojom::DisplayWakeLockType type) { | 57 void ArcPowerBridge::OnAcquireDisplayWakeLock(mojom::DisplayWakeLockType type) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 chromeos::PowerPolicyController* controller = | 114 chromeos::PowerPolicyController* controller = |
| 113 chromeos::PowerPolicyController::Get(); | 115 chromeos::PowerPolicyController::Get(); |
| 114 | 116 |
| 115 for (const auto& it : wake_locks_) { | 117 for (const auto& it : wake_locks_) { |
| 116 controller->RemoveWakeLock(it.second); | 118 controller->RemoveWakeLock(it.second); |
| 117 } | 119 } |
| 118 wake_locks_.clear(); | 120 wake_locks_.clear(); |
| 119 } | 121 } |
| 120 | 122 |
| 121 } // namespace arc | 123 } // namespace arc |
| OLD | NEW |