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" | 10 #include "base/basictypes.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "chromeos/chromeos_export.h" | |
13 #include "chromeos/dbus/power_manager/policy.pb.h" | 14 #include "chromeos/dbus/power_manager/policy.pb.h" |
15 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | |
14 #include "chromeos/dbus/power_manager/suspend.pb.h" | 16 #include "chromeos/dbus/power_manager/suspend.pb.h" |
15 #include "chromeos/dbus/power_manager_client.h" | 17 #include "chromeos/dbus/power_manager_client.h" |
16 | 18 |
17 namespace chromeos { | 19 namespace chromeos { |
18 | 20 |
19 // A fake implementation of PowerManagerClient. This remembers the policy passed | 21 // 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 | 22 // to SetPolicy() and the user of this class can inspect the last set policy by |
21 // get_policy(). | 23 // get_policy(). |
22 class FakePowerManagerClient : public PowerManagerClient { | 24 class CHROMEOS_EXPORT FakePowerManagerClient : public PowerManagerClient { |
23 public: | 25 public: |
24 FakePowerManagerClient(); | 26 FakePowerManagerClient(); |
25 ~FakePowerManagerClient() override; | 27 ~FakePowerManagerClient() override; |
26 | 28 |
27 power_manager::PowerManagementPolicy& policy() { return policy_; } | 29 power_manager::PowerManagementPolicy& policy() { return policy_; } |
30 const power_manager::PowerSupplyProperties& props() const { return props_; } | |
28 int num_request_restart_calls() const { return num_request_restart_calls_; } | 31 int num_request_restart_calls() const { return num_request_restart_calls_; } |
29 int num_request_shutdown_calls() const { return num_request_shutdown_calls_; } | 32 int num_request_shutdown_calls() const { return num_request_shutdown_calls_; } |
30 int num_set_policy_calls() const { return num_set_policy_calls_; } | 33 int num_set_policy_calls() const { return num_set_policy_calls_; } |
31 int num_set_is_projecting_calls() const { | 34 int num_set_is_projecting_calls() const { |
32 return num_set_is_projecting_calls_; | 35 return num_set_is_projecting_calls_; |
33 } | 36 } |
34 bool is_projecting() const { return is_projecting_; } | 37 bool is_projecting() const { return is_projecting_; } |
35 | 38 |
36 // PowerManagerClient overrides | 39 // PowerManagerClient overrides |
37 void Init(dbus::Bus* bus) override; | 40 void Init(dbus::Bus* bus) override; |
(...skipping 22 matching lines...) Expand all Loading... | |
60 | 63 |
61 // Emulates the power manager announcing that the system is starting or | 64 // Emulates the power manager announcing that the system is starting or |
62 // completing a suspend attempt. | 65 // completing a suspend attempt. |
63 void SendSuspendImminent(); | 66 void SendSuspendImminent(); |
64 void SendSuspendDone(); | 67 void SendSuspendDone(); |
65 void SendDarkSuspendImminent(); | 68 void SendDarkSuspendImminent(); |
66 | 69 |
67 // Notifies observers that the power button has been pressed or released. | 70 // Notifies observers that the power button has been pressed or released. |
68 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp); | 71 void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp); |
69 | 72 |
73 // Updates the PowerSupplyProperties and notifies observers of its changes. | |
74 void UpdatePowerProperties(const power_manager::PowerSupplyProperties& proto); | |
oshima
2015/07/10 22:39:41
nit: proto refers to Protocol Buffer, which is a w
mozartalouis
2015/07/14 20:01:29
Done.
| |
75 | |
70 private: | 76 private: |
71 // Callback that will be run by asynchronous suspend delays to report | 77 // Callback that will be run by asynchronous suspend delays to report |
72 // readiness. | 78 // readiness. |
73 void HandleSuspendReadiness(); | 79 void HandleSuspendReadiness(); |
74 | 80 |
81 // Notifies |observers_| that |props_| has been updated. | |
82 void NotifyObservers(); | |
83 | |
75 base::ObserverList<Observer> observers_; | 84 base::ObserverList<Observer> observers_; |
76 | 85 |
77 // Last policy passed to SetPolicy(). | 86 // Last policy passed to SetPolicy(). |
78 power_manager::PowerManagementPolicy policy_; | 87 power_manager::PowerManagementPolicy policy_; |
79 | 88 |
89 // Power status received from the power manager. | |
90 power_manager::PowerSupplyProperties props_; | |
91 | |
80 // Number of times that various methods have been called. | 92 // Number of times that various methods have been called. |
81 int num_request_restart_calls_; | 93 int num_request_restart_calls_; |
82 int num_request_shutdown_calls_; | 94 int num_request_shutdown_calls_; |
83 int num_set_policy_calls_; | 95 int num_set_policy_calls_; |
84 int num_set_is_projecting_calls_; | 96 int num_set_is_projecting_calls_; |
85 | 97 |
86 // Number of pending suspend readiness callbacks. | 98 // Number of pending suspend readiness callbacks. |
87 int num_pending_suspend_readiness_callbacks_; | 99 int num_pending_suspend_readiness_callbacks_; |
88 | 100 |
89 // Last projecting state set in SetIsProjecting(). | 101 // Last projecting state set in SetIsProjecting(). |
90 bool is_projecting_; | 102 bool is_projecting_; |
91 | 103 |
92 // Delegate for managing power consumption of Chrome's renderer processes. | 104 // Delegate for managing power consumption of Chrome's renderer processes. |
93 base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_; | 105 base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_; |
94 | 106 |
95 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); | 107 DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient); |
96 }; | 108 }; |
97 | 109 |
98 } // namespace chromeos | 110 } // namespace chromeos |
99 | 111 |
100 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ | 112 #endif // CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_ |
OLD | NEW |