OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 namespace dbus { | 13 namespace dbus { |
14 class Bus; | 14 class Bus; |
15 class ObjectProxy; | 15 class ObjectProxy; |
16 class Response; | 16 class Response; |
17 class Signal; | 17 class Signal; |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
22 // This is the local struct that is used in Chrome. | |
23 struct PowerSupplyStatus { | |
24 bool line_power_on; | |
25 | |
26 bool battery_is_present; | |
27 bool battery_is_full; | |
28 | |
29 // Time in seconds until the battery is empty or full, 0 for unknown. | |
30 int64 battery_seconds_to_empty; | |
31 int64 battery_seconds_to_full; | |
32 | |
33 double battery_percentage; | |
34 | |
35 PowerSupplyStatus() : line_power_on(false), | |
36 battery_is_present(false), | |
37 battery_is_full(false), | |
38 battery_seconds_to_empty(0), | |
39 battery_seconds_to_full(0), | |
40 battery_percentage(0) {} | |
satorux1
2011/11/03 23:38:47
linux_chromeos_clang build tends to complain about
Simon Que
2011/11/04 22:35:31
Done.
| |
41 | |
42 const std::string& ToString() const; | |
43 }; | |
44 | |
22 // PowerManagerClient is used to communicate with the power manager. | 45 // PowerManagerClient is used to communicate with the power manager. |
23 class PowerManagerClient { | 46 class PowerManagerClient { |
24 public: | 47 public: |
25 // Interface for observing changes from the power manager. | 48 // Interface for observing changes from the power manager. |
26 class Observer { | 49 class Observer { |
27 public: | 50 public: |
28 // Called when the brightness is changed. | 51 // Called when the brightness is changed. |
29 // |level| is of the range [0, 100]. | 52 // |level| is of the range [0, 100]. |
30 // |user_initiated| is true if the action is initiated by the user. | 53 // |user_initiated| is true if the action is initiated by the user. |
31 virtual void BrightnessChanged(int level, bool user_initiated) = 0; | 54 virtual void BrightnessChanged(int level, bool user_initiated) {} |
55 | |
56 // Called when power supply polling takes place. |status| is a data | |
57 // structure that contains the current state of the power supply. | |
58 virtual void PowerChanged(const PowerSupplyStatus& status) {} | |
32 }; | 59 }; |
33 | 60 |
34 // Adds and removes the observer. | 61 // Adds and removes the observer. |
35 virtual void AddObserver(Observer* observer) = 0; | 62 virtual void AddObserver(Observer* observer) = 0; |
36 virtual void RemoveObserver(Observer* observer) = 0; | 63 virtual void RemoveObserver(Observer* observer) = 0; |
37 | 64 |
38 // Decreases the screen brightness. |allow_off| controls whether or not | 65 // Decreases the screen brightness. |allow_off| controls whether or not |
39 // it's allowed to turn off the back light. | 66 // it's allowed to turn off the back light. |
40 virtual void DecreaseScreenBrightness(bool allow_off) = 0; | 67 virtual void DecreaseScreenBrightness(bool allow_off) = 0; |
41 | 68 |
42 // Increases the screen brightness. | 69 // Increases the screen brightness. |
43 virtual void IncreaseScreenBrightness() = 0; | 70 virtual void IncreaseScreenBrightness() = 0; |
44 | 71 |
72 // UI initiated request for status update. | |
73 virtual void RequestStatusUpdate() = 0; | |
satorux1
2011/11/04 22:24:57
Please add this to mock_power_manager_client.h too
Simon Que
2011/11/04 22:35:31
Done.
| |
74 | |
45 // Creates the instance. | 75 // Creates the instance. |
46 static PowerManagerClient* Create(dbus::Bus* bus); | 76 static PowerManagerClient* Create(dbus::Bus* bus); |
47 | 77 |
48 virtual ~PowerManagerClient(); | 78 virtual ~PowerManagerClient(); |
49 | 79 |
50 protected: | 80 protected: |
51 // Create() should be used instead. | 81 // Create() should be used instead. |
52 PowerManagerClient(); | 82 PowerManagerClient(); |
53 | 83 |
54 private: | 84 private: |
55 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); | 85 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); |
56 }; | 86 }; |
57 | 87 |
58 } // namespace chromeos | 88 } // namespace chromeos |
59 | 89 |
60 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 90 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
OLD | NEW |