OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 BASE_POWER_MONITOR_POWER_OBSERVER_H_ | 5 #ifndef BASE_POWER_MONITOR_POWER_OBSERVER_H_ |
6 #define BASE_POWER_MONITOR_POWER_OBSERVER_H_ | 6 #define BASE_POWER_MONITOR_POWER_OBSERVER_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/thread_checker.h" |
10 | 12 |
11 namespace base { | 13 namespace base { |
12 | 14 |
13 class BASE_EXPORT PowerObserver { | 15 class BASE_EXPORT PowerObserver { |
| 16 friend class PowerMonitor; |
| 17 |
14 public: | 18 public: |
| 19 PowerObserver(); |
| 20 |
15 // Notification of a change in power status of the computer, such | 21 // Notification of a change in power status of the computer, such |
16 // as from switching between battery and A/C power. | 22 // as from switching between battery and A/C power. |
17 virtual void OnPowerStateChange(bool on_battery_power) {}; | 23 virtual void OnPowerStateChange(bool on_battery_power) {} |
18 | 24 |
19 // Notification that the system is suspending. | 25 // Notification that the system is suspending. |
20 virtual void OnSuspend() {} | 26 virtual void OnSuspend() {} |
21 | 27 |
22 // Notification that the system is resuming. | 28 // Notification that the system is resuming. |
23 virtual void OnResume() {} | 29 virtual void OnResume() {} |
24 | 30 |
25 protected: | 31 protected: |
26 virtual ~PowerObserver() {} | 32 virtual ~PowerObserver(); |
| 33 |
| 34 private: |
| 35 // Allows PowerMonitor to ensure this observer is added and removed |
| 36 // from the same thread, which is required by the ObserverListThreadSafe. |
| 37 scoped_ptr<base::ThreadChecker> power_monitor_thread_checker_; |
27 }; | 38 }; |
28 | 39 |
29 } // namespace base | 40 } // namespace base |
30 | 41 |
31 #endif // BASE_POWER_MONITOR_POWER_OBSERVER_H_ | 42 #endif // BASE_POWER_MONITOR_POWER_OBSERVER_H_ |
OLD | NEW |