| 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" | |
| 12 | 10 |
| 13 namespace base { | 11 namespace base { |
| 14 | 12 |
| 15 class BASE_EXPORT PowerObserver { | 13 class BASE_EXPORT PowerObserver { |
| 16 friend class PowerMonitor; | |
| 17 | |
| 18 public: | 14 public: |
| 19 PowerObserver(); | |
| 20 | |
| 21 // Notification of a change in power status of the computer, such | 15 // Notification of a change in power status of the computer, such |
| 22 // as from switching between battery and A/C power. | 16 // as from switching between battery and A/C power. |
| 23 virtual void OnPowerStateChange(bool on_battery_power) {} | 17 virtual void OnPowerStateChange(bool on_battery_power) {}; |
| 24 | 18 |
| 25 // Notification that the system is suspending. | 19 // Notification that the system is suspending. |
| 26 virtual void OnSuspend() {} | 20 virtual void OnSuspend() {} |
| 27 | 21 |
| 28 // Notification that the system is resuming. | 22 // Notification that the system is resuming. |
| 29 virtual void OnResume() {} | 23 virtual void OnResume() {} |
| 30 | 24 |
| 31 protected: | 25 protected: |
| 32 virtual ~PowerObserver(); | 26 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_; | |
| 38 }; | 27 }; |
| 39 | 28 |
| 40 } // namespace base | 29 } // namespace base |
| 41 | 30 |
| 42 #endif // BASE_POWER_MONITOR_POWER_OBSERVER_H_ | 31 #endif // BASE_POWER_MONITOR_POWER_OBSERVER_H_ |
| OLD | NEW |