OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SYSTEM_MONITOR_H_ | 5 #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/base_api.h" |
9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 | 12 |
12 // Windows HiRes timers drain the battery faster so we need to know the battery | 13 // Windows HiRes timers drain the battery faster so we need to know the battery |
13 // status. This isn't true for other platforms. | 14 // status. This isn't true for other platforms. |
14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
15 #define ENABLE_BATTERY_MONITORING 1 | 16 #define ENABLE_BATTERY_MONITORING 1 |
16 #else | 17 #else |
17 #undef ENABLE_BATTERY_MONITORING | 18 #undef ENABLE_BATTERY_MONITORING |
18 #endif // !OS_WIN | 19 #endif // !OS_WIN |
19 | 20 |
20 #include "base/observer_list_threadsafe.h" | 21 #include "base/observer_list_threadsafe.h" |
21 #if defined(ENABLE_BATTERY_MONITORING) | 22 #if defined(ENABLE_BATTERY_MONITORING) |
22 #include "base/timer.h" | 23 #include "base/timer.h" |
23 #endif // defined(ENABLE_BATTERY_MONITORING) | 24 #endif // defined(ENABLE_BATTERY_MONITORING) |
24 | 25 |
25 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
26 #include <IOKit/pwr_mgt/IOPMLib.h> | 27 #include <IOKit/pwr_mgt/IOPMLib.h> |
27 #include <IOKit/IOMessage.h> | 28 #include <IOKit/IOMessage.h> |
28 #endif // OS_MACOSX | 29 #endif // OS_MACOSX |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 | 32 |
32 // Class for monitoring various system-related subsystems | 33 // Class for monitoring various system-related subsystems |
33 // such as power management, network status, etc. | 34 // such as power management, network status, etc. |
34 // TODO(mbelshe): Add support beyond just power management. | 35 // TODO(mbelshe): Add support beyond just power management. |
35 class SystemMonitor { | 36 class BASE_API SystemMonitor { |
36 public: | 37 public: |
37 // Normalized list of power events. | 38 // Normalized list of power events. |
38 enum PowerEvent { | 39 enum PowerEvent { |
39 POWER_STATE_EVENT, // The Power status of the system has changed. | 40 POWER_STATE_EVENT, // The Power status of the system has changed. |
40 SUSPEND_EVENT, // The system is being suspended. | 41 SUSPEND_EVENT, // The system is being suspended. |
41 RESUME_EVENT // The system is being resumed. | 42 RESUME_EVENT // The system is being resumed. |
42 }; | 43 }; |
43 | 44 |
44 // Create SystemMonitor. Only one SystemMonitor instance per application | 45 // Create SystemMonitor. Only one SystemMonitor instance per application |
45 // is allowed. | 46 // is allowed. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 IONotificationPortRef notification_port_ref_; | 134 IONotificationPortRef notification_port_ref_; |
134 io_object_t notifier_object_; | 135 io_object_t notifier_object_; |
135 #endif | 136 #endif |
136 | 137 |
137 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 138 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
138 }; | 139 }; |
139 | 140 |
140 } // namespace base | 141 } // namespace base |
141 | 142 |
142 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 143 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
OLD | NEW |