Chromium Code Reviews| Index: content/common/power_monitor_client.h |
| diff --git a/content/common/power_monitor_client.h b/content/common/power_monitor_client.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..febb5a0684c5c37f3044facbe467ac300d2088cf |
| --- /dev/null |
| +++ b/content/common/power_monitor_client.h |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_COMMON_POWER_MONITOR_CLIENT_H_ |
| +#define CONTENT_COMMON_POWER_MONITOR_CLIENT_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/observer_list_threadsafe.h" |
| +#include "base/power_monitor/power_observer.h" |
| + |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +// A class used to monitor the power state change and notify the observers about |
| +// the change event. |
| +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
|
| +public: |
| + 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
|
| + ~PowerMonitorClient(); |
| + |
| + // Get the process-wide PowerMonitorClient (if not present, returns NULL). |
| + static PowerMonitorClient* Get(); |
| + |
| + // Add and remove an observer. |
| + // Can be called from any thread. |
| + // Must not be called from within a notification callback. |
| + void AddObserver(base::PowerObserver* observer); |
| + void RemoveObserver(base::PowerObserver* observer); |
| + |
| + // Is the computer currently on battery power. Can be called on any thread. |
| + bool BatteryPower() const { |
| + // Using a lock here is not necessary for just a bool. |
|
scottmg
2013/06/22 00:11:24
tsan will not agree
|
| + return battery_in_use_; |
| + } |
| + |
| +private: |
| + friend class PowerMonitorMessageFilter; |
| + |
| + void NotifyPowerStateChange(bool battery_in_use); |
| + void NotifySuspend(); |
| + void NotifyResume(); |
| + |
| + scoped_refptr<ObserverListThreadSafe<base::PowerObserver> > observers_; |
| + bool battery_in_use_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PowerMonitorClient); |
| +}; |
| + |
| +} // namespace base |
| + |
| +#endif // CONTENT_COMMON_POWER_MONITOR_CLIENT_H_ |