| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 CrosPowerLibrary(); | 50 CrosPowerLibrary(); |
| 51 ~CrosPowerLibrary(); | 51 ~CrosPowerLibrary(); |
| 52 | 52 |
| 53 // This method is called when there's a change in power status. | 53 // This method is called when there's a change in power status. |
| 54 // This method is called on a background thread. | 54 // This method is called on a background thread. |
| 55 static void PowerStatusChangedHandler(void* object, | 55 static void PowerStatusChangedHandler(void* object, |
| 56 const chromeos::PowerStatus& status); | 56 const chromeos::PowerStatus& status); |
| 57 | 57 |
| 58 // This methods starts the monitoring of power changes. | 58 // This methods starts the monitoring of power changes. |
| 59 // It should be called on a background thread. | 59 void Init(); |
| 60 void InitOnBackgroundThread(); | |
| 61 | 60 |
| 62 // Called by the handler to update the power status. | 61 // Called by the handler to update the power status. |
| 63 // This will notify all the Observers. | 62 // This will notify all the Observers. |
| 64 void UpdatePowerStatus(const chromeos::PowerStatus& status); | 63 void UpdatePowerStatus(const chromeos::PowerStatus& status); |
| 65 | 64 |
| 66 ObserverList<Observer> observers_; | 65 ObserverList<Observer> observers_; |
| 67 | 66 |
| 68 // A reference to the battery power api, to allow callbacks when the battery | 67 // A reference to the battery power api, to allow callbacks when the battery |
| 69 // status changes. | 68 // status changes. |
| 70 chromeos::PowerStatusConnection power_status_connection_; | 69 chromeos::PowerStatusConnection power_status_connection_; |
| 71 | 70 |
| 72 // The latest power status. | 71 // The latest power status. |
| 73 chromeos::PowerStatus status_; | 72 chromeos::PowerStatus status_; |
| 74 | 73 |
| 75 DISALLOW_COPY_AND_ASSIGN(CrosPowerLibrary); | 74 DISALLOW_COPY_AND_ASSIGN(CrosPowerLibrary); |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 #endif // CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ | 77 #endif // CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ |
| OLD | NEW |