Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // Remove an existing observer. | 127 // Remove an existing observer. |
| 128 // Can be called from any thread. | 128 // Can be called from any thread. |
| 129 // Must not be called from within a notification callback. | 129 // Must not be called from within a notification callback. |
| 130 void RemovePowerObserver(PowerObserver* obs); | 130 void RemovePowerObserver(PowerObserver* obs); |
| 131 void RemoveDevicesChangedObserver(DevicesChangedObserver* obs); | 131 void RemoveDevicesChangedObserver(DevicesChangedObserver* obs); |
| 132 | 132 |
| 133 // The ProcessFoo() style methods are a broken pattern and should not | 133 // The ProcessFoo() style methods are a broken pattern and should not |
| 134 // be copied. Any significant addition to this class is blocked on | 134 // be copied. Any significant addition to this class is blocked on |
| 135 // refactoring to improve the state of affairs. See http://crbug.com/149059 | 135 // refactoring to improve the state of affairs. See http://crbug.com/149059 |
| 136 | 136 |
| 137 #if defined(OS_WIN) | |
| 138 // Windows-specific handling of a WM_POWERBROADCAST message. | |
| 139 // Embedders of this API should hook their top-level window | |
| 140 // message loop and forward WM_POWERBROADCAST through this call. | |
| 141 void ProcessWmPowerBroadcastMessage(int event_id); | |
| 142 #endif | |
| 143 | |
| 144 // Cross-platform handling of a power event. | 137 // Cross-platform handling of a power event. |
| 145 void ProcessPowerMessage(PowerEvent event_id); | 138 void ProcessPowerMessage(PowerEvent event_id); |
| 146 | 139 |
| 147 // Cross-platform handling of a device change event. | 140 // Cross-platform handling of a device change event. |
| 148 void ProcessDevicesChanged(DeviceType device_type); | 141 void ProcessDevicesChanged(DeviceType device_type); |
| 149 | 142 |
| 150 private: | 143 private: |
| 144 #if defined(OS_WIN) | |
| 145 // Represents a message-only window for power message handling on Windows. | |
| 146 // Only allow SystemMonitor to create it. | |
| 147 class PowerMessageWindow { | |
|
Hongbo Min
2013/02/23 03:42:01
Let me explain the reason why we need to define th
vandebo (ex-Chrome)
2013/02/25 17:46:54
I see. This can be solved by making SystemMonitor
| |
| 148 public: | |
| 149 PowerMessageWindow(); | |
| 150 ~PowerMessageWindow(); | |
| 151 | |
| 152 private: | |
| 153 void ProcessWmPowerBroadcastMessage(int event_id); | |
| 154 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, | |
| 155 WPARAM wparam, LPARAM lparam); | |
| 156 static LRESULT CALLBACK WndProcThunk(HWND hwnd, | |
| 157 UINT message, | |
| 158 WPARAM wparam, | |
| 159 LPARAM lparam); | |
| 160 // Instance of the module containing the window procedure. | |
| 161 HMODULE instance_; | |
| 162 // A hidden message-only window. | |
| 163 HWND message_hwnd_; | |
| 164 }; | |
| 165 #endif | |
| 166 | |
| 151 #if defined(OS_MACOSX) | 167 #if defined(OS_MACOSX) |
| 152 void PlatformInit(); | 168 void PlatformInit(); |
| 153 void PlatformDestroy(); | 169 void PlatformDestroy(); |
| 154 #endif | 170 #endif |
| 155 | 171 |
| 156 // Platform-specific method to check whether the system is currently | 172 // Platform-specific method to check whether the system is currently |
| 157 // running on battery power. Returns true if running on batteries, | 173 // running on battery power. Returns true if running on batteries, |
| 158 // false otherwise. | 174 // false otherwise. |
| 159 bool IsBatteryPower(); | 175 bool IsBatteryPower(); |
| 160 | 176 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 176 | 192 |
| 177 #if defined(ENABLE_BATTERY_MONITORING) | 193 #if defined(ENABLE_BATTERY_MONITORING) |
| 178 base::OneShotTimer<SystemMonitor> delayed_battery_check_; | 194 base::OneShotTimer<SystemMonitor> delayed_battery_check_; |
| 179 #endif | 195 #endif |
| 180 | 196 |
| 181 #if defined(OS_IOS) | 197 #if defined(OS_IOS) |
| 182 // Holds pointers to system event notification observers. | 198 // Holds pointers to system event notification observers. |
| 183 std::vector<id> notification_observers_; | 199 std::vector<id> notification_observers_; |
| 184 #endif | 200 #endif |
| 185 | 201 |
| 202 #if defined(OS_WIN) | |
| 203 PowerMessageWindow power_message_window_; | |
| 204 #endif | |
| 205 | |
| 186 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 206 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
| 187 }; | 207 }; |
| 188 | 208 |
| 189 } // namespace base | 209 } // namespace base |
| 190 | 210 |
| 191 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 211 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
| OLD | NEW |