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> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/macros.h" | |
12 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
13 #include "chromeos/dbus/power_manager/policy.pb.h" | 9 #include "chromeos/dbus/power_manager/policy.pb.h" |
10 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | |
14 #include "chromeos/dbus/power_manager/suspend.pb.h" | 11 #include "chromeos/dbus/power_manager/suspend.pb.h" |
15 #include "chromeos/dbus/power_manager_client.h" | 12 #include "chromeos/dbus/power_manager_client.h" |
16 | 13 |
17 namespace chromeos { | 14 namespace chromeos { |
18 | 15 |
19 // A fake implementation of PowerManagerClient. This remembers the policy passed | 16 // 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 | 17 // to SetPolicy() and the user of this class can inspect the last set policy by |
21 // get_policy(). | 18 // get_policy(). |
22 class FakePowerManagerClient : public PowerManagerClient { | 19 class FakePowerManagerClient : public PowerManagerClient { |
23 public: | 20 public: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 | 57 |
61 // Emulates the power manager announcing that the system is starting or | 58 // Emulates the power manager announcing that the system is starting or |
62 // completing a suspend attempt. | 59 // completing a suspend attempt. |
63 void SendSuspendImminent(); | 60 void SendSuspendImminent(); |
64 void SendSuspendDone(); | 61 void SendSuspendDone(); |
65 void SendDarkSuspendImminent(); | 62 void SendDarkSuspendImminent(); |
66 | 63 |
67 // Notifies observers that the power button has been pressed or released. | 64 // Notifies observers that the power button has been pressed or released. |
68 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp); | 65 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
69 | 66 |
67 // Emulates the changes in various power settings. | |
68 void UpdateBatteryPercentage(int percentage); | |
69 void UpdateBatteryFullTimeToEmpty(int time_in_hours); | |
70 void UpdateExternalPower(int external_power); | |
71 void UpdateIsBatteryCharging(bool is_charging); | |
72 void UpdateIsCalculatingBatteryTime(bool is_calculating); | |
73 | |
74 // Called once any power states are changed to notify the observer of the | |
75 // change. | |
76 void UpdatePowerStatus(); | |
77 | |
70 private: | 78 private: |
71 // Callback that will be run by asynchronous suspend delays to report | 79 // Callback that will be run by asynchronous suspend delays to report |
72 // readiness. | 80 // readiness. |
73 void HandleSuspendReadiness(); | 81 void HandleSuspendReadiness(); |
74 | 82 |
83 void ParseCommandLineSwitch(); | |
84 | |
85 void ParseOption(const std::string& arg0, const std::string& arg1); | |
86 | |
75 base::ObserverList<Observer> observers_; | 87 base::ObserverList<Observer> observers_; |
76 | 88 |
77 // Last policy passed to SetPolicy(). | 89 // Last policy passed to SetPolicy(). |
78 power_manager::PowerManagementPolicy policy_; | 90 power_manager::PowerManagementPolicy policy_; |
79 | 91 |
92 // The power properties set for for the UI. | |
93 power_manager::PowerSupplyProperties props_; | |
94 | |
95 // Variables that handle states of the battery and power. | |
96 bool is_charging_; | |
97 bool is_calculating_; | |
98 int battery_percentage_; | |
99 int power_source_; | |
100 int hours_to_empty_full_battery_; // 4 hours. default value. | |
stevenjb
2015/06/26 20:42:19
nit: Comment should be in the .cc file.
mozartalouis
2015/06/26 21:13:03
Done.
| |
101 | |
80 // Number of times that various methods have been called. | 102 // Number of times that various methods have been called. |
81 int num_request_restart_calls_; | 103 int num_request_restart_calls_; |
82 int num_request_shutdown_calls_; | 104 int num_request_shutdown_calls_; |
83 int num_set_policy_calls_; | 105 int num_set_policy_calls_; |
84 int num_set_is_projecting_calls_; | 106 int num_set_is_projecting_calls_; |
85 | 107 |
86 // Number of pending suspend readiness callbacks. | 108 // Number of pending suspend readiness callbacks. |
87 int num_pending_suspend_readiness_callbacks_; | 109 int num_pending_suspend_readiness_callbacks_; |
88 | 110 |
89 // Last projecting state set in SetIsProjecting(). | 111 // Last projecting state set in SetIsProjecting(). |
90 bool is_projecting_; | 112 bool is_projecting_; |
91 | 113 |
92 // Delegate for managing power consumption of Chrome's renderer processes. | 114 // Delegate for managing power consumption of Chrome's renderer processes. |
93 base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_; | 115 base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_; |
94 | 116 |
117 // Note: This should remain the last member so it'll be destroyed and | |
118 // invalidate its weak pointers before any other members are destroyed. | |
119 base::WeakPtrFactory<FakePowerManagerClient> weak_ptr_factory_; | |
120 | |
95 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); | 121 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); |
96 }; | 122 }; |
97 | 123 |
98 } // namespace chromeos | 124 } // namespace chromeos |
99 | 125 |
100 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 126 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
OLD | NEW |