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_POWER_POWER_STATE_OVERRIDE_H_ | 5 #ifndef CHROMEOS_POWER_POWER_STATE_OVERRIDE_H_ |
6 #define CHROMEOS_POWER_POWER_STATE_OVERRIDE_H_ | 6 #define CHROMEOS_POWER_POWER_STATE_OVERRIDE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
12 #include "chromeos/dbus/dbus_thread_manager_observer.h" | 12 #include "chromeos/dbus/dbus_thread_manager_observer.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
16 class DBusThreadManager; | 16 class DBusThreadManager; |
17 | 17 |
18 // This class overrides the current power state on the machine, disabling | 18 // This class overrides the current power state on the machine, disabling |
19 // a set of power management features. | 19 // a set of power management features. |
20 class CHROMEOS_EXPORT PowerStateOverride | 20 class CHROMEOS_EXPORT PowerStateOverride |
21 : public base::RefCountedThreadSafe<PowerStateOverride>, | 21 : public base::RefCountedThreadSafe<PowerStateOverride>, |
22 public DBusThreadManagerObserver { | 22 public DBusThreadManagerObserver { |
23 public: | 23 public: |
24 enum Mode { | 24 enum Mode { |
25 // Blocks the screen from being dimmed or blanked due to user inactivity. | 25 // Blocks the screen from being dimmed or blanked due to user inactivity. |
26 // Also implies BLOCK_SYSTEM_SUSPEND. | 26 // Also implies BLOCK_SYSTEM_SUSPEND. |
27 BLOCK_DISPLAY_SLEEP, | 27 BLOCK_DISPLAY_SLEEP, |
28 | 28 |
29 // Blocks the system from being suspended due to user inactivity or (in the | 29 // Blocks the system from being suspended due to user inactivity. |
30 // case of a laptop) the lid being closed. | |
31 BLOCK_SYSTEM_SUSPEND, | 30 BLOCK_SYSTEM_SUSPEND, |
32 }; | 31 }; |
33 | 32 |
34 explicit PowerStateOverride(Mode mode); | 33 explicit PowerStateOverride(Mode mode); |
35 | 34 |
36 // DBusThreadManagerObserver implementation: | 35 // DBusThreadManagerObserver implementation: |
37 virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager) | 36 virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager) |
38 OVERRIDE; | 37 OVERRIDE; |
39 | 38 |
40 private: | 39 private: |
(...skipping 30 matching lines...) Expand all Loading... |
71 base::RepeatingTimer<PowerStateOverride> heartbeat_; | 70 base::RepeatingTimer<PowerStateOverride> heartbeat_; |
72 | 71 |
73 DBusThreadManager* dbus_thread_manager_; // not owned | 72 DBusThreadManager* dbus_thread_manager_; // not owned |
74 | 73 |
75 DISALLOW_COPY_AND_ASSIGN(PowerStateOverride); | 74 DISALLOW_COPY_AND_ASSIGN(PowerStateOverride); |
76 }; | 75 }; |
77 | 76 |
78 } // namespace chromeos | 77 } // namespace chromeos |
79 | 78 |
80 #endif // CHROMEOS_POWER_POWER_STATE_OVERRIDE_H_ | 79 #endif // CHROMEOS_POWER_POWER_STATE_OVERRIDE_H_ |
OLD | NEW |