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