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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/power/session_length_limiter.h" 5 #include "chrome/browser/chromeos/power/session_length_limiter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void SessionLengthLimiterDelegateImpl::StopSession() { 58 void SessionLengthLimiterDelegateImpl::StopSession() {
59 browser::AttemptUserExit(); 59 browser::AttemptUserExit();
60 } 60 }
61 61
62 } // namespace 62 } // namespace
63 63
64 SessionLengthLimiter::Delegate::~Delegate() { 64 SessionLengthLimiter::Delegate::~Delegate() {
65 } 65 }
66 66
67 // static 67 // static
68 void SessionLengthLimiter::RegisterPrefs(PrefService* local_state) { 68 void SessionLengthLimiter::RegisterPrefs(PrefServiceSimple* local_state) {
69 local_state->RegisterInt64Pref(prefs::kSessionStartTime, 69 local_state->RegisterInt64Pref(prefs::kSessionStartTime, 0);
70 0, 70 local_state->RegisterIntegerPref(prefs::kSessionLengthLimit, 0);
71 PrefService::UNSYNCABLE_PREF);
72 local_state->RegisterIntegerPref(prefs::kSessionLengthLimit,
73 0,
74 PrefService::UNSYNCABLE_PREF);
75 } 71 }
76 72
77 SessionLengthLimiter::SessionLengthLimiter(Delegate* delegate, 73 SessionLengthLimiter::SessionLengthLimiter(Delegate* delegate,
78 bool browser_restarted) 74 bool browser_restarted)
79 : delegate_(delegate ? delegate : new SessionLengthLimiterDelegateImpl) { 75 : delegate_(delegate ? delegate : new SessionLengthLimiterDelegateImpl) {
80 DCHECK(thread_checker_.CalledOnValidThread()); 76 DCHECK(thread_checker_.CalledOnValidThread());
81 77
82 // If this is a user login, set the session start time in local state to the 78 // If this is a user login, set the session start time in local state to the
83 // current time. If this a browser restart after a crash, set the session 79 // current time. If this a browser restart after a crash, set the session
84 // start time only if its current value appears corrupted (value unset, value 80 // start time only if its current value appears corrupted (value unset, value
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 (delegate_->GetCurrentTime() - session_start_time_); 156 (delegate_->GetCurrentTime() - session_start_time_);
161 if (remaining < kZeroTimeDelta) 157 if (remaining < kZeroTimeDelta)
162 remaining = kZeroTimeDelta; 158 remaining = kZeroTimeDelta;
163 159
164 // End the session if the remaining time reaches zero. 160 // End the session if the remaining time reaches zero.
165 if (remaining == base::TimeDelta()) 161 if (remaining == base::TimeDelta())
166 delegate_->StopSession(); 162 delegate_->StopSession();
167 } 163 }
168 164
169 } // namespace chromeos 165 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698