Commit a7be6986 authored by rlp@chromium.org's avatar rlp@chromium.org

Adding metrics to track browser launches per primary/secondary profile. Adding...

Adding metrics to track browser launches per primary/secondary profile. Adding metrics to track number of profiles per machine.

BUG=160771,106774
TEST=none

Review URL: http://codereview.chromium.org/8890054

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114088 0039d316-1c4b-4281-b951-d872f2087c98
parent ec99c335
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -370,6 +371,7 @@ bool ProfileManager::AddProfile(Profile* profile) { ...@@ -370,6 +371,7 @@ bool ProfileManager::AddProfile(Profile* profile) {
RegisterProfile(profile, true); RegisterProfile(profile, true);
DoFinalInit(profile, ShouldGoOffTheRecord()); DoFinalInit(profile, ShouldGoOffTheRecord());
ProfileMetrics::LogNumberOfProfiles(this, ProfileMetrics::ADD_PROFILE_EVENT);
return true; return true;
} }
...@@ -659,6 +661,9 @@ void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { ...@@ -659,6 +661,9 @@ void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) {
QueueProfileDirectoryForDeletion(profile_dir); QueueProfileDirectoryForDeletion(profile_dir);
cache.DeleteProfileFromCache(profile_dir); cache.DeleteProfileFromCache(profile_dir);
ProfileMetrics::LogNumberOfProfiles(this,
ProfileMetrics::DELETE_PROFILE_EVENT);
} }
// static // static
...@@ -681,6 +686,8 @@ void ProfileManager::AutoloadProfiles() { ...@@ -681,6 +686,8 @@ void ProfileManager::AutoloadProfiles() {
GetProfile(cache.GetPathOfProfileAtIndex(p)); GetProfile(cache.GetPathOfProfileAtIndex(p));
} }
} }
ProfileMetrics::LogNumberOfProfiles(this,
ProfileMetrics::STARTUP_PROFILE_EVENT);
} }
ProfileManagerWithoutInit::ProfileManagerWithoutInit( ProfileManagerWithoutInit::ProfileManagerWithoutInit(
......
...@@ -11,11 +11,13 @@ ...@@ -11,11 +11,13 @@
#include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "content/public/browser/browser_thread.h"
namespace { namespace {
ProfileMetrics::ProfileType GetProfileType( ProfileMetrics::ProfileType GetProfileType(
FilePath& profile_path) { const FilePath& profile_path) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY; ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY;
ProfileManager* manager = g_browser_process->profile_manager(); ProfileManager* manager = g_browser_process->profile_manager();
FilePath user_data_dir; FilePath user_data_dir;
...@@ -63,6 +65,27 @@ enum ProfileAvatar { ...@@ -63,6 +65,27 @@ enum ProfileAvatar {
NUM_PROFILE_AVATAR_METRICS NUM_PROFILE_AVATAR_METRICS
}; };
void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager,
ProfileEvent startup) {
size_t number_of_profiles =
manager->GetProfileInfoCache().GetNumberOfProfiles();
if (startup == STARTUP_PROFILE_EVENT) {
UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesOnStartup",
number_of_profiles);
} else {
UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesAfterAddOrDelete",
number_of_profiles);
}
}
void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) {
DCHECK(metric < NUM_PROFILE_ADD_METRICS);
UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric,
NUM_PROFILE_ADD_METRICS);
UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER,
NUM_PROFILE_NET_METRICS);
}
void ProfileMetrics::LogProfileAvatarSelection(size_t icon_index) { void ProfileMetrics::LogProfileAvatarSelection(size_t icon_index) {
DCHECK(icon_index < NUM_PROFILE_AVATAR_METRICS); DCHECK(icon_index < NUM_PROFILE_AVATAR_METRICS);
ProfileAvatar icon_name = AVATAR_UNKNOWN; ProfileAvatar icon_name = AVATAR_UNKNOWN;
...@@ -156,18 +179,24 @@ void ProfileMetrics::LogProfileAvatarSelection(size_t icon_index) { ...@@ -156,18 +179,24 @@ void ProfileMetrics::LogProfileAvatarSelection(size_t icon_index) {
NUM_PROFILE_AVATAR_METRICS); NUM_PROFILE_AVATAR_METRICS);
} }
void ProfileMetrics::LogProfileDeleteUser(ProfileNetUserCounts metric) {
DCHECK(metric < NUM_PROFILE_NET_METRICS);
UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", metric,
NUM_PROFILE_NET_METRICS);
}
void ProfileMetrics::LogProfileOpenMethod(ProfileOpen metric) { void ProfileMetrics::LogProfileOpenMethod(ProfileOpen metric) {
DCHECK(metric < NUM_PROFILE_OPEN_METRICS); DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric, UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric,
NUM_PROFILE_OPEN_METRICS); NUM_PROFILE_OPEN_METRICS);
} }
void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) {
DCHECK(metric < NUM_PROFILE_ADD_METRICS); if (metric == GAIA_OPT_IN)
UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, LogProfileAvatarSelection(AVATAR_GAIA);
NUM_PROFILE_ADD_METRICS); UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings",
UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, metric,
NUM_PROFILE_NET_METRICS); NUM_PROFILE_GAIA_METRICS);
} }
void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) { void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) {
...@@ -176,34 +205,26 @@ void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) { ...@@ -176,34 +205,26 @@ void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) {
NUM_PROFILE_OPEN_METRICS); NUM_PROFILE_OPEN_METRICS);
} }
void ProfileMetrics::LogProfileDeleteUser(ProfileNetUserCounts metric) {
DCHECK(metric < NUM_PROFILE_NET_METRICS);
UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", metric,
NUM_PROFILE_NET_METRICS);
}
void ProfileMetrics::LogProfileSyncInfo(ProfileSync metric) { void ProfileMetrics::LogProfileSyncInfo(ProfileSync metric) {
DCHECK(metric < NUM_PROFILE_SYNC_METRICS); DCHECK(metric < NUM_PROFILE_SYNC_METRICS);
UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric, UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric,
NUM_PROFILE_SYNC_METRICS); NUM_PROFILE_SYNC_METRICS);
} }
void ProfileMetrics::LogProfileUpdate(FilePath& profile_path) { void ProfileMetrics::LogProfileLaunch(const FilePath& profile_path) {
UMA_HISTOGRAM_ENUMERATION("Profile.Update", UMA_HISTOGRAM_ENUMERATION("Profile.LaunchBrowser",
GetProfileType(profile_path), GetProfileType(profile_path),
NUM_PROFILE_TYPE_METRICS); NUM_PROFILE_TYPE_METRICS);
} }
void ProfileMetrics::LogProfileSyncSignIn(FilePath& profile_path) { void ProfileMetrics::LogProfileSyncSignIn(const FilePath& profile_path) {
UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn",
GetProfileType(profile_path), GetProfileType(profile_path),
NUM_PROFILE_TYPE_METRICS); NUM_PROFILE_TYPE_METRICS);
} }
void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) { void ProfileMetrics::LogProfileUpdate(const FilePath& profile_path) {
if (metric == GAIA_OPT_IN) UMA_HISTOGRAM_ENUMERATION("Profile.Update",
LogProfileAvatarSelection(AVATAR_GAIA); GetProfileType(profile_path),
UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings", NUM_PROFILE_TYPE_METRICS);
metric,
NUM_PROFILE_GAIA_METRICS);
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
class FilePath; class FilePath;
class ProfileManager;
class ProfileMetrics { class ProfileMetrics {
public: public:
...@@ -61,15 +62,27 @@ class ProfileMetrics { ...@@ -61,15 +62,27 @@ class ProfileMetrics {
NUM_PROFILE_GAIA_METRICS NUM_PROFILE_GAIA_METRICS
}; };
enum ProfileEvent {
STARTUP_PROFILE_EVENT = 0,
ADD_PROFILE_EVENT,
DELETE_PROFILE_EVENT
};
static void LogNumberOfProfiles(ProfileManager* manager,
ProfileEvent startup);
static void LogProfileAddNewUser(ProfileAdd metric);
static void LogProfileAvatarSelection(size_t icon_index); static void LogProfileAvatarSelection(size_t icon_index);
static void LogProfileDeleteUser(ProfileNetUserCounts metric);
static void LogProfileOpenMethod(ProfileOpen metric); static void LogProfileOpenMethod(ProfileOpen metric);
static void LogProfileAddNewUser(ProfileAdd metric); static void LogProfileSwitchGaia(ProfileGaia metric);
static void LogProfileSwitchUser(ProfileOpen metric); static void LogProfileSwitchUser(ProfileOpen metric);
static void LogProfileDeleteUser(ProfileNetUserCounts metric);
static void LogProfileSyncInfo(ProfileSync metric); static void LogProfileSyncInfo(ProfileSync metric);
static void LogProfileUpdate(FilePath& profile_path);
static void LogProfileSyncSignIn(FilePath& profile_path); // These functions should only be called on the UI thread because they hook
static void LogProfileSwitchGaia(ProfileGaia metric); // into g_browser_process through a helper function.
static void LogProfileLaunch(const FilePath& profile_path);
static void LogProfileSyncSignIn(const FilePath& profile_path);
static void LogProfileUpdate(const FilePath& profile_path);
}; };
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/sessions/restore_tab_helper.h" #include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/sessions/session_service.h" #include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/sessions/session_service_factory.h"
...@@ -387,6 +388,9 @@ Browser::Browser(Type type, Profile* profile) ...@@ -387,6 +388,9 @@ Browser::Browser(Type type, Profile* profile)
TabFinder::GetInstance(); TabFinder::GetInstance();
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT);
FilePath profile_path = profile->GetPath();
ProfileMetrics::LogProfileLaunch(profile_path);
} }
Browser::~Browser() { Browser::~Browser() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment