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

Side by Side Diff: chrome/browser/chromeos/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: Rebased. Not sure why the patch is not applying - bot source out of sync with ToT? 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_SESSION_LENGTH_LIMITER_H_
6 #define CHROME_BROWSER_CHROMEOS_SESSION_LENGTH_LIMITER_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "base/prefs/public/pref_change_registrar.h"
13 #include "base/threading/thread_checker.h"
14 #include "base/time.h"
15 #include "base/timer.h"
16 #include "chrome/browser/profiles/profile_keyed_service.h"
17
18 class PrefService;
19
20 namespace chromeos {
21
22 class SessionLengthLimiter : public ProfileKeyedService {
23 public:
24 class Observer {
25 public:
26 // Notification of the remaining session time, sent by the
27 // SessionLengthLimiter once per second. When there is no limit or the limit
28 // is removed, the notification is invoked one more time with |remaining|
29 // set to |NULL|.
30 virtual void SessionTimeRemainingChanged(
31 const base::TimeDelta* remaining) = 0;
32
33 protected:
34 virtual ~Observer();
35 };
36
37 class Delegate {
38 public:
39 virtual ~Delegate();
40
41 virtual const base::Time GetCurrentTime() const = 0;
42 virtual void Logout() = 0;
Mattias Nissler (ping if slow) 2012/12/12 10:12:57 Call this StopSession() maybe?
bartfab (slow) 2012/12/13 16:22:48 Done.
43 };
44
45 SessionLengthLimiter(Delegate* delegate, PrefService* prefs);
46 virtual ~SessionLengthLimiter();
47
48 // ProfileKeyedService:
49 virtual void Shutdown() OVERRIDE;
50
51 void AddObserver(Observer* observer);
52 void RemoveObserver(Observer* observer);
53
54 private:
55 base::ThreadChecker thread_checker_;
56
57 scoped_ptr<Delegate> delegate_;
58 PrefChangeRegistrar pref_change_registrar_;
Mattias Nissler (ping if slow) 2012/12/12 10:12:57 Might want to use an IntegerPrefMember instead.
bartfab (slow) 2012/12/13 16:22:48 I used a PrefChangeRegistrary because I want to ac
59
60 base::RepeatingTimer<SessionLengthLimiter> repeating_timer_;
61 base::Time session_start_time_;
62 base::TimeDelta session_length_limit_;
63 ObserverList<Observer> observers_;
64
65 void OnSessionLengthLimitChanged();
66
67 void StartTimer();
68 void StopTimer();
69 void TimerTick();
Mattias Nissler (ping if slow) 2012/12/12 10:12:57 These functions could use some commenting on what
bartfab (slow) 2012/12/13 16:22:48 Done.
70
71 scoped_ptr<base::TimeDelta> GetRemainingTime() const;
72
73 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter);
74 };
75
76 } // namespace chromeos
77
78 #endif // CHROME_BROWSER_CHROMEOS_SESSION_LENGTH_LIMITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698