| Index: base/power_monitor/power_monitor_device_source.h
|
| diff --git a/base/power_monitor/power_monitor.h b/base/power_monitor/power_monitor_device_source.h
|
| similarity index 65%
|
| copy from base/power_monitor/power_monitor.h
|
| copy to base/power_monitor/power_monitor_device_source.h
|
| index e8935473915c4a108009a473c27defbc79d93147..392ad6d300e885150a26d9f990f76bcc93dc50c4 100644
|
| --- a/base/power_monitor/power_monitor.h
|
| +++ b/base/power_monitor/power_monitor_device_source.h
|
| @@ -2,13 +2,14 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef BASE_POWER_MONITOR_POWER_MONITOR_H_
|
| -#define BASE_POWER_MONITOR_POWER_MONITOR_H_
|
| +#ifndef BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_
|
| +#define BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_
|
|
|
| #include "base/base_export.h"
|
| #include "base/basictypes.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/observer_list_threadsafe.h"
|
| +#include "base/power_monitor/power_monitor_source.h"
|
| #include "base/power_monitor/power_observer.h"
|
|
|
| #if defined(OS_WIN)
|
| @@ -33,20 +34,10 @@ namespace base {
|
|
|
| // A class used to monitor the power state change and notify the observers about
|
| // the change event.
|
| -class BASE_EXPORT PowerMonitor {
|
| +class BASE_EXPORT PowerMonitorDeviceSource : public PowerMonitorSource {
|
| public:
|
| - // Normalized list of power events.
|
| - enum PowerEvent {
|
| - POWER_STATE_EVENT, // The Power status of the system has changed.
|
| - SUSPEND_EVENT, // The system is being suspended.
|
| - RESUME_EVENT // The system is being resumed.
|
| - };
|
| -
|
| - PowerMonitor();
|
| - ~PowerMonitor();
|
| -
|
| - // Get the application-wide PowerMonitor (if not present, returns NULL).
|
| - static PowerMonitor* Get();
|
| + PowerMonitorDeviceSource();
|
| + virtual ~PowerMonitorDeviceSource() OVERRIDE;
|
|
|
| #if defined(OS_MACOSX)
|
| // Allocate system resources needed by the PowerMonitor class.
|
| @@ -60,22 +51,8 @@ class BASE_EXPORT PowerMonitor {
|
| #endif // OS_IOS
|
| #endif // OS_MACOSX
|
|
|
| - // Add and remove an observer.
|
| - // Can be called from any thread.
|
| - // Must not be called from within a notification callback.
|
| - void AddObserver(PowerObserver* observer);
|
| - void RemoveObserver(PowerObserver* observer);
|
| -
|
| - // Is the computer currently on battery power. Can be called on any thread.
|
| - bool BatteryPower() const {
|
| - // Using a lock here is not necessary for just a bool.
|
| - return battery_in_use_;
|
| - }
|
| -
|
| private:
|
| friend class PowerMonitorTest;
|
| - // A friend function that is allowed to access the private ProcessPowerEvent.
|
| - friend void ProcessPowerEventHelper(PowerEvent);
|
|
|
| #if defined(OS_WIN)
|
| // Represents a message-only window for power message handling on Windows.
|
| @@ -105,22 +82,15 @@ class BASE_EXPORT PowerMonitor {
|
| void PlatformDestroy();
|
| #endif
|
|
|
| - // Cross-platform handling of a power event.
|
| - void ProcessPowerEvent(PowerEvent event_id);
|
| -
|
| // Platform-specific method to check whether the system is currently
|
| // running on battery power. Returns true if running on batteries,
|
| // false otherwise.
|
| - bool IsBatteryPower();
|
| + virtual bool IsBatteryPower() OVERRIDE;
|
|
|
| // Checks the battery status and notifies observers if the battery
|
| // status has changed.
|
| void BatteryCheck();
|
|
|
| - void NotifyPowerStateChange();
|
| - void NotifySuspend();
|
| - void NotifyResume();
|
| -
|
| #if defined(OS_IOS)
|
| // Holds pointers to system event notification observers.
|
| std::vector<id> notification_observers_;
|
| @@ -130,17 +100,13 @@ class BASE_EXPORT PowerMonitor {
|
| base::OneShotTimer<PowerMonitor> delayed_battery_check_;
|
| #endif
|
|
|
| - scoped_refptr<ObserverListThreadSafe<PowerObserver> > observers_;
|
| - bool battery_in_use_;
|
| - bool suspended_;
|
| -
|
| #if defined(OS_WIN)
|
| PowerMessageWindow power_message_window_;
|
| #endif
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
|
| + DISALLOW_COPY_AND_ASSIGN(PowerMonitorDeviceSource);
|
| };
|
|
|
| } // namespace base
|
|
|
| -#endif // BASE_POWER_MONITOR_POWER_MONITOR_H_
|
| +#endif // BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_H_
|
|
|