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 "base/logging.h" | 10 #include "base/logging.h" |
11 #include "chromeos/dbus/power_policy_controller.h" | 11 #include "chromeos/dbus/power_policy_controller.h" |
12 #include "components/arc/arc_service_manager.h" | 12 #include "components/arc/arc_service_manager.h" |
13 | 13 |
14 namespace arc { | 14 namespace arc { |
15 | 15 |
16 ArcPowerBridge::ArcPowerBridge(ArcBridgeService* arc_bridge_service) | 16 ArcPowerBridge::ArcPowerBridge(ArcBridgeService* bridge_service) |
17 : arc_bridge_service_(arc_bridge_service), binding_(this) { | 17 : ArcService(bridge_service), binding_(this) { |
18 arc_bridge_service->AddObserver(this); | 18 arc_bridge_service()->AddObserver(this); |
19 if (arc_bridge_service->power_instance()) | |
20 OnPowerInstanceReady(); | |
21 } | 19 } |
22 | 20 |
23 ArcPowerBridge::~ArcPowerBridge() { | 21 ArcPowerBridge::~ArcPowerBridge() { |
24 arc_bridge_service_->RemoveObserver(this); | 22 arc_bridge_service()->RemoveObserver(this); |
25 ReleaseAllDisplayWakeLocks(); | 23 ReleaseAllDisplayWakeLocks(); |
26 } | 24 } |
27 | 25 |
28 void ArcPowerBridge::OnStateChanged(ArcBridgeService::State state) { | 26 void ArcPowerBridge::OnStateChanged(ArcBridgeService::State state) { |
29 if (state == ArcBridgeService::State::STOPPING) | 27 if (state == ArcBridgeService::State::STOPPING) |
30 ReleaseAllDisplayWakeLocks(); | 28 ReleaseAllDisplayWakeLocks(); |
31 } | 29 } |
32 | 30 |
33 void ArcPowerBridge::OnPowerInstanceReady() { | 31 void ArcPowerBridge::OnPowerInstanceReady() { |
34 PowerInstance* power_instance = arc_bridge_service_->power_instance(); | 32 PowerInstance* power_instance = arc_bridge_service()->power_instance(); |
35 if (!power_instance) { | 33 if (!power_instance) { |
36 LOG(ERROR) << "OnPowerInstanceReady called, but no power instance found"; | 34 LOG(ERROR) << "OnPowerInstanceReady called, but no power instance found"; |
37 return; | 35 return; |
38 } | 36 } |
39 | 37 |
40 PowerHostPtr host; | 38 PowerHostPtr host; |
41 binding_.Bind(mojo::GetProxy(&host)); | 39 binding_.Bind(mojo::GetProxy(&host)); |
42 power_instance->Init(std::move(host)); | 40 power_instance->Init(std::move(host)); |
43 } | 41 } |
44 | 42 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 chromeos::PowerPolicyController* controller = | 97 chromeos::PowerPolicyController* controller = |
100 chromeos::PowerPolicyController::Get(); | 98 chromeos::PowerPolicyController::Get(); |
101 | 99 |
102 for (const auto& it : wake_locks_) { | 100 for (const auto& it : wake_locks_) { |
103 controller->RemoveWakeLock(it.second); | 101 controller->RemoveWakeLock(it.second); |
104 } | 102 } |
105 wake_locks_.clear(); | 103 wake_locks_.clear(); |
106 } | 104 } |
107 | 105 |
108 } // namespace arc | 106 } // namespace arc |
OLD | NEW |