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

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

Issue 9838085: Move files inside chrome/browser/chromeos/dbus to chromeos/dbus (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: _ Created 8 years, 9 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12
13 #include "chromeos/dbus/power_supply_status.h"
14
15 namespace base {
16 class TimeTicks;
17 }
18 namespace dbus {
19 class Bus;
20 }
21
22 namespace chromeos {
23
24 // Callback used for processing the idle time. The int64 param is the number of
25 // seconds the user has been idle.
26 typedef base::Callback<void(int64)> CalculateIdleTimeCallback;
27 typedef base::Callback<void(void)> IdleNotificationCallback;
28
29 // PowerManagerClient is used to communicate with the power manager.
30 class PowerManagerClient {
31 public:
32 // Interface for observing changes from the power manager.
33 class Observer {
34 public:
35 virtual ~Observer() {}
36
37 // Called when the brightness is changed.
38 // |level| is of the range [0, 100].
39 // |user_initiated| is true if the action is initiated by the user.
40 virtual void BrightnessChanged(int level, bool user_initiated) {}
41
42 // Called when power supply polling takes place. |status| is a data
43 // structure that contains the current state of the power supply.
44 virtual void PowerChanged(const PowerSupplyStatus& status) {}
45
46 // Called when the system resumes from suspend.
47 virtual void SystemResumed() {}
48
49 // Called when the power button is pressed or released.
50 virtual void PowerButtonStateChanged(bool down,
51 const base::TimeTicks& timestamp) {}
52
53 // Called when the lock button is pressed or released.
54 virtual void LockButtonStateChanged(bool down,
55 const base::TimeTicks& timestamp) {}
56
57 // Called when the screen is locked.
58 virtual void LockScreen() {}
59
60 // Called when the screen is unlocked.
61 virtual void UnlockScreen() {}
62
63 // Called when the screen fails to unlock.
64 virtual void UnlockScreenFailed() {}
65
66 // Called when we go idle for threshold time.
67 virtual void IdleNotify(int64 threshold_secs) {}
68
69 // Called when we go from idle to active.
70 virtual void ActiveNotify() {}
71 };
72
73 enum UpdateRequestType {
74 UPDATE_INITIAL, // Initial update request.
75 UPDATE_USER, // User initialted update request.
76 UPDATE_POLL // Update requested by poll signal.
77 };
78
79 // Adds and removes the observer.
80 virtual void AddObserver(Observer* observer) = 0;
81 virtual void RemoveObserver(Observer* observer) = 0;
82 virtual bool HasObserver(Observer* observer) = 0;
83
84 // Decreases the screen brightness. |allow_off| controls whether or not
85 // it's allowed to turn off the back light.
86 virtual void DecreaseScreenBrightness(bool allow_off) = 0;
87
88 // Increases the screen brightness.
89 virtual void IncreaseScreenBrightness() = 0;
90
91 // Request for power supply status update.
92 virtual void RequestStatusUpdate(UpdateRequestType update_type) = 0;
93
94 // Requests restart of the system.
95 virtual void RequestRestart() = 0;
96
97 // Requests shutdown of the system.
98 virtual void RequestShutdown() = 0;
99
100 // Notifies PowerManager that a user requested to lock the screen.
101 virtual void NotifyScreenLockRequested() = 0;
102
103 // Notifies PowerManager that screen lock has been completed.
104 virtual void NotifyScreenLockCompleted() = 0;
105
106 // Notifies PowerManager that a user unlocked the screen.
107 virtual void NotifyScreenUnlockRequested() = 0;
108
109 // Notifies PowerManager that screen is unlocked.
110 virtual void NotifyScreenUnlockCompleted() = 0;
111
112 // Idle management functions:
113
114 // Calculates idle time asynchronously, after the idle time request has
115 // replied. It passes the idle time in seconds to |callback|. If it
116 // encounters some error, it passes -1 to |callback|.
117 virtual void CalculateIdleTime(const CalculateIdleTimeCallback& callback) = 0;
118
119 // Requests notification for Idle at a certain threshold.
120 // NOTE: This notification is one shot, once the machine has been idle for
121 // threshold time, a notification will be sent and then that request will be
122 // removed from the notification queue. If you wish notifications the next
123 // time the machine goes idle for that much time, request again.
124 virtual void RequestIdleNotification(int64 threshold_secs) = 0;
125
126 // Requests that the observers be notified in case of an Idle->Active event.
127 // NOTE: Like the previous request, this will also get triggered exactly once.
128 virtual void RequestActiveNotification() = 0;
129
130 // Creates the instance.
131 static PowerManagerClient* Create(dbus::Bus* bus);
132
133 virtual ~PowerManagerClient();
134
135 protected:
136 // Create() should be used instead.
137 PowerManagerClient();
138
139 private:
140 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient);
141 };
142
143 } // namespace chromeos
144
145 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698