Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: base/system_monitor/system_monitor.h

Issue 8528044: Revert 109960 - Send WM_DEVICECHANGE message through SystemMonitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/system_monitor/system_monitor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_export.h" 9 #include "base/base_export.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Notification that the system is suspending. 83 // Notification that the system is suspending.
84 virtual void OnSuspend() {} 84 virtual void OnSuspend() {}
85 85
86 // Notification that the system is resuming. 86 // Notification that the system is resuming.
87 virtual void OnResume() {} 87 virtual void OnResume() {}
88 88
89 protected: 89 protected:
90 virtual ~PowerObserver() {} 90 virtual ~PowerObserver() {}
91 }; 91 };
92 92
93 class BASE_EXPORT DevicesChangedObserver {
94 public:
95 // Notification that the devices connected to the system have changed.
96 virtual void OnDevicesChanged() {}
97
98 protected:
99 virtual ~DevicesChangedObserver() {}
100 };
101
102 // Add a new observer. 93 // Add a new observer.
103 // Can be called from any thread. 94 // Can be called from any thread.
104 // Must not be called from within a notification callback. 95 // Must not be called from within a notification callback.
105 void AddPowerObserver(PowerObserver* obs); 96 void AddObserver(PowerObserver* obs);
106 void AddDevicesChangedObserver(DevicesChangedObserver* obs);
107 97
108 // Remove an existing observer. 98 // Remove an existing observer.
109 // Can be called from any thread. 99 // Can be called from any thread.
110 // Must not be called from within a notification callback. 100 // Must not be called from within a notification callback.
111 void RemovePowerObserver(PowerObserver* obs); 101 void RemoveObserver(PowerObserver* obs);
112 void RemoveDevicesChangedObserver(DevicesChangedObserver* obs);
113 102
114 #if defined(OS_WIN) 103 #if defined(OS_WIN)
115 // Windows-specific handling of a WM_POWERBROADCAST message. 104 // Windows-specific handling of a WM_POWERBROADCAST message.
116 // Embedders of this API should hook their top-level window 105 // Embedders of this API should hook their top-level window
117 // message loop and forward WM_POWERBROADCAST through this call. 106 // message loop and forward WM_POWERBROADCAST through this call.
118 void ProcessWmPowerBroadcastMessage(int event_id); 107 void ProcessWmPowerBroadcastMessage(int event_id);
119 #endif 108 #endif
120 109
121 // Cross-platform handling of a power event. 110 // Cross-platform handling of a power event.
122 void ProcessPowerMessage(PowerEvent event_id); 111 void ProcessPowerMessage(PowerEvent event_id);
123 112
124 // Cross-platform handling of a device change event.
125 void ProcessDevicesChanged();
126
127 private: 113 private:
128 #if defined(OS_MACOSX) 114 #if defined(OS_MACOSX)
129 void PlatformInit(); 115 void PlatformInit();
130 void PlatformDestroy(); 116 void PlatformDestroy();
131 #endif 117 #endif
132 118
133 // Platform-specific method to check whether the system is currently 119 // Platform-specific method to check whether the system is currently
134 // running on battery power. Returns true if running on batteries, 120 // running on battery power. Returns true if running on batteries,
135 // false otherwise. 121 // false otherwise.
136 bool IsBatteryPower(); 122 bool IsBatteryPower();
137 123
138 // Checks the battery status and notifies observers if the battery 124 // Checks the battery status and notifies observers if the battery
139 // status has changed. 125 // status has changed.
140 void BatteryCheck(); 126 void BatteryCheck();
141 127
142 // Functions to trigger notifications. 128 // Functions to trigger notifications.
143 void NotifyDevicesChanged();
144 void NotifyPowerStateChange(); 129 void NotifyPowerStateChange();
145 void NotifySuspend(); 130 void NotifySuspend();
146 void NotifyResume(); 131 void NotifyResume();
147 132
148 scoped_refptr<ObserverListThreadSafe<PowerObserver> > power_observer_list_; 133 scoped_refptr<ObserverListThreadSafe<PowerObserver> > observer_list_;
149 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> >
150 devices_changed_observer_list_;
151 bool battery_in_use_; 134 bool battery_in_use_;
152 bool suspended_; 135 bool suspended_;
153 136
154 #if defined(ENABLE_BATTERY_MONITORING) 137 #if defined(ENABLE_BATTERY_MONITORING)
155 base::OneShotTimer<SystemMonitor> delayed_battery_check_; 138 base::OneShotTimer<SystemMonitor> delayed_battery_check_;
156 #endif 139 #endif
157 140
158 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); 141 DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
159 }; 142 };
160 143
161 } // namespace base 144 } // namespace base
162 145
163 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ 146 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | base/system_monitor/system_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698