OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 DEVICE_BATTERY_BATTERY_STATUS_SERVICE_H_ | 5 #ifndef DEVICE_BATTERY_BATTERY_STATUS_SERVICE_H_ |
6 #define DEVICE_BATTERY_BATTERY_STATUS_SERVICE_H_ | 6 #define DEVICE_BATTERY_BATTERY_STATUS_SERVICE_H_ |
7 | 7 |
8 #include "base/callback_list.h" | 8 #include "base/callback_list.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 typedef base::Callback<void(const BatteryStatus&)> BatteryUpdateCallback; | 23 typedef base::Callback<void(const BatteryStatus&)> BatteryUpdateCallback; |
24 typedef base::CallbackList<void(const BatteryStatus&)> | 24 typedef base::CallbackList<void(const BatteryStatus&)> |
25 BatteryUpdateCallbackList; | 25 BatteryUpdateCallbackList; |
26 typedef BatteryUpdateCallbackList::Subscription BatteryUpdateSubscription; | 26 typedef BatteryUpdateCallbackList::Subscription BatteryUpdateSubscription; |
27 | 27 |
28 // Returns the BatteryStatusService singleton. | 28 // Returns the BatteryStatusService singleton. |
29 static BatteryStatusService* GetInstance(); | 29 static BatteryStatusService* GetInstance(); |
30 | 30 |
31 // Adds a callback to receive battery status updates. Must be called on the | 31 // Adds a callback to receive battery status updates. Must be called on the |
32 // main thread. The callback itself will be called on the main thread as well. | 32 // main thread. The callback itself will be called on the main thread as well. |
| 33 // NOTE: The callback may be run before AddCallback returns! |
33 scoped_ptr<BatteryUpdateSubscription> AddCallback( | 34 scoped_ptr<BatteryUpdateSubscription> AddCallback( |
34 const BatteryUpdateCallback& callback); | 35 const BatteryUpdateCallback& callback); |
35 | 36 |
36 // Gracefully clean-up. | 37 // Gracefully clean-up. |
37 void Shutdown(); | 38 void Shutdown(); |
38 | 39 |
39 // Injects a custom battery status manager for testing purposes. | 40 // Injects a custom battery status manager for testing purposes. |
40 void SetBatteryManagerForTesting( | 41 void SetBatteryManagerForTesting( |
41 scoped_ptr<BatteryStatusManager> test_battery_manager); | 42 scoped_ptr<BatteryStatusManager> test_battery_manager); |
42 | 43 |
(...skipping 20 matching lines...) Expand all Loading... |
63 BatteryStatus status_; | 64 BatteryStatus status_; |
64 bool status_updated_; | 65 bool status_updated_; |
65 bool is_shutdown_; | 66 bool is_shutdown_; |
66 | 67 |
67 DISALLOW_COPY_AND_ASSIGN(BatteryStatusService); | 68 DISALLOW_COPY_AND_ASSIGN(BatteryStatusService); |
68 }; | 69 }; |
69 | 70 |
70 } // namespace device | 71 } // namespace device |
71 | 72 |
72 #endif // DEVICE_BATTERY_BATTERY_STATUS_SERVICE_H_ | 73 #endif // DEVICE_BATTERY_BATTERY_STATUS_SERVICE_H_ |
OLD | NEW |