diff options
author | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-12 21:53:57 +0000 |
---|---|---|
committer | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-12 21:53:57 +0000 |
commit | a7be698679e55d0f3dea967dc40755bc7f369915 (patch) | |
tree | 0de949f2f138ce02b976439a744c1f386c306073 /chrome | |
parent | ec99c3352fdec4248da487b91f6cc52ddd74fd5a (diff) | |
download | chromium_src-a7be698679e55d0f3dea967dc40755bc7f369915.zip chromium_src-a7be698679e55d0f3dea967dc40755bc7f369915.tar.gz chromium_src-a7be698679e55d0f3dea967dc40755bc7f369915.tar.bz2 |
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
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/profiles/profile_manager.cc | 7 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_metrics.cc | 65 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_metrics.h | 23 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 4 |
4 files changed, 72 insertions, 27 deletions
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index 1a4f6f9..509c842 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -20,6 +20,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.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/sync/profile_sync_service.h" #include "chrome/browser/ui/browser.h" @@ -370,6 +371,7 @@ bool ProfileManager::AddProfile(Profile* profile) { RegisterProfile(profile, true); DoFinalInit(profile, ShouldGoOffTheRecord()); + ProfileMetrics::LogNumberOfProfiles(this, ProfileMetrics::ADD_PROFILE_EVENT); return true; } @@ -659,6 +661,9 @@ void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { QueueProfileDirectoryForDeletion(profile_dir); cache.DeleteProfileFromCache(profile_dir); + + ProfileMetrics::LogNumberOfProfiles(this, + ProfileMetrics::DELETE_PROFILE_EVENT); } // static @@ -681,6 +686,8 @@ void ProfileManager::AutoloadProfiles() { GetProfile(cache.GetPathOfProfileAtIndex(p)); } } + ProfileMetrics::LogNumberOfProfiles(this, + ProfileMetrics::STARTUP_PROFILE_EVENT); } ProfileManagerWithoutInit::ProfileManagerWithoutInit( diff --git a/chrome/browser/profiles/profile_metrics.cc b/chrome/browser/profiles/profile_metrics.cc index a178783..450cb90 100644 --- a/chrome/browser/profiles/profile_metrics.cc +++ b/chrome/browser/profiles/profile_metrics.cc @@ -11,11 +11,13 @@ #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/chrome_constants.h" +#include "content/public/browser/browser_thread.h" namespace { ProfileMetrics::ProfileType GetProfileType( - FilePath& profile_path) { + const FilePath& profile_path) { + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY; ProfileManager* manager = g_browser_process->profile_manager(); FilePath user_data_dir; @@ -63,6 +65,27 @@ enum ProfileAvatar { 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) { DCHECK(icon_index < NUM_PROFILE_AVATAR_METRICS); ProfileAvatar icon_name = AVATAR_UNKNOWN; @@ -156,18 +179,24 @@ void ProfileMetrics::LogProfileAvatarSelection(size_t icon_index) { 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) { DCHECK(metric < NUM_PROFILE_OPEN_METRICS); UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric, NUM_PROFILE_OPEN_METRICS); } -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::LogProfileSwitchGaia(ProfileGaia metric) { + if (metric == GAIA_OPT_IN) + LogProfileAvatarSelection(AVATAR_GAIA); + UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings", + metric, + NUM_PROFILE_GAIA_METRICS); } void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) { @@ -176,34 +205,26 @@ void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) { 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) { DCHECK(metric < NUM_PROFILE_SYNC_METRICS); UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric, NUM_PROFILE_SYNC_METRICS); } -void ProfileMetrics::LogProfileUpdate(FilePath& profile_path) { - UMA_HISTOGRAM_ENUMERATION("Profile.Update", +void ProfileMetrics::LogProfileLaunch(const FilePath& profile_path) { + UMA_HISTOGRAM_ENUMERATION("Profile.LaunchBrowser", GetProfileType(profile_path), NUM_PROFILE_TYPE_METRICS); } -void ProfileMetrics::LogProfileSyncSignIn(FilePath& profile_path) { +void ProfileMetrics::LogProfileSyncSignIn(const FilePath& profile_path) { UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", GetProfileType(profile_path), NUM_PROFILE_TYPE_METRICS); } -void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) { - if (metric == GAIA_OPT_IN) - LogProfileAvatarSelection(AVATAR_GAIA); - UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings", - metric, - NUM_PROFILE_GAIA_METRICS); +void ProfileMetrics::LogProfileUpdate(const FilePath& profile_path) { + UMA_HISTOGRAM_ENUMERATION("Profile.Update", + GetProfileType(profile_path), + NUM_PROFILE_TYPE_METRICS); } diff --git a/chrome/browser/profiles/profile_metrics.h b/chrome/browser/profiles/profile_metrics.h index 22c4b2e..7f1b6d0 100644 --- a/chrome/browser/profiles/profile_metrics.h +++ b/chrome/browser/profiles/profile_metrics.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" class FilePath; +class ProfileManager; class ProfileMetrics { public: @@ -61,15 +62,27 @@ class ProfileMetrics { 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 LogProfileDeleteUser(ProfileNetUserCounts metric); static void LogProfileOpenMethod(ProfileOpen metric); - static void LogProfileAddNewUser(ProfileAdd metric); + static void LogProfileSwitchGaia(ProfileGaia metric); static void LogProfileSwitchUser(ProfileOpen metric); - static void LogProfileDeleteUser(ProfileNetUserCounts metric); static void LogProfileSyncInfo(ProfileSync metric); - static void LogProfileUpdate(FilePath& profile_path); - static void LogProfileSyncSignIn(FilePath& profile_path); - static void LogProfileSwitchGaia(ProfileGaia metric); + + // These functions should only be called on the UI thread because they hook + // 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); }; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 451ba5b..1bd1fe1 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -76,6 +76,7 @@ #include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/profiles/profile.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/session_service.h" #include "chrome/browser/sessions/session_service_factory.h" @@ -387,6 +388,9 @@ Browser::Browser(Type type, Profile* profile) TabFinder::GetInstance(); UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_INIT); + + FilePath profile_path = profile->GetPath(); + ProfileMetrics::LogProfileLaunch(profile_path); } Browser::~Browser() { |