blob: 6abaea09102d87839a39bb2af99131df6540f091 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_
#define CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/public/pref_change_registrar.h"
#include "base/threading/thread_checker.h"
#include "base/time.h"
#include "base/timer.h"
class PrefService;
class PrefRegistrySimple;
namespace chromeos {
// Enforces a session length limit by terminating the session when the limit is
// reached.
class SessionLengthLimiter {
public:
class Delegate {
public:
virtual ~Delegate();
virtual const base::Time GetCurrentTime() const = 0;
virtual void StopSession() = 0;
};
// Registers preferences.
static void RegisterPrefs(PrefRegistrySimple* registry);
SessionLengthLimiter(Delegate* delegate, bool browser_restarted);
~SessionLengthLimiter();
private:
void OnSessionLengthLimitChanged();
base::ThreadChecker thread_checker_;
scoped_ptr<Delegate> delegate_;
PrefChangeRegistrar pref_change_registrar_;
scoped_ptr<base::OneShotTimer<SessionLengthLimiter::Delegate> > timer_;
base::Time session_start_time_;
DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_
|