| OLD | NEW |
| 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 Loading... |
| 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(PrefServiceSimple* local_state) { | 68 void SessionLengthLimiter::RegisterPrefs(PrefRegistrarSimple* local_state) { |
| 69 local_state->RegisterInt64Pref(prefs::kSessionStartTime, 0); | 69 local_state->RegisterInt64Pref(prefs::kSessionStartTime, 0); |
| 70 local_state->RegisterIntegerPref(prefs::kSessionLengthLimit, 0); | 70 local_state->RegisterIntegerPref(prefs::kSessionLengthLimit, 0); |
| 71 } | 71 } |
| 72 | 72 |
| 73 SessionLengthLimiter::SessionLengthLimiter(Delegate* delegate, | 73 SessionLengthLimiter::SessionLengthLimiter(Delegate* delegate, |
| 74 bool browser_restarted) | 74 bool browser_restarted) |
| 75 : delegate_(delegate ? delegate : new SessionLengthLimiterDelegateImpl) { | 75 : delegate_(delegate ? delegate : new SessionLengthLimiterDelegateImpl) { |
| 76 DCHECK(thread_checker_.CalledOnValidThread()); | 76 DCHECK(thread_checker_.CalledOnValidThread()); |
| 77 | 77 |
| 78 // 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 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 (delegate_->GetCurrentTime() - session_start_time_); | 156 (delegate_->GetCurrentTime() - session_start_time_); |
| 157 if (remaining < kZeroTimeDelta) | 157 if (remaining < kZeroTimeDelta) |
| 158 remaining = kZeroTimeDelta; | 158 remaining = kZeroTimeDelta; |
| 159 | 159 |
| 160 // End the session if the remaining time reaches zero. | 160 // End the session if the remaining time reaches zero. |
| 161 if (remaining == base::TimeDelta()) | 161 if (remaining == base::TimeDelta()) |
| 162 delegate_->StopSession(); | 162 delegate_->StopSession(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace chromeos | 165 } // namespace chromeos |
| OLD | NEW |