OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 // TODO(sque): Move to chrome/browser/chromeos/system, crosbug.com/16558 | 9 // TODO(sque): Move to chrome/browser/chromeos/system, crosbug.com/16558 |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 | 12 |
13 namespace chromeos { | 13 namespace chromeos { |
14 | 14 |
15 typedef base::Callback<void(int64_t)> CalculateIdleTimeCallback; | |
16 | |
17 // This interface defines interaction with the ChromeOS power library APIs. | 15 // This interface defines interaction with the ChromeOS power library APIs. |
18 // Classes can add themselves as observers. Users can get an instance of this | 16 // Classes can add themselves as observers. Users can get an instance of this |
19 // library class like this: chromeos::CrosLibrary::Get()->GetPowerLibrary() | 17 // library class like this: chromeos::CrosLibrary::Get()->GetPowerLibrary() |
20 class PowerLibrary { | 18 class PowerLibrary { |
21 public: | 19 public: |
22 class Observer { | 20 class Observer { |
23 public: | 21 public: |
24 virtual void SystemResumed() = 0; | 22 virtual void SystemResumed() = 0; |
25 | 23 |
26 protected: | 24 protected: |
27 virtual ~Observer() {} | 25 virtual ~Observer() {} |
28 }; | 26 }; |
29 | 27 |
30 virtual ~PowerLibrary() {} | 28 virtual ~PowerLibrary() {} |
31 | 29 |
32 virtual void Init() = 0; | 30 virtual void Init() = 0; |
33 | 31 |
34 virtual void AddObserver(Observer* observer) = 0; | 32 virtual void AddObserver(Observer* observer) = 0; |
35 virtual void RemoveObserver(Observer* observer) = 0; | 33 virtual void RemoveObserver(Observer* observer) = 0; |
36 | 34 |
37 // Calculates idle time asynchronously. If it encounters some error, | |
38 // it returns -1. | |
39 virtual void CalculateIdleTime(CalculateIdleTimeCallback* callback) = 0; | |
40 | |
41 // Enable/disable screen lock for current session. | 35 // Enable/disable screen lock for current session. |
42 virtual void EnableScreenLock(bool enable) = 0; | 36 virtual void EnableScreenLock(bool enable) = 0; |
43 | 37 |
44 // Factory function, creates a new instance and returns ownership. | 38 // Factory function, creates a new instance and returns ownership. |
45 // For normal usage, access the singleton via CrosLibrary::Get(). | 39 // For normal usage, access the singleton via CrosLibrary::Get(). |
46 static PowerLibrary* GetImpl(bool stub); | 40 static PowerLibrary* GetImpl(bool stub); |
47 }; | 41 }; |
48 | 42 |
49 } // namespace chromeos | 43 } // namespace chromeos |
50 | 44 |
51 #endif // CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ | 45 #endif // CHROME_BROWSER_CHROMEOS_CROS_POWER_LIBRARY_H_ |
OLD | NEW |