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 CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ |
6 #define CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ | 6 #define CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ |
7 | 7 |
8 #include "ash/wm/user_activity_observer.h" | 8 #include "ash/wm/user_activity_observer.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/time/time.h" |
11 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
12 | 14 |
13 namespace chromeos { | 15 namespace chromeos { |
14 | 16 |
| 17 // This may need to be replaced with code in power manager, please see |
| 18 // crbug.com/343671 for details. |
15 class IdleDetector : public ash::UserActivityObserver { | 19 class IdleDetector : public ash::UserActivityObserver { |
16 public: | 20 public: |
17 IdleDetector(const base::Closure& on_active_callback, | 21 IdleDetector(const base::Closure& on_active_callback, |
18 const base::Closure& on_idle_callback); | 22 const base::Closure& on_idle_callback); |
19 virtual ~IdleDetector(); | 23 virtual ~IdleDetector(); |
20 | 24 |
21 void Start(const base::TimeDelta& timeout); | 25 void Start(const base::TimeDelta& timeout); |
22 | 26 |
23 private: | 27 private: |
24 // UserActivityObserver overrides: | 28 // UserActivityObserver overrides: |
25 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; | 29 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; |
26 | 30 |
27 // Resets |timer_| to fire when we reach our idle timeout. | 31 // Resets |timer_| to fire when we reach our idle timeout. |
28 void ResetTimer(); | 32 void ResetTimer(); |
29 | 33 |
30 base::OneShotTimer<IdleDetector> timer_; | 34 base::OneShotTimer<IdleDetector> timer_; |
31 | 35 |
32 base::Closure active_callback_; | 36 base::Closure active_callback_; |
33 base::Closure idle_callback_; | 37 base::Closure idle_callback_; |
34 | 38 |
35 base::TimeDelta timeout_; | 39 base::TimeDelta timeout_; |
36 | 40 |
37 DISALLOW_COPY_AND_ASSIGN(IdleDetector); | 41 DISALLOW_COPY_AND_ASSIGN(IdleDetector); |
38 }; | 42 }; |
39 | 43 |
40 } // namespace chromeos | 44 } // namespace chromeos |
41 | 45 |
42 #endif // CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ | 46 #endif // CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ |
OLD | NEW |