Chromium Code Reviews| Index: content/public/browser/battery_status_provider.h |
| diff --git a/content/public/browser/battery_status_provider.h b/content/public/browser/battery_status_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6720247cdeefc4f21d4c39c8f31e10529db42d44 |
| --- /dev/null |
| +++ b/content/public/browser/battery_status_provider.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2012 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_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_ |
| +#define CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_ |
| + |
| +#include <list> |
| + |
| +#include "base/memory/singleton.h" |
| +#include "base/observer_list.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace content { |
| + |
| +struct CONTENT_EXPORT PowerSupplyStatus { |
|
jam
2012/04/12 01:55:10
the content api, like the webkit api, puts each st
sadrul
2012/04/12 05:20:09
Done.
|
| + bool line_power_on; |
| + |
| + bool battery_is_present; |
| + bool battery_is_full; |
| + |
| + // Time in seconds until the battery is empty or full, 0 for unknown. |
| + int64 battery_seconds_to_empty; |
| + int64 battery_seconds_to_full; |
| + |
| + double battery_percentage; |
| + |
| + bool is_calculating_battery_time; |
| +}; |
| + |
| +class CONTENT_EXPORT BatteryStatusProvider { |
| + public: |
| + class CONTENT_EXPORT Observer { |
|
jam
2012/04/12 01:55:10
this class is only used by content, so it doesn't
sadrul
2012/04/12 05:20:09
Done.
|
| + public: |
| + virtual void PowerChanged(const PowerSupplyStatus& power_status) = 0; |
| + }; |
| + |
| + static BatteryStatusProvider* GetInstance(); |
| + |
| + void AddObserver(Observer* observer); |
|
jam
2012/04/12 01:55:10
for the content API we follow webkit API and only
sadrul
2012/04/12 05:20:09
Done.
|
| + void RemoveObserver(Observer* observer); |
| + |
| + // Sends updated battery status information to all the observers. |
| + void SendUpdate(const PowerSupplyStatus& power_status); |
| + |
| + private: |
| + friend struct DefaultSingletonTraits<BatteryStatusProvider>; |
| + |
| + BatteryStatusProvider(); |
| + virtual ~BatteryStatusProvider(); |
| + |
| + ObserverList<Observer> observers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BatteryStatusProvider); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_ |