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

Side by Side Diff: chrome/browser/profiles/profile_metrics.cc

Issue 8890054: Adding metrics to track browser launches per primary/secondary profile. Adding metrics to track n... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/profiles/profile_metrics.h" 5 #include "chrome/browser/profiles/profile_metrics.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profiles/profile_info_cache.h" 11 #include "chrome/browser/profiles/profile_info_cache.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/common/chrome_constants.h" 13 #include "chrome/common/chrome_constants.h"
14 #include "content/public/browser/browser_thread.h"
14 15
15 namespace { 16 namespace {
16 17
17 ProfileMetrics::ProfileType GetProfileType( 18 ProfileMetrics::ProfileType GetProfileType(
18 FilePath& profile_path) { 19 const FilePath& profile_path) {
20 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
19 ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY; 21 ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY;
20 ProfileManager* manager = g_browser_process->profile_manager(); 22 ProfileManager* manager = g_browser_process->profile_manager();
21 FilePath user_data_dir; 23 FilePath user_data_dir;
22 // In unittests, we do not always have a profile_manager so check. 24 // In unittests, we do not always have a profile_manager so check.
23 if (manager) { 25 if (manager) {
24 user_data_dir = manager->user_data_dir(); 26 user_data_dir = manager->user_data_dir();
25 } 27 }
26 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) { 28 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) {
27 metric = ProfileMetrics::ORIGINAL; 29 metric = ProfileMetrics::ORIGINAL;
28 } 30 }
(...skipping 27 matching lines...) Expand all
56 AVATAR_DOG, 58 AVATAR_DOG,
57 AVATAR_HORSE, 59 AVATAR_HORSE,
58 AVATAR_MARGARITA, 60 AVATAR_MARGARITA,
59 AVATAR_NOTE, 61 AVATAR_NOTE,
60 AVATAR_SUN_CLOUD, 62 AVATAR_SUN_CLOUD,
61 AVATAR_UNKNOWN, // 26 63 AVATAR_UNKNOWN, // 26
62 AVATAR_GAIA, // 27 64 AVATAR_GAIA, // 27
63 NUM_PROFILE_AVATAR_METRICS 65 NUM_PROFILE_AVATAR_METRICS
64 }; 66 };
65 67
68 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager,
69 ProfileEvent startup) {
70 size_t number_of_profiles =
71 manager->GetProfileInfoCache().GetNumberOfProfiles();
72 if (startup == STARTUP_PROFILE_EVENT) {
73 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesOnStartup",
74 number_of_profiles);
75 } else {
76 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesAfterAddOrDelete",
jar (doing other things) 2011/12/10 22:07:44 I'm curious, do you really expect the distribution
rpetterson 2011/12/11 08:46:12 Because this is a stat which changes during usage,
77 number_of_profiles);
78 }
79 }
80
81 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) {
82 DCHECK(metric < NUM_PROFILE_ADD_METRICS);
83 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric,
84 NUM_PROFILE_ADD_METRICS);
85 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER,
86 NUM_PROFILE_NET_METRICS);
87 }
88
66 void ProfileMetrics::LogProfileAvatarSelection(size_t icon_index) { 89 void ProfileMetrics::LogProfileAvatarSelection(size_t icon_index) {
67 DCHECK(icon_index < NUM_PROFILE_AVATAR_METRICS); 90 DCHECK(icon_index < NUM_PROFILE_AVATAR_METRICS);
68 ProfileAvatar icon_name = AVATAR_UNKNOWN; 91 ProfileAvatar icon_name = AVATAR_UNKNOWN;
69 switch (icon_index) { 92 switch (icon_index) {
70 case 0: 93 case 0:
71 icon_name = AVATAR_GENERIC; 94 icon_name = AVATAR_GENERIC;
72 break; 95 break;
73 case 1: 96 case 1:
74 icon_name = AVATAR_GENERIC_AQUA; 97 icon_name = AVATAR_GENERIC_AQUA;
75 break; 98 break;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 icon_name = AVATAR_GAIA; 172 icon_name = AVATAR_GAIA;
150 break; 173 break;
151 default: // We should never actually get here. 174 default: // We should never actually get here.
152 NOTREACHED(); 175 NOTREACHED();
153 break; 176 break;
154 } 177 }
155 UMA_HISTOGRAM_ENUMERATION("Profile.Avatar", icon_name, 178 UMA_HISTOGRAM_ENUMERATION("Profile.Avatar", icon_name,
156 NUM_PROFILE_AVATAR_METRICS); 179 NUM_PROFILE_AVATAR_METRICS);
157 } 180 }
158 181
182 void ProfileMetrics::LogProfileDeleteUser(ProfileNetUserCounts metric) {
183 DCHECK(metric < NUM_PROFILE_NET_METRICS);
184 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", metric,
185 NUM_PROFILE_NET_METRICS);
186 }
187
159 void ProfileMetrics::LogProfileOpenMethod(ProfileOpen metric) { 188 void ProfileMetrics::LogProfileOpenMethod(ProfileOpen metric) {
160 DCHECK(metric < NUM_PROFILE_OPEN_METRICS); 189 DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
161 UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric, 190 UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric,
162 NUM_PROFILE_OPEN_METRICS); 191 NUM_PROFILE_OPEN_METRICS);
163 } 192 }
164 193
165 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { 194 void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) {
166 DCHECK(metric < NUM_PROFILE_ADD_METRICS); 195 if (metric == GAIA_OPT_IN)
167 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, 196 LogProfileAvatarSelection(AVATAR_GAIA);
168 NUM_PROFILE_ADD_METRICS); 197 UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings",
169 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, 198 metric,
170 NUM_PROFILE_NET_METRICS); 199 NUM_PROFILE_GAIA_METRICS);
171 } 200 }
172 201
173 void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) { 202 void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) {
174 DCHECK(metric < NUM_PROFILE_OPEN_METRICS); 203 DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
175 UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric, 204 UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric,
176 NUM_PROFILE_OPEN_METRICS); 205 NUM_PROFILE_OPEN_METRICS);
177 } 206 }
178 207
179 void ProfileMetrics::LogProfileDeleteUser(ProfileNetUserCounts metric) {
180 DCHECK(metric < NUM_PROFILE_NET_METRICS);
181 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", metric,
182 NUM_PROFILE_NET_METRICS);
183 }
184
185 void ProfileMetrics::LogProfileSyncInfo(ProfileSync metric) { 208 void ProfileMetrics::LogProfileSyncInfo(ProfileSync metric) {
186 DCHECK(metric < NUM_PROFILE_SYNC_METRICS); 209 DCHECK(metric < NUM_PROFILE_SYNC_METRICS);
187 UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric, 210 UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric,
188 NUM_PROFILE_SYNC_METRICS); 211 NUM_PROFILE_SYNC_METRICS);
189 } 212 }
190 213
191 void ProfileMetrics::LogProfileUpdate(FilePath& profile_path) { 214 void ProfileMetrics::LogProfileLaunch(const FilePath& profile_path) {
192 UMA_HISTOGRAM_ENUMERATION("Profile.Update", 215 UMA_HISTOGRAM_ENUMERATION("Profile.LaunchBrowser",
193 GetProfileType(profile_path), 216 GetProfileType(profile_path),
194 NUM_PROFILE_TYPE_METRICS); 217 NUM_PROFILE_TYPE_METRICS);
195 } 218 }
196 219
197 void ProfileMetrics::LogProfileSyncSignIn(FilePath& profile_path) { 220 void ProfileMetrics::LogProfileSyncSignIn(const FilePath& profile_path) {
198 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", 221 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn",
199 GetProfileType(profile_path), 222 GetProfileType(profile_path),
200 NUM_PROFILE_TYPE_METRICS); 223 NUM_PROFILE_TYPE_METRICS);
201 } 224 }
202 225
203 void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) { 226 void ProfileMetrics::LogProfileUpdate(const FilePath& profile_path) {
204 if (metric == GAIA_OPT_IN) 227 UMA_HISTOGRAM_ENUMERATION("Profile.Update",
205 LogProfileAvatarSelection(AVATAR_GAIA); 228 GetProfileType(profile_path),
206 UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings", 229 NUM_PROFILE_TYPE_METRICS);
207 metric,
208 NUM_PROFILE_GAIA_METRICS);
209 } 230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698