| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 10 #include "base/memory/singleton.h" |
| 11 #include "base/observer_list.h" |
| 12 #include "content/common/content_export.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 struct CONTENT_EXPORT PowerSupplyStatus { |
| 17 bool line_power_on; |
| 18 |
| 19 bool battery_is_present; |
| 20 bool battery_is_full; |
| 21 |
| 22 // Time in seconds until the battery is empty or full, 0 for unknown. |
| 23 int64 battery_seconds_to_empty; |
| 24 int64 battery_seconds_to_full; |
| 25 |
| 26 double battery_percentage; |
| 27 |
| 28 bool is_calculating_battery_time; |
| 29 }; |
| 30 |
| 31 class CONTENT_EXPORT BatteryStatusProvider { |
| 32 public: |
| 33 class CONTENT_EXPORT Observer { |
| 34 public: |
| 35 virtual void PowerChanged(const PowerSupplyStatus& power_status) = 0; |
| 36 }; |
| 37 |
| 38 static BatteryStatusProvider* GetInstance(); |
| 39 |
| 40 void AddObserver(Observer* observer); |
| 41 void RemoveObserver(Observer* observer); |
| 42 |
| 43 // Sends updated battery status information to all the observers. |
| 44 void SendUpdate(const PowerSupplyStatus& power_status); |
| 45 |
| 46 private: |
| 47 friend struct DefaultSingletonTraits<BatteryStatusProvider>; |
| 48 |
| 49 BatteryStatusProvider(); |
| 50 virtual ~BatteryStatusProvider(); |
| 51 |
| 52 ObserverList<Observer> observers_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(BatteryStatusProvider); |
| 55 }; |
| 56 |
| 57 } // namespace content |
| 58 |
| 59 #endif // CONTENT_PUBLIC_BROWSER_BATTERY_STATUS_PROVIDER_H_ |
| OLD | NEW |