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

Unified 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: Fix include order. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/power/session_length_limiter.h
diff --git a/chrome/browser/chromeos/power/session_length_limiter.h b/chrome/browser/chromeos/power/session_length_limiter.h
new file mode 100644
index 0000000000000000000000000000000000000000..6312d8eedc0306d2df7643f3e2e82180530a65ae
--- /dev/null
+++ b/chrome/browser/chromeos/power/session_length_limiter.h
@@ -0,0 +1,63 @@
+// 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;
+
+namespace chromeos {
+
+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.
+ public:
+ class Delegate {
+ public:
+ virtual ~Delegate();
+
+ virtual const base::Time GetCurrentTime() const = 0;
+ virtual void StopSession() = 0;
+ };
+
+ // Registers preferences.
+ static void RegisterPrefs(PrefService* local_state);
+
+ SessionLengthLimiter(Delegate* delegate, bool browser_restarted);
+
+ private:
+ base::ThreadChecker thread_checker_;
+
+ scoped_ptr<Delegate> delegate_;
+ PrefChangeRegistrar pref_change_registrar_;
+
+ scoped_ptr<base::RepeatingTimer<SessionLengthLimiter> > repeating_timer_;
+ base::Time session_start_time_;
+ base::TimeDelta session_length_limit_;
+
+ void OnSessionLengthLimitChanged();
Nikita (slow) 2012/12/14 13:07:43 nit: Methods should go first.
bartfab (slow) 2012/12/14 17:23:26 Done.
+
+ // Starts a timer that sends out a notification with the remaining session
+ // time once per second and terminates the session when the time reaches zero.
+ void StartTimer();
+
+ // Stops the timer and sends out a final notification that there no longer is
+ // a session length limit.
+ void StopTimer();
+
+ // Updates the remaining time, sends out a notification and terminates the
+ // session when the time reaches zero.
+ void UpdateRemainingTime();
+
+ DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_POWER_SESSION_LENGTH_LIMITER_H_

Powered by Google App Engine
This is Rietveld 408576698