Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 11 matching lines...) Expand all Loading... | |
| 22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 23 #include "base/threading/platform_thread.h" | 23 #include "base/threading/platform_thread.h" |
| 24 #include "base/timer/timer.h" | 24 #include "base/timer/timer.h" |
| 25 #include "chromeos/chromeos_switches.h" | 25 #include "chromeos/chromeos_switches.h" |
| 26 #include "chromeos/dbus/fake_power_manager_client.h" | 26 #include "chromeos/dbus/fake_power_manager_client.h" |
| 27 #include "chromeos/dbus/power_manager/input_event.pb.h" | 27 #include "chromeos/dbus/power_manager/input_event.pb.h" |
| 28 #include "chromeos/dbus/power_manager/peripheral_battery_status.pb.h" | 28 #include "chromeos/dbus/power_manager/peripheral_battery_status.pb.h" |
| 29 #include "chromeos/dbus/power_manager/policy.pb.h" | 29 #include "chromeos/dbus/power_manager/policy.pb.h" |
| 30 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 30 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
| 31 #include "chromeos/dbus/power_manager/suspend.pb.h" | 31 #include "chromeos/dbus/power_manager/suspend.pb.h" |
| 32 #include "chromeos/system/statistics_provider.h" | |
| 32 #include "components/device_event_log/device_event_log.h" | 33 #include "components/device_event_log/device_event_log.h" |
| 33 #include "dbus/bus.h" | 34 #include "dbus/bus.h" |
| 34 #include "dbus/message.h" | 35 #include "dbus/message.h" |
| 35 #include "dbus/object_path.h" | 36 #include "dbus/object_path.h" |
| 36 #include "dbus/object_proxy.h" | 37 #include "dbus/object_proxy.h" |
| 37 | 38 |
| 38 namespace chromeos { | 39 namespace chromeos { |
| 39 | 40 |
| 40 // Maximum amount of time that the power manager will wait for Chrome to | 41 // Maximum amount of time that the power manager will wait for Chrome to |
| 41 // say that it's ready for the system to be suspended, in milliseconds. | 42 // say that it's ready for the system to be suspended, in milliseconds. |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 POWER_LOG(ERROR) << "Unable to decode " | 452 POWER_LOG(ERROR) << "Unable to decode " |
| 452 << power_manager::kGetPowerSupplyPropertiesMethod | 453 << power_manager::kGetPowerSupplyPropertiesMethod |
| 453 << " response"; | 454 << " response"; |
| 454 } | 455 } |
| 455 } | 456 } |
| 456 | 457 |
| 457 void OnGetScreenBrightnessPercent( | 458 void OnGetScreenBrightnessPercent( |
| 458 const GetScreenBrightnessPercentCallback& callback, | 459 const GetScreenBrightnessPercentCallback& callback, |
| 459 dbus::Response* response) { | 460 dbus::Response* response) { |
| 460 if (!response) { | 461 if (!response) { |
| 461 POWER_LOG(ERROR) << "Error calling " | 462 chromeos::system::StatisticsProvider* stats = |
| 462 << power_manager::kGetScreenBrightnessPercentMethod; | 463 chromeos::system::StatisticsProvider::GetInstance(); |
| 464 std::string hwid; | |
| 465 if (stats->GetMachineStatistic(chromeos::system::kHardwareClassKey, | |
| 466 &hwid) && | |
| 467 hwid != chromeos::system::kHardwareClassValueVM) { | |
|
achuithb
2016/08/05 21:28:06
Why not just have a method like IsRunningOnVM() in
| |
| 468 POWER_LOG(ERROR) << "Error calling " | |
| 469 << power_manager::kGetScreenBrightnessPercentMethod; | |
| 470 } | |
| 463 return; | 471 return; |
| 464 } | 472 } |
| 465 dbus::MessageReader reader(response); | 473 dbus::MessageReader reader(response); |
| 466 double percent = 0.0; | 474 double percent = 0.0; |
| 467 if (!reader.PopDouble(&percent)) | 475 if (!reader.PopDouble(&percent)) |
| 468 POWER_LOG(ERROR) << "Error reading response from powerd: " | 476 POWER_LOG(ERROR) << "Error reading response from powerd: " |
| 469 << response->ToString(); | 477 << response->ToString(); |
| 470 callback.Run(percent); | 478 callback.Run(percent); |
| 471 } | 479 } |
| 472 | 480 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 // static | 808 // static |
| 801 PowerManagerClient* PowerManagerClient::Create( | 809 PowerManagerClient* PowerManagerClient::Create( |
| 802 DBusClientImplementationType type) { | 810 DBusClientImplementationType type) { |
| 803 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 811 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 804 return new PowerManagerClientImpl(); | 812 return new PowerManagerClientImpl(); |
| 805 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 813 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 806 return new FakePowerManagerClient(); | 814 return new FakePowerManagerClient(); |
| 807 } | 815 } |
| 808 | 816 |
| 809 } // namespace chromeos | 817 } // namespace chromeos |
| OLD | NEW |