Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1030)

Side by Side Diff: chrome/browser/chromeos/power/session_length_limiter.h

Issue 11499012: Add policy for limiting the session length (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. SessionLengthLimiter is no longer a PKS. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 {
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 base::RepeatingTimer<SessionLengthLimiter> repeating_timer_;
41 base::Time session_start_time_;
42 base::TimeDelta session_length_limit_;
43
44 void OnSessionLengthLimitChanged();
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698