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