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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // Registers preferences. | 32 // Registers preferences. |
33 static void RegisterPrefs(PrefRegistrySimple* registry); | 33 static void RegisterPrefs(PrefRegistrySimple* registry); |
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 | |
42 // reached zero. | |
43 void StartTimer(); | |
44 | |
45 // Stops the timer. | |
46 void StopTimer(); | |
47 | |
48 // Updates the remaining time, and terminates the session when the time | |
49 // reaches zero. | |
50 void UpdateRemainingTime(); | |
51 | |
52 base::ThreadChecker thread_checker_; | 41 base::ThreadChecker thread_checker_; |
53 | 42 |
54 scoped_ptr<Delegate> delegate_; | 43 scoped_ptr<Delegate> delegate_; |
55 PrefChangeRegistrar pref_change_registrar_; | 44 PrefChangeRegistrar pref_change_registrar_; |
56 | 45 |
57 scoped_ptr<base::RepeatingTimer<SessionLengthLimiter> > repeating_timer_; | 46 scoped_ptr<base::OneShotTimer<SessionLengthLimiter::Delegate> > timer_; |
58 base::Time session_start_time_; | 47 base::Time session_start_time_; |
59 base::TimeDelta session_length_limit_; | |
60 | 48 |
61 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter); | 49 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter); |
62 }; | 50 }; |
63 | 51 |
64 } // namespace chromeos | 52 } // namespace chromeos |
65 | 53 |
66 #endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ | 54 #endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ |
OLD | NEW |