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

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

Issue 2692163003: cros: Add enterprise user session metrics (Closed)
Patch Set: update sparse histogram comment Created 3 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
« no previous file with comments | « chrome/browser/chromeos/session_length_limiter.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/session_length_limiter.h" 5 #include "chrome/browser/chromeos/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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 if (!user_activity_seen_ && ui::UserActivityDetector::Get()) 101 if (!user_activity_seen_ && ui::UserActivityDetector::Get())
102 ui::UserActivityDetector::Get()->AddObserver(this); 102 ui::UserActivityDetector::Get()->AddObserver(this);
103 } 103 }
104 104
105 SessionLengthLimiter::~SessionLengthLimiter() { 105 SessionLengthLimiter::~SessionLengthLimiter() {
106 if (!user_activity_seen_ && ui::UserActivityDetector::Get()) 106 if (!user_activity_seen_ && ui::UserActivityDetector::Get())
107 ui::UserActivityDetector::Get()->RemoveObserver(this); 107 ui::UserActivityDetector::Get()->RemoveObserver(this);
108 } 108 }
109 109
110 base::TimeDelta SessionLengthLimiter::GetSessionDuration() const {
111 if (session_start_time_.is_null())
112 return base::TimeDelta();
113
114 return delegate_->GetCurrentTime() - session_start_time_;
115 }
116
110 void SessionLengthLimiter::OnUserActivity(const ui::Event* event) { 117 void SessionLengthLimiter::OnUserActivity(const ui::Event* event) {
111 if (user_activity_seen_) 118 if (user_activity_seen_)
112 return; 119 return;
113 if (ui::UserActivityDetector::Get()) 120 if (ui::UserActivityDetector::Get())
114 ui::UserActivityDetector::Get()->RemoveObserver(this); 121 ui::UserActivityDetector::Get()->RemoveObserver(this);
115 user_activity_seen_ = true; 122 user_activity_seen_ = true;
116 123
117 PrefService* local_state = g_browser_process->local_state(); 124 PrefService* local_state = g_browser_process->local_state();
118 local_state->SetBoolean(prefs::kSessionUserActivitySeen, true); 125 local_state->SetBoolean(prefs::kSessionUserActivitySeen, true);
119 if (session_start_time_.is_null()) { 126 if (session_start_time_.is_null()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return; 211 return;
205 } 212 }
206 213
207 // Set a timer to log out the user when the session length limit is reached. 214 // Set a timer to log out the user when the session length limit is reached.
208 timer_.reset(new base::OneShotTimer); 215 timer_.reset(new base::OneShotTimer);
209 timer_->Start(FROM_HERE, remaining, delegate_.get(), 216 timer_->Start(FROM_HERE, remaining, delegate_.get(),
210 &SessionLengthLimiter::Delegate::StopSession); 217 &SessionLengthLimiter::Delegate::StopSession);
211 } 218 }
212 219
213 } // namespace chromeos 220 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/session_length_limiter.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698