Chromium Code Reviews| 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/basictypes.h" | |
| 9 #include "base/callback.h" | |
| 8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 9 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 10 | 12 |
| 11 #include <string> | 13 #include <string> |
| 12 | 14 |
| 13 namespace dbus { | 15 namespace dbus { |
| 14 class Bus; | 16 class Bus; |
| 15 class ObjectProxy; | 17 class ObjectProxy; |
| 16 class Response; | 18 class Response; |
| 17 class Signal; | 19 class Signal; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 29 // Time in seconds until the battery is empty or full, 0 for unknown. | 31 // Time in seconds until the battery is empty or full, 0 for unknown. |
| 30 int64 battery_seconds_to_empty; | 32 int64 battery_seconds_to_empty; |
| 31 int64 battery_seconds_to_full; | 33 int64 battery_seconds_to_full; |
| 32 | 34 |
| 33 double battery_percentage; | 35 double battery_percentage; |
| 34 | 36 |
| 35 PowerSupplyStatus(); | 37 PowerSupplyStatus(); |
| 36 const std::string& ToString() const; | 38 const std::string& ToString() const; |
| 37 }; | 39 }; |
| 38 | 40 |
| 41 // Callback used for processing the idle time. The int64 param is the number of | |
| 42 // milliseconds the user has been idle. | |
| 43 typedef base::Callback<void(int64)> CalculateIdleTimeCallback; | |
| 44 | |
| 39 // PowerManagerClient is used to communicate with the power manager. | 45 // PowerManagerClient is used to communicate with the power manager. |
| 40 class PowerManagerClient { | 46 class PowerManagerClient { |
| 41 public: | 47 public: |
| 42 // Interface for observing changes from the power manager. | 48 // Interface for observing changes from the power manager. |
| 43 class Observer { | 49 class Observer { |
| 44 public: | 50 public: |
| 45 // Called when the brightness is changed. | 51 // Called when the brightness is changed. |
| 46 // |level| is of the range [0, 100]. | 52 // |level| is of the range [0, 100]. |
| 47 // |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. |
| 48 virtual void BrightnessChanged(int level, bool user_initiated) {} | 54 virtual void BrightnessChanged(int level, bool user_initiated) {} |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 65 | 71 |
| 66 // UI initiated request for power supply status update. | 72 // UI initiated request for power supply status update. |
| 67 virtual void RequestStatusUpdate() = 0; | 73 virtual void RequestStatusUpdate() = 0; |
| 68 | 74 |
| 69 // Requests restart of the system. | 75 // Requests restart of the system. |
| 70 virtual void RequestRestart() = 0; | 76 virtual void RequestRestart() = 0; |
| 71 | 77 |
| 72 // Requests shutdown of the system. | 78 // Requests shutdown of the system. |
| 73 virtual void RequestShutdown() = 0; | 79 virtual void RequestShutdown() = 0; |
| 74 | 80 |
| 81 // Calculates idle time asynchronously, after the idle time request has | |
| 82 // replied. It passes the idle time in seconds to |callback|. If it | |
|
satorux1
2011/11/15 02:07:12
seconds -> milliseconds? The comment above says it
Simon Que
2011/11/15 02:47:44
Done. Actually the other way around.
| |
| 83 // encounters some error, it passes -1 to |callback|. | |
| 84 virtual void CalculateIdleTime(const CalculateIdleTimeCallback& callback) = 0; | |
| 85 | |
| 75 // Creates the instance. | 86 // Creates the instance. |
| 76 static PowerManagerClient* Create(dbus::Bus* bus); | 87 static PowerManagerClient* Create(dbus::Bus* bus); |
| 77 | 88 |
| 78 virtual ~PowerManagerClient(); | 89 virtual ~PowerManagerClient(); |
| 79 | 90 |
| 80 protected: | 91 protected: |
| 81 // Create() should be used instead. | 92 // Create() should be used instead. |
| 82 PowerManagerClient(); | 93 PowerManagerClient(); |
| 83 | 94 |
| 84 private: | 95 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); | 96 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); |
| 86 }; | 97 }; |
| 87 | 98 |
| 88 } // namespace chromeos | 99 } // namespace chromeos |
| 89 | 100 |
| 90 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 101 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
| OLD | NEW |