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

Unified Diff: components/signin/core/browser/signin_manager.cc

Issue 459853002: UMA track signed in duration at signout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compiler issue Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/signin/signin_manager_factory.cc ('k') | components/signin/core/common/signin_pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/signin/core/browser/signin_manager.cc
diff --git a/components/signin/core/browser/signin_manager.cc b/components/signin/core/browser/signin_manager.cc
index 9c68eb98915ca9b5c5c0d78a990e7c1bd2ac50b0..ea1cc06fdf00e2fe5e9f88fb444eda57103d5d0e 100644
--- a/components/signin/core/browser/signin_manager.cc
+++ b/components/signin/core/browser/signin_manager.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -201,13 +202,24 @@ void SigninManager::SignOut(
ClearTransientSigninData();
const std::string username = GetAuthenticatedUsername();
+ const base::Time signin_time =
+ base::Time::FromInternalValue(
+ client_->GetPrefs()->GetInt64(prefs::kSignedInTime));
clear_authenticated_username();
client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
+ client_->GetPrefs()->ClearPref(prefs::kSignedInTime);
client_->ClearSigninScopedDeviceId();
// Erase (now) stale information from AboutSigninInternals.
NotifyDiagnosticsObservers(USERNAME, "");
+ // Determine the duration the user was logged in and log that to UMA.
+ if (!signin_time.is_null()) {
+ base::TimeDelta signed_in_duration = base::Time::Now() - signin_time;
+ UMA_HISTOGRAM_COUNTS("Signin.SignedInDurationBeforeSignout",
+ signed_in_duration.InMinutes());
+ }
+
// Revoke all tokens before sending signed_out notification, because there
// may be components that don't listen for token service events when the
// profile is not connected to an account.
@@ -353,6 +365,8 @@ void SigninManager::OnExternalSigninCompleted(const std::string& username) {
}
void SigninManager::OnSignedIn(const std::string& username) {
+ client_->GetPrefs()->SetInt64(prefs::kSignedInTime,
+ base::Time::Now().ToInternalValue());
SetAuthenticatedUsername(username);
possibly_invalid_username_.clear();
« no previous file with comments | « chrome/browser/signin/signin_manager_factory.cc ('k') | components/signin/core/common/signin_pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698