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

Side by Side Diff: chrome/browser/chromeos/dbus/power_manager_client.cc

Issue 8537001: chromeos: Power manager client calls shutdown and restart (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: removed DCHECK for power library Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/dbus/power_manager_client.h" 5 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 virtual void RequestStatusUpdate() OVERRIDE { 126 virtual void RequestStatusUpdate() OVERRIDE {
127 dbus::MethodCall method_call(power_manager::kPowerManagerInterface, 127 dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
128 power_manager::kGetAllPropertiesMethod); 128 power_manager::kGetAllPropertiesMethod);
129 power_manager_proxy_->CallMethod( 129 power_manager_proxy_->CallMethod(
130 &method_call, 130 &method_call,
131 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 131 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
132 base::Bind(&PowerManagerClientImpl::OnGetAllPropertiesMethod, 132 base::Bind(&PowerManagerClientImpl::OnGetAllPropertiesMethod,
133 weak_ptr_factory_.GetWeakPtr())); 133 weak_ptr_factory_.GetWeakPtr()));
134 } 134 }
135 135
136 // Requests restart of the system.
137 virtual void RequestRestart() OVERRIDE {
138 dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
139 power_manager::kRequestRestartMethod);
140 power_manager_proxy_->CallMethod(
141 &method_call,
142 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
143 dbus::ObjectProxy::EmptyResponseCallback());
144 };
145
146 // Requests shutdown of the system.
147 virtual void RequestShutdown() OVERRIDE {
148 dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
149 power_manager::kRequestShutdownMethod);
150 power_manager_proxy_->CallMethod(
151 &method_call,
152 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
153 dbus::ObjectProxy::EmptyResponseCallback());
154 }
155
156
136 private: 157 private:
137 // Called when a dbus signal is initially connected. 158 // Called when a dbus signal is initially connected.
138 void SignalConnected(const std::string& interface_name, 159 void SignalConnected(const std::string& interface_name,
139 const std::string& signal_name, 160 const std::string& signal_name,
140 bool success) { 161 bool success) {
141 LOG_IF(WARNING, !success) << "Failed to connect to signal " 162 LOG_IF(WARNING, !success) << "Failed to connect to signal "
142 << signal_name << "."; 163 << signal_name << ".";
143 } 164 }
144 165
145 // Called when a brightness change signal is received. 166 // Called when a brightness change signal is received.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 timer_.Start( 277 timer_.Start(
257 FROM_HERE, 278 FROM_HERE,
258 base::TimeDelta::FromMilliseconds(100), 279 base::TimeDelta::FromMilliseconds(100),
259 this, 280 this,
260 &PowerManagerClientStubImpl::Update); 281 &PowerManagerClientStubImpl::Update);
261 } else { 282 } else {
262 timer_.Stop(); 283 timer_.Stop();
263 } 284 }
264 } 285 }
265 286
287 virtual void RequestRestart() OVERRIDE {}
288
289 virtual void RequestShutdown() OVERRIDE {}
290
266 private: 291 private:
267 void Update() { 292 void Update() {
268 // We pause at 0 and 100% so that it's easier to check those conditions. 293 // We pause at 0 and 100% so that it's easier to check those conditions.
269 if (pause_count_ > 1) { 294 if (pause_count_ > 1) {
270 pause_count_--; 295 pause_count_--;
271 return; 296 return;
272 } 297 }
273 298
274 if (battery_percentage_ == 0 || battery_percentage_ == 100) { 299 if (battery_percentage_ == 0 || battery_percentage_ == 100) {
275 if (pause_count_) { 300 if (pause_count_) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 334
310 PowerManagerClient* PowerManagerClient::Create(dbus::Bus* bus) { 335 PowerManagerClient* PowerManagerClient::Create(dbus::Bus* bus) {
311 if (system::runtime_environment::IsRunningOnChromeOS()) { 336 if (system::runtime_environment::IsRunningOnChromeOS()) {
312 return new PowerManagerClientImpl(bus); 337 return new PowerManagerClientImpl(bus);
313 } else { 338 } else {
314 return new PowerManagerClientStubImpl(); 339 return new PowerManagerClientStubImpl();
315 } 340 }
316 } 341 }
317 342
318 } // namespace chromeos 343 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/dbus/power_manager_client.h ('k') | chrome/browser/chromeos/login/shutdown_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698