OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_POWER_SESSION_LENGTH_LIMITER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/public/pref_change_registrar.h" | 10 #include "base/prefs/public/pref_change_registrar.h" |
11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/timer.h" | 13 #include "base/timer.h" |
14 | 14 |
15 class PrefService; | 15 class PrefService; |
16 class PrefServiceSimple; | 16 class PrefRegistrySimple; |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 // Enforces a session length limit by terminating the session when the limit is | 20 // Enforces a session length limit by terminating the session when the limit is |
21 // reached. | 21 // reached. |
22 class SessionLengthLimiter { | 22 class SessionLengthLimiter { |
23 public: | 23 public: |
24 class Delegate { | 24 class Delegate { |
25 public: | 25 public: |
26 virtual ~Delegate(); | 26 virtual ~Delegate(); |
27 | 27 |
28 virtual const base::Time GetCurrentTime() const = 0; | 28 virtual const base::Time GetCurrentTime() const = 0; |
29 virtual void StopSession() = 0; | 29 virtual void StopSession() = 0; |
30 }; | 30 }; |
31 | 31 |
32 // Registers preferences. | 32 // Registers preferences. |
33 static void RegisterPrefs(PrefServiceSimple* local_state); | 33 static void RegisterPrefs(PrefRegistrySimple* local_state); |
34 | 34 |
35 SessionLengthLimiter(Delegate* delegate, bool browser_restarted); | 35 SessionLengthLimiter(Delegate* delegate, bool browser_restarted); |
36 ~SessionLengthLimiter(); | 36 ~SessionLengthLimiter(); |
37 | 37 |
38 private: | 38 private: |
39 void OnSessionLengthLimitChanged(); | 39 void OnSessionLengthLimitChanged(); |
40 | 40 |
41 // Starts a timer that periodically checks whether the remaining time has | 41 // Starts a timer that periodically checks whether the remaining time has |
42 // reached zero. | 42 // reached zero. |
43 void StartTimer(); | 43 void StartTimer(); |
(...skipping 13 matching lines...) Expand all Loading... |
57 scoped_ptr<base::RepeatingTimer<SessionLengthLimiter> > repeating_timer_; | 57 scoped_ptr<base::RepeatingTimer<SessionLengthLimiter> > repeating_timer_; |
58 base::Time session_start_time_; | 58 base::Time session_start_time_; |
59 base::TimeDelta session_length_limit_; | 59 base::TimeDelta session_length_limit_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter); | 61 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter); |
62 }; | 62 }; |
63 | 63 |
64 } // namespace chromeos | 64 } // namespace chromeos |
65 | 65 |
66 #endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ | 66 #endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ |
OLD | NEW |