Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: chrome/browser/chromeos/dbus/power_manager_client.h

Issue 8566024: chromeos: call GetIdleTime from power manager client (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed omission of callback.h Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h"
11 12
12 namespace dbus { 13 namespace dbus {
13 class Bus; 14 class Bus;
14 } // namespace 15 } // namespace
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 // This is the local struct that is used in Chrome. 19 // This is the local struct that is used in Chrome.
19 struct PowerSupplyStatus { 20 struct PowerSupplyStatus {
20 bool line_power_on; 21 bool line_power_on;
21 22
22 bool battery_is_present; 23 bool battery_is_present;
23 bool battery_is_full; 24 bool battery_is_full;
24 25
25 // Time in seconds until the battery is empty or full, 0 for unknown. 26 // Time in seconds until the battery is empty or full, 0 for unknown.
26 int64 battery_seconds_to_empty; 27 int64 battery_seconds_to_empty;
27 int64 battery_seconds_to_full; 28 int64 battery_seconds_to_full;
28 29
29 double battery_percentage; 30 double battery_percentage;
30 31
31 PowerSupplyStatus(); 32 PowerSupplyStatus();
32 const std::string& ToString() const; 33 const std::string& ToString() const;
33 }; 34 };
34 35
36 // Callback used for processing the idle time. The int64 param is the number of
37 // seconds the user has been idle.
38 typedef base::Callback<void(int64)> CalculateIdleTimeCallback;
39
35 // PowerManagerClient is used to communicate with the power manager. 40 // PowerManagerClient is used to communicate with the power manager.
36 class PowerManagerClient { 41 class PowerManagerClient {
37 public: 42 public:
38 // Interface for observing changes from the power manager. 43 // Interface for observing changes from the power manager.
39 class Observer { 44 class Observer {
40 public: 45 public:
41 // Called when the brightness is changed. 46 // Called when the brightness is changed.
42 // |level| is of the range [0, 100]. 47 // |level| is of the range [0, 100].
43 // |user_initiated| is true if the action is initiated by the user. 48 // |user_initiated| is true if the action is initiated by the user.
44 virtual void BrightnessChanged(int level, bool user_initiated) {} 49 virtual void BrightnessChanged(int level, bool user_initiated) {}
(...skipping 16 matching lines...) Expand all
61 66
62 // UI initiated request for power supply status update. 67 // UI initiated request for power supply status update.
63 virtual void RequestStatusUpdate() = 0; 68 virtual void RequestStatusUpdate() = 0;
64 69
65 // Requests restart of the system. 70 // Requests restart of the system.
66 virtual void RequestRestart() = 0; 71 virtual void RequestRestart() = 0;
67 72
68 // Requests shutdown of the system. 73 // Requests shutdown of the system.
69 virtual void RequestShutdown() = 0; 74 virtual void RequestShutdown() = 0;
70 75
76 // Calculates idle time asynchronously, after the idle time request has
77 // replied. It passes the idle time in seconds to |callback|. If it
78 // encounters some error, it passes -1 to |callback|.
79 virtual void CalculateIdleTime(const CalculateIdleTimeCallback& callback) = 0;
80
71 // Creates the instance. 81 // Creates the instance.
72 static PowerManagerClient* Create(dbus::Bus* bus); 82 static PowerManagerClient* Create(dbus::Bus* bus);
73 83
74 virtual ~PowerManagerClient(); 84 virtual ~PowerManagerClient();
75 85
76 protected: 86 protected:
77 // Create() should be used instead. 87 // Create() should be used instead.
78 PowerManagerClient(); 88 PowerManagerClient();
79 89
80 private: 90 private:
81 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); 91 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient);
82 }; 92 };
83 93
84 } // namespace chromeos 94 } // namespace chromeos
85 95
86 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ 96 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/dbus/mock_power_manager_client.h ('k') | chrome/browser/chromeos/dbus/power_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698