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

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

Issue 2409983006: Make [S,G]getBacklightsForcedOff dbus API integrated to power_manager_client (Closed)
Patch Set: based on Daniel's comments Created 4 years, 2 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 | « chromeos/dbus/power_manager_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/dbus/power_manager_client.h" 5 #include "chromeos/dbus/power_manager_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 POWER_LOG(USER) << "SetPowerSource: " << id; 239 POWER_LOG(USER) << "SetPowerSource: " << id;
240 dbus::MethodCall method_call(power_manager::kPowerManagerInterface, 240 dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
241 power_manager::kSetPowerSourceMethod); 241 power_manager::kSetPowerSourceMethod);
242 dbus::MessageWriter writer(&method_call); 242 dbus::MessageWriter writer(&method_call);
243 writer.AppendString(id); 243 writer.AppendString(id);
244 power_manager_proxy_->CallMethod( 244 power_manager_proxy_->CallMethod(
245 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 245 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
246 dbus::ObjectProxy::EmptyResponseCallback()); 246 dbus::ObjectProxy::EmptyResponseCallback());
247 } 247 }
248 248
249 void SetBacklightsForcedOff(bool forced_off) override {
250 dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
251 power_manager::kSetBacklightsForcedOffMethod);
252 dbus::MessageWriter(&method_call).AppendBool(forced_off);
253 power_manager_proxy_->CallMethod(
254 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
255 dbus::ObjectProxy::EmptyResponseCallback());
256 }
257
258 void GetBacklightsForcedOff(
259 const GetBacklightsForcedOffCallback& callback) override {
260 dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
261 power_manager::kGetBacklightsForcedOffMethod);
262 power_manager_proxy_->CallMethod(
263 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
264 base::Bind(&PowerManagerClientImpl::OnGetBacklightsForcedOff,
265 weak_ptr_factory_.GetWeakPtr(), callback));
266 }
267
249 base::Closure GetSuspendReadinessCallback() override { 268 base::Closure GetSuspendReadinessCallback() override {
250 DCHECK(OnOriginThread()); 269 DCHECK(OnOriginThread());
251 DCHECK(suspend_is_pending_); 270 DCHECK(suspend_is_pending_);
252 num_pending_suspend_readiness_callbacks_++; 271 num_pending_suspend_readiness_callbacks_++;
253 return base::Bind(&PowerManagerClientImpl::HandleObserverSuspendReadiness, 272 return base::Bind(&PowerManagerClientImpl::HandleObserverSuspendReadiness,
254 weak_ptr_factory_.GetWeakPtr(), pending_suspend_id_, 273 weak_ptr_factory_.GetWeakPtr(), pending_suspend_id_,
255 suspending_from_dark_resume_); 274 suspending_from_dark_resume_);
256 } 275 }
257 276
258 int GetNumPendingSuspendReadinessCallbacks() override { 277 int GetNumPendingSuspendReadinessCallbacks() override {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 dbus::Response* response) { 483 dbus::Response* response) {
465 if (!response) { 484 if (!response) {
466 if (!system::StatisticsProvider::GetInstance()->IsRunningOnVm()) { 485 if (!system::StatisticsProvider::GetInstance()->IsRunningOnVm()) {
467 POWER_LOG(ERROR) << "Error calling " 486 POWER_LOG(ERROR) << "Error calling "
468 << power_manager::kGetScreenBrightnessPercentMethod; 487 << power_manager::kGetScreenBrightnessPercentMethod;
469 } 488 }
470 return; 489 return;
471 } 490 }
472 dbus::MessageReader reader(response); 491 dbus::MessageReader reader(response);
473 double percent = 0.0; 492 double percent = 0.0;
474 if (!reader.PopDouble(&percent)) 493 if (!reader.PopDouble(&percent)) {
Daniel Erat 2016/10/13 21:37:35 ah, thanks for fixing this too :-)
475 POWER_LOG(ERROR) << "Error reading response from powerd: " 494 POWER_LOG(ERROR) << "Error reading response from powerd: "
476 << response->ToString(); 495 << response->ToString();
496 }
477 callback.Run(percent); 497 callback.Run(percent);
478 } 498 }
479 499
500 void OnGetBacklightsForcedOff(const GetBacklightsForcedOffCallback& callback,
501 dbus::Response* response) {
502 if (!response) {
503 POWER_LOG(ERROR) << "Error calling "
504 << power_manager::kGetBacklightsForcedOffMethod;
505 return;
506 }
507 dbus::MessageReader reader(response);
508 bool state = false;
509 if (!reader.PopBool(&state)) {
510 POWER_LOG(ERROR) << "Error reading response from powerd: "
511 << response->ToString();
512 }
513 callback.Run(state);
514 }
515
480 void HandlePowerSupplyProperties( 516 void HandlePowerSupplyProperties(
481 const power_manager::PowerSupplyProperties& proto) { 517 const power_manager::PowerSupplyProperties& proto) {
482 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(proto)); 518 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(proto));
483 const bool on_battery = proto.external_power() == 519 const bool on_battery = proto.external_power() ==
484 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED; 520 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED;
485 base::PowerMonitorDeviceSource::SetPowerSource(on_battery); 521 base::PowerMonitorDeviceSource::SetPowerSource(on_battery);
486 } 522 }
487 523
488 void HandleRegisterSuspendDelayReply(bool dark_suspend, 524 void HandleRegisterSuspendDelayReply(bool dark_suspend,
489 const std::string& method_name, 525 const std::string& method_name,
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 // static 910 // static
875 PowerManagerClient* PowerManagerClient::Create( 911 PowerManagerClient* PowerManagerClient::Create(
876 DBusClientImplementationType type) { 912 DBusClientImplementationType type) {
877 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 913 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
878 return new PowerManagerClientImpl(); 914 return new PowerManagerClientImpl();
879 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type); 915 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type);
880 return new FakePowerManagerClient(); 916 return new FakePowerManagerClient();
881 } 917 }
882 918
883 } // namespace chromeos 919 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/power_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698