Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: components/arc/power/arc_power_bridge.cc

Issue 1596663002: arc-bridge: Introduce the ArcService class (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Rebased + protected ArcService direct instantiation Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/arc/power/arc_power_bridge.h ('k') | components/arc/settings/arc_settings_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « components/arc/power/arc_power_bridge.h ('k') | components/arc/settings/arc_settings_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698