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

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

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix double registration in Chrome Frame test. Created 7 years, 10 months 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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/prefs/public/pref_service_base.h" 13 #include "base/prefs/public/pref_service_base.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
16 #include "chrome/browser/prefs/pref_registry_simple.h"
16 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 namespace { 22 namespace {
22 23
23 // The minimum session time limit that can be set. 24 // The minimum session time limit that can be set.
24 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. 25 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds.
25 26
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void SessionLengthLimiterDelegateImpl::StopSession() { 59 void SessionLengthLimiterDelegateImpl::StopSession() {
59 browser::AttemptUserExit(); 60 browser::AttemptUserExit();
60 } 61 }
61 62
62 } // namespace 63 } // namespace
63 64
64 SessionLengthLimiter::Delegate::~Delegate() { 65 SessionLengthLimiter::Delegate::~Delegate() {
65 } 66 }
66 67
67 // static 68 // static
68 void SessionLengthLimiter::RegisterPrefs(PrefServiceSimple* local_state) { 69 void SessionLengthLimiter::RegisterPrefs(PrefRegistrySimple* registry) {
69 local_state->RegisterInt64Pref(prefs::kSessionStartTime, 0); 70 registry->RegisterInt64Pref(prefs::kSessionStartTime, 0);
70 local_state->RegisterIntegerPref(prefs::kSessionLengthLimit, 0); 71 registry->RegisterIntegerPref(prefs::kSessionLengthLimit, 0);
71 } 72 }
72 73
73 SessionLengthLimiter::SessionLengthLimiter(Delegate* delegate, 74 SessionLengthLimiter::SessionLengthLimiter(Delegate* delegate,
74 bool browser_restarted) 75 bool browser_restarted)
75 : delegate_(delegate ? delegate : new SessionLengthLimiterDelegateImpl) { 76 : delegate_(delegate ? delegate : new SessionLengthLimiterDelegateImpl) {
76 DCHECK(thread_checker_.CalledOnValidThread()); 77 DCHECK(thread_checker_.CalledOnValidThread());
77 78
78 // If this is a user login, set the session start time in local state to the 79 // If this is a user login, set the session start time in local state to the
79 // current time. If this a browser restart after a crash, set the session 80 // current time. If this a browser restart after a crash, set the session
80 // start time only if its current value appears corrupted (value unset, value 81 // start time only if its current value appears corrupted (value unset, value
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 (delegate_->GetCurrentTime() - session_start_time_); 157 (delegate_->GetCurrentTime() - session_start_time_);
157 if (remaining < kZeroTimeDelta) 158 if (remaining < kZeroTimeDelta)
158 remaining = kZeroTimeDelta; 159 remaining = kZeroTimeDelta;
159 160
160 // End the session if the remaining time reaches zero. 161 // End the session if the remaining time reaches zero.
161 if (remaining == base::TimeDelta()) 162 if (remaining == base::TimeDelta())
162 delegate_->StopSession(); 163 delegate_->StopSession();
163 } 164 }
164 165
165 } // namespace chromeos 166 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698