Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 13 #include "chromeos/dbus/power_manager/policy.pb.h" | 11 #include "chromeos/dbus/power_manager/policy.pb.h" |
| 12 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | |
| 14 #include "chromeos/dbus/power_manager/suspend.pb.h" | 13 #include "chromeos/dbus/power_manager/suspend.pb.h" |
| 15 #include "chromeos/dbus/power_manager_client.h" | 14 #include "chromeos/dbus/power_manager_client.h" |
| 16 | 15 |
| 17 namespace chromeos { | 16 namespace chromeos { |
| 18 | 17 |
| 19 // A fake implementation of PowerManagerClient. This remembers the policy passed | 18 // A fake implementation of PowerManagerClient. This remembers the policy passed |
| 20 // to SetPolicy() and the user of this class can inspect the last set policy by | 19 // to SetPolicy() and the user of this class can inspect the last set policy by |
| 21 // get_policy(). | 20 // get_policy(). |
| 22 class FakePowerManagerClient : public PowerManagerClient { | 21 class FakePowerManagerClient : public PowerManagerClient { |
| 23 public: | 22 public: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 59 |
| 61 // Emulates the power manager announcing that the system is starting or | 60 // Emulates the power manager announcing that the system is starting or |
| 62 // completing a suspend attempt. | 61 // completing a suspend attempt. |
| 63 void SendSuspendImminent(); | 62 void SendSuspendImminent(); |
| 64 void SendSuspendDone(); | 63 void SendSuspendDone(); |
| 65 void SendDarkSuspendImminent(); | 64 void SendDarkSuspendImminent(); |
| 66 | 65 |
| 67 // Notifies observers that the power button has been pressed or released. | 66 // Notifies observers that the power button has been pressed or released. |
| 68 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp); | 67 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
| 69 | 68 |
| 69 void UpdatePowerProperties( | |
| 70 int battery_percent, | |
| 71 bool is_calculating_battery_time, | |
| 72 power_manager::PowerSupplyProperties::BatteryState battery_state, | |
| 73 power_manager::PowerSupplyProperties::ExternalPower external_power); | |
| 74 | |
| 75 power_manager::PowerSupplyProperties GetPowerSupplyProperties() { | |
|
Daniel Erat
2015/06/30 22:13:31
this is inlined, so you should just name it props(
mozartalouis
2015/07/01 00:43:28
Done.
| |
| 76 return props_; | |
| 77 } | |
| 78 | |
| 70 private: | 79 private: |
| 71 // Callback that will be run by asynchronous suspend delays to report | 80 // Callback that will be run by asynchronous suspend delays to report |
| 72 // readiness. | 81 // readiness. |
| 73 void HandleSuspendReadiness(); | 82 void HandleSuspendReadiness(); |
| 74 | 83 |
| 84 // Called once any power states are changed to notify the observer of the | |
| 85 // change. | |
| 86 void NotifyObservers(); | |
| 87 | |
| 75 base::ObserverList<Observer> observers_; | 88 base::ObserverList<Observer> observers_; |
| 76 | 89 |
| 77 // Last policy passed to SetPolicy(). | 90 // Last policy passed to SetPolicy(). |
| 78 power_manager::PowerManagementPolicy policy_; | 91 power_manager::PowerManagementPolicy policy_; |
| 79 | 92 |
| 93 // The power properties set for for the UI. | |
| 94 power_manager::PowerSupplyProperties props_; | |
| 95 | |
| 80 // Number of times that various methods have been called. | 96 // Number of times that various methods have been called. |
| 81 int num_request_restart_calls_; | 97 int num_request_restart_calls_; |
| 82 int num_request_shutdown_calls_; | 98 int num_request_shutdown_calls_; |
| 83 int num_set_policy_calls_; | 99 int num_set_policy_calls_; |
| 84 int num_set_is_projecting_calls_; | 100 int num_set_is_projecting_calls_; |
| 85 | 101 |
| 86 // Number of pending suspend readiness callbacks. | 102 // Number of pending suspend readiness callbacks. |
| 87 int num_pending_suspend_readiness_callbacks_; | 103 int num_pending_suspend_readiness_callbacks_; |
| 88 | 104 |
| 89 // Last projecting state set in SetIsProjecting(). | 105 // Last projecting state set in SetIsProjecting(). |
| 90 bool is_projecting_; | 106 bool is_projecting_; |
| 91 | 107 |
| 92 // Delegate for managing power consumption of Chrome's renderer processes. | 108 // Delegate for managing power consumption of Chrome's renderer processes. |
| 93 base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_; | 109 base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_; |
| 94 | 110 |
| 95 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); | 111 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); |
| 96 }; | 112 }; |
| 97 | 113 |
| 98 } // namespace chromeos | 114 } // namespace chromeos |
| 99 | 115 |
| 100 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 116 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
| OLD | NEW |