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 #ifndef CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
6 #define CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 6 #define CHROMEOS_DBUS_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/callback.h" | 11 #include "base/callback.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
14 #include "chromeos/dbus/dbus_client_implementation_type.h" | 14 #include "chromeos/dbus/dbus_client_implementation_type.h" |
15 | 15 |
16 #include "chromeos/dbus/power_supply_status.h" | 16 #include "chromeos/dbus/power_supply_status.h" |
17 | 17 |
18 namespace dbus { | 18 namespace dbus { |
19 class Bus; | 19 class Bus; |
20 } | 20 } |
21 | 21 |
22 namespace power_manager { | 22 namespace power_manager { |
23 class PowerManagementPolicy; | 23 class PowerManagementPolicy; |
24 } | 24 } |
25 | 25 |
26 namespace chromeos { | 26 namespace chromeos { |
27 | 27 |
28 typedef base::Callback<void(void)> IdleNotificationCallback; | 28 typedef base::Callback<void(void)> IdleNotificationCallback; |
29 typedef base::Callback<void(uint32)> PowerStateRequestIdCallback; | |
30 | 29 |
31 // Callback used for getting the current screen brightness. The param is in the | 30 // Callback used for getting the current screen brightness. The param is in the |
32 // range [0.0, 100.0]. | 31 // range [0.0, 100.0]. |
33 typedef base::Callback<void(double)> GetScreenBrightnessPercentCallback; | 32 typedef base::Callback<void(double)> GetScreenBrightnessPercentCallback; |
34 | 33 |
35 // PowerManagerClient is used to communicate with the power manager. | 34 // PowerManagerClient is used to communicate with the power manager. |
36 class CHROMEOS_EXPORT PowerManagerClient { | 35 class CHROMEOS_EXPORT PowerManagerClient { |
37 public: | 36 public: |
38 // Interface for observing changes from the power manager. | 37 // Interface for observing changes from the power manager. |
39 class Observer { | 38 class Observer { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // before the idle action has been performed. | 98 // before the idle action has been performed. |
100 virtual void IdleActionDeferred() {} | 99 virtual void IdleActionDeferred() {} |
101 }; | 100 }; |
102 | 101 |
103 enum UpdateRequestType { | 102 enum UpdateRequestType { |
104 UPDATE_INITIAL, // Initial update request. | 103 UPDATE_INITIAL, // Initial update request. |
105 UPDATE_USER, // User initialted update request. | 104 UPDATE_USER, // User initialted update request. |
106 UPDATE_POLL // Update requested by poll signal. | 105 UPDATE_POLL // Update requested by poll signal. |
107 }; | 106 }; |
108 | 107 |
109 enum PowerStateOverrideType { | |
110 DISABLE_IDLE_DIM = 1 << 0, // Disable screen dimming on idle. | |
111 DISABLE_IDLE_BLANK = 1 << 1, // Disable screen blanking on idle. | |
112 DISABLE_IDLE_SUSPEND = 1 << 2, // Disable suspend on idle. | |
113 DISABLE_LID_SUSPEND = 1 << 3, // Disable suspend on lid closed. | |
114 }; | |
115 | |
116 // Adds and removes the observer. | 108 // Adds and removes the observer. |
117 virtual void AddObserver(Observer* observer) = 0; | 109 virtual void AddObserver(Observer* observer) = 0; |
118 virtual void RemoveObserver(Observer* observer) = 0; | 110 virtual void RemoveObserver(Observer* observer) = 0; |
119 virtual bool HasObserver(Observer* observer) = 0; | 111 virtual bool HasObserver(Observer* observer) = 0; |
120 | 112 |
121 // Decreases the screen brightness. |allow_off| controls whether or not | 113 // Decreases the screen brightness. |allow_off| controls whether or not |
122 // it's allowed to turn off the back light. | 114 // it's allowed to turn off the back light. |
123 virtual void DecreaseScreenBrightness(bool allow_off) = 0; | 115 virtual void DecreaseScreenBrightness(bool allow_off) = 0; |
124 | 116 |
125 // Increases the screen brightness. | 117 // Increases the screen brightness. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Notifies the power manager that a video is currently playing. It also | 158 // Notifies the power manager that a video is currently playing. It also |
167 // includes whether or not the containing window for the video is fullscreen. | 159 // includes whether or not the containing window for the video is fullscreen. |
168 virtual void NotifyVideoActivity( | 160 virtual void NotifyVideoActivity( |
169 const base::TimeTicks& last_activity_time, | 161 const base::TimeTicks& last_activity_time, |
170 bool is_fullscreen) = 0; | 162 bool is_fullscreen) = 0; |
171 | 163 |
172 // Tells the power manager to begin using |policy|. | 164 // Tells the power manager to begin using |policy|. |
173 virtual void SetPolicy( | 165 virtual void SetPolicy( |
174 const power_manager::PowerManagementPolicy& policy) = 0; | 166 const power_manager::PowerManagementPolicy& policy) = 0; |
175 | 167 |
176 // Override the current power state on the machine. The overrides will be | |
177 // applied to the request ID specified. To specify a new request; use 0 as the | |
178 // request id and the method will call the provided callback with the new | |
179 // request ID for use with further calls. |duration| will be rounded down to | |
180 // the nearest second. The overrides parameter will & out the | |
181 // PowerStateOverrideType types to allow specific selection of overrides. For | |
182 // example, to override just dim and suspending but leaving blanking in, set | |
183 // overrides to, DISABLE_IDLE_DIM | DISABLE_IDLE_SUSPEND. | |
184 virtual void RequestPowerStateOverrides( | |
185 uint32 request_id, | |
186 base::TimeDelta duration, | |
187 int overrides, | |
188 const PowerStateRequestIdCallback& callback) = 0; | |
189 | |
190 // Cancels the power state override request specified by request_id. | |
191 virtual void CancelPowerStateOverrides(uint32 request_id) = 0; | |
192 | |
193 // Tells powerd whether or not we are in a projecting mode. This is used to | 168 // Tells powerd whether or not we are in a projecting mode. This is used to |
194 // adjust idleness thresholds and derived, on this side, from the number of | 169 // adjust idleness thresholds and derived, on this side, from the number of |
195 // video outputs attached. | 170 // video outputs attached. |
196 virtual void SetIsProjecting(bool is_projecting) = 0; | 171 virtual void SetIsProjecting(bool is_projecting) = 0; |
197 | 172 |
198 // Returns a callback that can be called by an observer to report | 173 // Returns a callback that can be called by an observer to report |
199 // readiness for suspend. See Observer::SuspendImminent(). | 174 // readiness for suspend. See Observer::SuspendImminent(). |
200 virtual base::Closure GetSuspendReadinessCallback() = 0; | 175 virtual base::Closure GetSuspendReadinessCallback() = 0; |
201 | 176 |
202 // Creates the instance. | 177 // Creates the instance. |
203 static PowerManagerClient* Create(DBusClientImplementationType type, | 178 static PowerManagerClient* Create(DBusClientImplementationType type, |
204 dbus::Bus* bus); | 179 dbus::Bus* bus); |
205 | 180 |
206 virtual ~PowerManagerClient(); | 181 virtual ~PowerManagerClient(); |
207 | 182 |
208 protected: | 183 protected: |
209 // Create() should be used instead. | 184 // Create() should be used instead. |
210 PowerManagerClient(); | 185 PowerManagerClient(); |
211 | 186 |
212 private: | 187 private: |
213 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); | 188 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); |
214 }; | 189 }; |
215 | 190 |
216 } // namespace chromeos | 191 } // namespace chromeos |
217 | 192 |
218 #endif // CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 193 #endif // CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
OLD | NEW |