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: |
| 151 #if defined(OS_MACOSX) | 144 #if defined(OS_MACOSX) || defined(OS_WIN) |
|
vandebo (ex-Chrome)
2013/02/21 19:47:17
Remove change - you don't have PlatformInit/Desotr
Hongbo Min
2013/02/22 06:55:43
Done.
| |
| 152 void PlatformInit(); | 145 void PlatformInit(); |
| 153 void PlatformDestroy(); | 146 void PlatformDestroy(); |
| 154 #endif | 147 #endif |
| 155 | 148 |
| 149 #if defined(OS_WIN) | |
| 150 // Represents a message-only window for power message handling on Windows. | |
| 151 // Only allow SystemMonitor to create it. | |
| 152 class PowerMessageWindow { | |
|
vandebo (ex-Chrome)
2013/02/21 19:47:17
Brett's point was that this can be an anonymous cl
Hongbo Min
2013/02/22 06:55:43
The problem is, if we just declare the class here
vandebo (ex-Chrome)
2013/02/23 01:14:53
Good point. Put it in system_monitor_win.cc and u
| |
| 153 private: | |
| 154 friend class SystemMonitor; | |
|
vandebo (ex-Chrome)
2013/02/21 19:47:17
Looks like won't need this friend declaration afte
Hongbo Min
2013/02/22 06:55:43
Actually, no need to make ctor and dtor as private
| |
| 155 | |
| 156 PowerMessageWindow(); | |
| 157 ~PowerMessageWindow(); | |
| 158 void ProcessWmPowerBroadcastMessage(int event_id); | |
| 159 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, | |
| 160 WPARAM wparam, LPARAM lparam); | |
| 161 static LRESULT CALLBACK WndProcThunk(HWND hwnd, | |
| 162 UINT message, | |
| 163 WPARAM wparam, | |
| 164 LPARAM lparam); | |
| 165 // Instance of the module containing the window procedure. | |
| 166 HMODULE instance_; | |
| 167 // A hidden message-only window. | |
| 168 HWND message_hwnd_; | |
| 169 }; | |
| 170 | |
| 171 PowerMessageWindow power_message_window_; | |
| 172 #endif | |
| 173 | |
| 156 // Platform-specific method to check whether the system is currently | 174 // Platform-specific method to check whether the system is currently |
| 157 // running on battery power. Returns true if running on batteries, | 175 // running on battery power. Returns true if running on batteries, |
| 158 // false otherwise. | 176 // false otherwise. |
| 159 bool IsBatteryPower(); | 177 bool IsBatteryPower(); |
| 160 | 178 |
| 161 // Checks the battery status and notifies observers if the battery | 179 // Checks the battery status and notifies observers if the battery |
| 162 // status has changed. | 180 // status has changed. |
| 163 void BatteryCheck(); | 181 void BatteryCheck(); |
| 164 | 182 |
| 165 // Functions to trigger notifications. | 183 // Functions to trigger notifications. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 182 // Holds pointers to system event notification observers. | 200 // Holds pointers to system event notification observers. |
| 183 std::vector<id> notification_observers_; | 201 std::vector<id> notification_observers_; |
| 184 #endif | 202 #endif |
| 185 | 203 |
| 186 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); | 204 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
| 187 }; | 205 }; |
| 188 | 206 |
| 189 } // namespace base | 207 } // namespace base |
| 190 | 208 |
| 191 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ | 209 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
| OLD | NEW |