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