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

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: Upload flaked. 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 // Enforces a session length limit by terminating the session when the limit is
20 // reached.
21 class SessionLengthLimiter {
22 public:
23 class Delegate {
24 public:
25 virtual ~Delegate();
26
27 virtual const base::Time GetCurrentTime() const = 0;
28 virtual void StopSession() = 0;
29 };
30
31 // Registers preferences.
32 static void RegisterPrefs(PrefService* local_state);
33
34 SessionLengthLimiter(Delegate* delegate, bool browser_restarted);
35
36 private:
37 void OnSessionLengthLimitChanged();
38
39 // Starts a timer that periodically checks whether the remaining time has
40 // reached zero.
41 void StartTimer();
42
43 // Stops the timer.
44 void StopTimer();
45
46 // Updates the remaining time, and terminates the session when the time
47 // reaches zero.
48 void UpdateRemainingTime();
49
50 base::ThreadChecker thread_checker_;
51
52 scoped_ptr<Delegate> delegate_;
53 PrefChangeRegistrar pref_change_registrar_;
54
55 scoped_ptr<base::RepeatingTimer<SessionLengthLimiter> > repeating_timer_;
56 base::Time session_start_time_;
57 base::TimeDelta session_length_limit_;
58
59 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter);
60 };
61
62 } // namespace chromeos
63
64 #endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager_impl.cc ('k') | chrome/browser/chromeos/power/session_length_limiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698