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

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: Remove ununsed include file 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
« no previous file with comments | « chrome/browser/profiles/profile_metrics.h ('k') | chrome/browser/profiles/profile_window.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6dfcf73c00b427620233ea57f637a11da634bcb7 100644
--- a/chrome/browser/profiles/profile_metrics.cc
+++ b/chrome/browser/profiles/profile_metrics.cc
@@ -12,6 +12,7 @@
#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_finder.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/public/browser/browser_thread.h"
@@ -22,6 +23,34 @@ namespace {
const int kMaximumReportedProfileCount = 5;
const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks.
+size_t number_of_profile_switches_ = 0;
+
+// Enum for tracking the state of profiles being switched to.
+enum ProfileOpenState {
+ // Profile being switched to is already opened and has browsers opened.
+ PROFILE_OPENED = 0,
+ // Profile being switched to is already opened but has no browsers opened.
+ PROFILE_OPENED_NO_BROWSER,
+ // Profile being switched to is not opened.
+ PROFILE_UNOPENED
+};
+
+ProfileOpenState GetProfileOpenState(
+ ProfileManager* manager,
+ const base::FilePath& path) {
+ Profile* profile_switched_to = manager->GetProfileByPath(path);
+
+ if (!profile_switched_to) {
+ return PROFILE_UNOPENED;
+ }
+
+ if (chrome::GetTotalBrowserCountForProfile(profile_switched_to) > 0) {
+ return PROFILE_OPENED;
+ }
+
+ return PROFILE_OPENED_NO_BROWSER;
+}
+
ProfileMetrics::ProfileType GetProfileType(
const base::FilePath& profile_path) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -147,7 +176,6 @@ bool ProfileMetrics::CountProfileInformation(ProfileManager* manager,
return true;
}
-
void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) {
ProfileCounts counts;
if (CountProfileInformation(manager, &counts)) {
@@ -163,6 +191,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 +339,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 +384,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,
« no previous file with comments | « chrome/browser/profiles/profile_metrics.h ('k') | chrome/browser/profiles/profile_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698