Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_POWER_MONITOR_CLIENT_H_ | |
| 6 #define CONTENT_COMMON_POWER_MONITOR_CLIENT_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/observer_list_threadsafe.h" | |
| 10 #include "base/power_monitor/power_observer.h" | |
| 11 | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 // A class used to monitor the power state change and notify the observers about | |
| 17 // the change event. | |
| 18 class CONTENT_EXPORT PowerMonitorClient { | |
|
wrong vandebo
2013/06/24 16:34:49
So this class looks basically the same as base::Sy
bajones
2013/06/25 18:33:34
I assume you mean base::PowerMonitor, not base::Sy
vandebo (ex-Chrome)
2013/06/25 18:37:14
Oops, yes, base::PowerMonitor (PowerMonitor was e
| |
| 19 public: | |
| 20 PowerMonitorClient(); | |
|
Ken Russell (switch to Gerrit)
2013/06/24 22:54:38
Since this class is a singleton the constructor an
bajones
2013/06/25 18:33:34
That would be my thinking as well, but that's not
| |
| 21 ~PowerMonitorClient(); | |
| 22 | |
| 23 // Get the process-wide PowerMonitorClient (if not present, returns NULL). | |
| 24 static PowerMonitorClient* Get(); | |
| 25 | |
| 26 // Add and remove an observer. | |
| 27 // Can be called from any thread. | |
| 28 // Must not be called from within a notification callback. | |
| 29 void AddObserver(base::PowerObserver* observer); | |
| 30 void RemoveObserver(base::PowerObserver* observer); | |
| 31 | |
| 32 // Is the computer currently on battery power. Can be called on any thread. | |
| 33 bool BatteryPower() const { | |
| 34 // Using a lock here is not necessary for just a bool. | |
|
scottmg
2013/06/22 00:11:24
tsan will not agree
| |
| 35 return battery_in_use_; | |
| 36 } | |
| 37 | |
| 38 private: | |
| 39 friend class PowerMonitorMessageFilter; | |
| 40 | |
| 41 void NotifyPowerStateChange(bool battery_in_use); | |
| 42 void NotifySuspend(); | |
| 43 void NotifyResume(); | |
| 44 | |
| 45 scoped_refptr<ObserverListThreadSafe<base::PowerObserver> > observers_; | |
| 46 bool battery_in_use_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(PowerMonitorClient); | |
| 49 }; | |
| 50 | |
| 51 } // namespace base | |
| 52 | |
| 53 #endif // CONTENT_COMMON_POWER_MONITOR_CLIENT_H_ | |
| OLD | NEW |