Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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_SYSTEM_MONITOR_H_ | 5 #ifndef BASE_SYSTEM_MONITOR_H_ |
| 6 #define BASE_SYSTEM_MONITOR_H_ | 6 #define BASE_SYSTEM_MONITOR_H_ |
| 7 | 7 |
| 8 #include "base/observer_list_threadsafe.h" | 8 #include "build/build_config.h" |
| 9 #include "base/singleton.h" | |
| 10 | 9 |
| 11 // Windows HiRes timers drain the battery faster so we need to know the battery | 10 // Windows HiRes timers drain the battery faster so we need to know the battery |
| 12 // status. This isn't true for other platforms. | 11 // status. This isn't true for other platforms. |
| 13 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 14 #define ENABLE_BATTERY_MONITORING 1 | 13 #define ENABLE_BATTERY_MONITORING 1 |
| 15 #else | 14 #else |
| 16 #undef ENABLE_BATTERY_MONITORING | 15 #undef ENABLE_BATTERY_MONITORING |
| 17 #endif // !OS_WIN | 16 #endif // !OS_WIN |
| 18 | 17 |
| 18 #include "base/observer_list_threadsafe.h" | |
| 19 #include "base/singleton.h" | |
| 20 #if defined(ENABLE_BATTERY_MONITORING) | |
| 21 #include "base/timer.h" | |
| 22 #endif // defined(ENABLE_BATTERY_MONITORING) | |
| 23 | |
| 19 namespace base { | 24 namespace base { |
| 20 | 25 |
| 21 // Class for monitoring various system-related subsystems | 26 // Class for monitoring various system-related subsystems |
| 22 // such as power management, network status, etc. | 27 // such as power management, network status, etc. |
| 23 // TODO(mbelshe): Add support beyond just power management. | 28 // TODO(mbelshe): Add support beyond just power management. |
| 24 class SystemMonitor { | 29 class SystemMonitor { |
| 25 public: | 30 public: |
| 26 // Access to the Singleton | 31 // Access to the Singleton |
| 27 static SystemMonitor* Get() { | 32 static SystemMonitor* Get() { |
|
M-A Ruel
2009/06/03 14:28:37
Humm I'd rather have this function implementation
| |
| 28 // Uses the LeakySingletonTrait because cleanup is optional. | 33 // Uses the LeakySingletonTrait because cleanup is optional. |
| 29 return | 34 return |
| 30 Singleton<SystemMonitor, LeakySingletonTraits<SystemMonitor> >::get(); | 35 Singleton<SystemMonitor, LeakySingletonTraits<SystemMonitor> >::get(); |
| 31 } | 36 } |
| 32 | 37 |
| 33 // Start the System Monitor within a process. This method | 38 // Start the System Monitor within a process. This method |
| 34 // is provided so that the battery check can be deferred. | 39 // is provided so that the battery check can be deferred. |
| 35 // The MessageLoop must be started before calling this | 40 // The MessageLoop must be started before calling this |
| 36 // method. | 41 // method. |
| 37 // This is a no-op on platforms for which ENABLE_BATTERY_MONITORING is | 42 // This is a no-op on platforms for which ENABLE_BATTERY_MONITORING is |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 #if defined(ENABLE_BATTERY_MONITORING) | 125 #if defined(ENABLE_BATTERY_MONITORING) |
| 121 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 126 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
| 122 #endif | 127 #endif |
| 123 | 128 |
| 124 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 129 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
| 125 }; | 130 }; |
| 126 | 131 |
| 127 } | 132 } |
| 128 | 133 |
| 129 #endif // BASE_SYSTEM_MONITOR_H_ | 134 #endif // BASE_SYSTEM_MONITOR_H_ |
| OLD | NEW |