| 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 if (!system::StatisticsProvider::GetInstance()->IsRunningOnVm()) { |
| 462 << power_manager::kGetScreenBrightnessPercentMethod; | 463 POWER_LOG(ERROR) << "Error calling " |
| 464 << power_manager::kGetScreenBrightnessPercentMethod; |
| 465 } |
| 463 return; | 466 return; |
| 464 } | 467 } |
| 465 dbus::MessageReader reader(response); | 468 dbus::MessageReader reader(response); |
| 466 double percent = 0.0; | 469 double percent = 0.0; |
| 467 if (!reader.PopDouble(&percent)) | 470 if (!reader.PopDouble(&percent)) |
| 468 POWER_LOG(ERROR) << "Error reading response from powerd: " | 471 POWER_LOG(ERROR) << "Error reading response from powerd: " |
| 469 << response->ToString(); | 472 << response->ToString(); |
| 470 callback.Run(percent); | 473 callback.Run(percent); |
| 471 } | 474 } |
| 472 | 475 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 // static | 803 // static |
| 801 PowerManagerClient* PowerManagerClient::Create( | 804 PowerManagerClient* PowerManagerClient::Create( |
| 802 DBusClientImplementationType type) { | 805 DBusClientImplementationType type) { |
| 803 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 806 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 804 return new PowerManagerClientImpl(); | 807 return new PowerManagerClientImpl(); |
| 805 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 808 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 806 return new FakePowerManagerClient(); | 809 return new FakePowerManagerClient(); |
| 807 } | 810 } |
| 808 | 811 |
| 809 } // namespace chromeos | 812 } // namespace chromeos |
| OLD | NEW |