Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/prefs/public/pref_change_registrar.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "base/time.h" | |
| 13 #include "base/timer.h" | |
| 14 | |
| 15 class PrefService; | |
| 16 | |
| 17 namespace chromeos { | |
| 18 | |
| 19 class SessionLengthLimiter { | |
|
Nikita (slow)
2012/12/14 13:07:43
nit: Class level comment about purpose and usage o
bartfab (slow)
2012/12/14 17:23:26
Done.
| |
| 20 public: | |
| 21 class Delegate { | |
| 22 public: | |
| 23 virtual ~Delegate(); | |
| 24 | |
| 25 virtual const base::Time GetCurrentTime() const = 0; | |
| 26 virtual void StopSession() = 0; | |
| 27 }; | |
| 28 | |
| 29 // Registers preferences. | |
| 30 static void RegisterPrefs(PrefService* local_state); | |
| 31 | |
| 32 SessionLengthLimiter(Delegate* delegate, bool browser_restarted); | |
| 33 | |
| 34 private: | |
| 35 base::ThreadChecker thread_checker_; | |
| 36 | |
| 37 scoped_ptr<Delegate> delegate_; | |
| 38 PrefChangeRegistrar pref_change_registrar_; | |
| 39 | |
| 40 scoped_ptr<base::RepeatingTimer<SessionLengthLimiter> > repeating_timer_; | |
| 41 base::Time session_start_time_; | |
| 42 base::TimeDelta session_length_limit_; | |
| 43 | |
| 44 void OnSessionLengthLimitChanged(); | |
|
Nikita (slow)
2012/12/14 13:07:43
nit: Methods should go first.
bartfab (slow)
2012/12/14 17:23:26
Done.
| |
| 45 | |
| 46 // Starts a timer that sends out a notification with the remaining session | |
| 47 // time once per second and terminates the session when the time reaches zero. | |
| 48 void StartTimer(); | |
| 49 | |
| 50 // Stops the timer and sends out a final notification that there no longer is | |
| 51 // a session length limit. | |
| 52 void StopTimer(); | |
| 53 | |
| 54 // Updates the remaining time, sends out a notification and terminates the | |
| 55 // session when the time reaches zero. | |
| 56 void UpdateRemainingTime(); | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter); | |
| 59 }; | |
| 60 | |
| 61 } // namespace chromeos | |
| 62 | |
| 63 #endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_ | |
| OLD | NEW |