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

Unified Diff: chrome/browser/profiles/profile_metrics.cc

Issue 844193005: Add UMA metrics for profile switching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use existing histogram and fix issues raised by mlerman@ Created 5 years, 11 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
Index: chrome/browser/profiles/profile_metrics.cc
diff --git a/chrome/browser/profiles/profile_metrics.cc b/chrome/browser/profiles/profile_metrics.cc
index 05ac76ba25a4d7c2be066981ab7a7d08eca3e059..31526bb69fb3ba7df543e70e309a58fe370839f7 100644
--- a/chrome/browser/profiles/profile_metrics.cc
+++ b/chrome/browser/profiles/profile_metrics.cc
@@ -12,6 +12,8 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/signin_header_helper.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/public/browser/browser_thread.h"
@@ -22,6 +24,8 @@ namespace {
const int kMaximumReportedProfileCount = 5;
const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks.
+size_t number_of_profile_switches_ = 0;
+
ProfileMetrics::ProfileType GetProfileType(
const base::FilePath& profile_path) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -147,6 +151,24 @@ bool ProfileMetrics::CountProfileInformation(ProfileManager* manager,
return true;
}
+ProfileMetrics::ProfileOpenState ProfileMetrics::GetProfileOpenState(
+ ProfileManager* manager,
+ const base::FilePath& path) {
+ Profile* profile_switched_to = manager->GetProfileByPath(path);
+ ProfileMetrics::ProfileOpenState profile_open_state = PROFILE_UNOPENED;
+
+ if (profile_switched_to) {
+ profile_open_state = PROFILE_OPENED_NO_BROWSER;
+ for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ if (it->profile()->GetOriginalProfile() ==
+ profile_switched_to->GetOriginalProfile()) {
+ profile_open_state = PROFILE_OPENED;
Mike Lerman 2015/01/23 19:46:14 Perhaps you can just return PROFILE_OPENED; no nee
anthonyvd 2015/01/26 16:07:48 Done.
+ break;
+ }
+ }
+ }
+ return profile_open_state;
Mike Lerman 2015/01/23 19:46:14 Flip your condition around, and return early. So w
anthonyvd 2015/01/26 16:07:48 Done.
+}
void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) {
ProfileCounts counts;
@@ -163,6 +185,11 @@ void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) {
}
}
+void ProfileMetrics::LogNumberOfProfileSwitches() {
+ UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSwitches",
+ number_of_profile_switches_);
+}
+
void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) {
ProfileCounts counts;
bool success = CountProfileInformation(manager, &counts);
@@ -306,6 +333,43 @@ void ProfileMetrics::LogProfileOpenMethod(ProfileOpen metric) {
NUM_PROFILE_OPEN_METRICS);
}
+void ProfileMetrics::LogProfileSwitch(
+ ProfileOpen metric,
+ ProfileManager* manager,
+ const base::FilePath& profile_path) {
+ DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
+ ProfileOpenState open_state = GetProfileOpenState(manager, profile_path);
+ switch (open_state) {
+ case PROFILE_OPENED:
+ UMA_HISTOGRAM_ENUMERATION(
+ "Profile.OpenMethod.ToOpenedProfile",
+ metric,
+ NUM_PROFILE_OPEN_METRICS);
+ break;
+ case PROFILE_OPENED_NO_BROWSER:
+ UMA_HISTOGRAM_ENUMERATION(
+ "Profile.OpenMethod.ToOpenedProfileWithoutBrowser",
+ metric,
+ NUM_PROFILE_OPEN_METRICS);
+ break;
+ case PROFILE_UNOPENED:
+ UMA_HISTOGRAM_ENUMERATION(
+ "Profile.OpenMethod.ToUnopenedProfile",
+ metric,
+ NUM_PROFILE_OPEN_METRICS);
+ break;
+ default:
+ // There are no other possible values.
+ NOTREACHED();
+ break;
+ }
+
+ ++number_of_profile_switches_;
+ // The LogOpenMethod histogram aggregates data from profile switches as well
+ // as opening of profile related UI elements.
+ LogProfileOpenMethod(metric);
+}
+
void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) {
if (metric == GAIA_OPT_IN)
LogProfileAvatarSelection(AVATAR_GAIA);
@@ -314,12 +378,6 @@ void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) {
NUM_PROFILE_GAIA_METRICS);
}
-void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) {
- DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
- UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric,
- NUM_PROFILE_OPEN_METRICS);
-}
-
void ProfileMetrics::LogProfileSyncInfo(ProfileSync metric) {
DCHECK(metric < NUM_PROFILE_SYNC_METRICS);
UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric,

Powered by Google App Engine
This is Rietveld 408576698