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

Side by Side 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: 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 unified diff | Download patch
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/files/file_path.h" 7 #include "base/files/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.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_info_cache.h" 12 #include "chrome/browser/profiles/profile_info_cache.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/signin/signin_header_helper.h" 14 #include "chrome/browser/signin/signin_header_helper.h"
15 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
16 #include "chrome/installer/util/google_update_settings.h" 16 #include "chrome/installer/util/google_update_settings.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/user_metrics.h" 18 #include "content/public/browser/user_metrics.h"
19 19
20 namespace { 20 namespace {
21 21
22 const int kMaximumReportedProfileCount = 5; 22 const int kMaximumReportedProfileCount = 5;
23 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks. 23 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks.
24 24
25 size_t number_of_switches_ = 0;
Mike Lerman 2015/01/21 20:58:02 call this "number_of_profile_switches_" please.
anthonyvd 2015/01/23 16:01:30 Done.
26
25 ProfileMetrics::ProfileType GetProfileType( 27 ProfileMetrics::ProfileType GetProfileType(
26 const base::FilePath& profile_path) { 28 const base::FilePath& profile_path) {
27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
28 ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY; 30 ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY;
29 ProfileManager* manager = g_browser_process->profile_manager(); 31 ProfileManager* manager = g_browser_process->profile_manager();
30 base::FilePath user_data_dir; 32 base::FilePath user_data_dir;
31 // In unittests, we do not always have a profile_manager so check. 33 // In unittests, we do not always have a profile_manager so check.
32 if (manager) { 34 if (manager) {
33 user_data_dir = manager->user_data_dir(); 35 user_data_dir = manager->user_data_dir();
34 } 36 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (limited_total > kMaximumReportedProfileCount) { 158 if (limited_total > kMaximumReportedProfileCount) {
157 limited_total = kMaximumReportedProfileCount + 1; 159 limited_total = kMaximumReportedProfileCount + 1;
158 limited_signedin = 160 limited_signedin =
159 (int)((float)(counts.signedin * limited_total) 161 (int)((float)(counts.signedin * limited_total)
160 / counts.total + 0.5); 162 / counts.total + 0.5);
161 } 163 }
162 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); 164 UpdateReportedOSProfileStatistics(limited_total, limited_signedin);
163 } 165 }
164 } 166 }
165 167
168 void ProfileMetrics::IncrementNumberOfSwitches() {
169 ++number_of_switches_;
Mike Lerman 2015/01/21 20:58:03 I don't think this needs to be a separate method;
anthonyvd 2015/01/23 16:01:31 Done.
170 }
171
172 void ProfileMetrics::LogNumberOfSwitches() {
173 UMA_HISTOGRAM_COUNTS_100("Profile.NumberofSwitches", number_of_switches_);
Mike Lerman 2015/01/21 20:58:03 nit: NumberOfSwitches (capital O)
anthonyvd 2015/01/23 16:01:31 Done.
174 }
175
166 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { 176 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) {
167 ProfileCounts counts; 177 ProfileCounts counts;
168 bool success = CountProfileInformation(manager, &counts); 178 bool success = CountProfileInformation(manager, &counts);
169 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); 179 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total);
170 180
171 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. 181 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests.
172 if (success) { 182 if (success) {
173 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", 183 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles",
174 counts.supervised); 184 counts.supervised);
175 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", 185 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles",
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", PROFILE_DELETED, 309 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", PROFILE_DELETED,
300 NUM_PROFILE_NET_METRICS); 310 NUM_PROFILE_NET_METRICS);
301 } 311 }
302 312
303 void ProfileMetrics::LogProfileOpenMethod(ProfileOpen metric) { 313 void ProfileMetrics::LogProfileOpenMethod(ProfileOpen metric) {
304 DCHECK(metric < NUM_PROFILE_OPEN_METRICS); 314 DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
305 UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric, 315 UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric,
306 NUM_PROFILE_OPEN_METRICS); 316 NUM_PROFILE_OPEN_METRICS);
307 } 317 }
308 318
319 void ProfileMetrics::LogProfileSwitch(
320 ProfileOpen metric,
321 bool profile_already_open) {
322 DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
323 if(profile_already_open) {
324 UMA_HISTOGRAM_ENUMERATION("Profile.ProfileSwitch.ToOpenedProfile",
325 metric,
326 NUM_PROFILE_OPEN_METRICS);
327 } else {
328 UMA_HISTOGRAM_ENUMERATION("Profile.ProfileSwitch.ToUnopenedProfile",
329 metric,
330 NUM_PROFILE_OPEN_METRICS);
331 }
332 UMA_HISTOGRAM_ENUMERATION("Profile.ProfileSwitch",
Mike Lerman 2015/01/21 20:58:02 We really try not to rename histograms - doing so
anthonyvd 2015/01/21 21:12:18 So I preserved the Profile.OpenMethod histogram an
Mike Lerman 2015/01/21 21:24:18 Ah, I understand. I'm leery of duplicating the dat
anthonyvd 2015/01/23 16:01:31 Done.
333 metric,
334 NUM_PROFILE_OPEN_METRICS);
335
336 IncrementNumberOfSwitches();
337 //The LogOpenMethod histogram aggregates data from profile switches
338 //as well as opening of profile related UI elements
Mike Lerman 2015/01/21 21:24:18 nit: Add spaces after the //'s, and end it all wit
anthonyvd 2015/01/23 16:01:30 Done.
339 LogProfileOpenMethod(metric);
340 }
341
309 void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) { 342 void ProfileMetrics::LogProfileSwitchGaia(ProfileGaia metric) {
310 if (metric == GAIA_OPT_IN) 343 if (metric == GAIA_OPT_IN)
311 LogProfileAvatarSelection(AVATAR_GAIA); 344 LogProfileAvatarSelection(AVATAR_GAIA);
312 UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings", 345 UMA_HISTOGRAM_ENUMERATION("Profile.SwitchGaiaPhotoSettings",
313 metric, 346 metric,
314 NUM_PROFILE_GAIA_METRICS); 347 NUM_PROFILE_GAIA_METRICS);
315 } 348 }
316 349
317 void ProfileMetrics::LogProfileSwitchUser(ProfileOpen metric) {
318 DCHECK(metric < NUM_PROFILE_OPEN_METRICS);
319 UMA_HISTOGRAM_ENUMERATION("Profile.OpenMethod", metric,
320 NUM_PROFILE_OPEN_METRICS);
321 }
322
323 void ProfileMetrics::LogProfileSyncInfo(ProfileSync metric) { 350 void ProfileMetrics::LogProfileSyncInfo(ProfileSync metric) {
324 DCHECK(metric < NUM_PROFILE_SYNC_METRICS); 351 DCHECK(metric < NUM_PROFILE_SYNC_METRICS);
325 UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric, 352 UMA_HISTOGRAM_ENUMERATION("Profile.SyncCustomize", metric,
326 NUM_PROFILE_SYNC_METRICS); 353 NUM_PROFILE_SYNC_METRICS);
327 } 354 }
328 355
329 void ProfileMetrics::LogProfileAuthResult(ProfileAuth metric) { 356 void ProfileMetrics::LogProfileAuthResult(ProfileAuth metric) {
330 UMA_HISTOGRAM_ENUMERATION("Profile.AuthResult", metric, 357 UMA_HISTOGRAM_ENUMERATION("Profile.AuthResult", metric,
331 NUM_PROFILE_AUTH_METRICS); 358 NUM_PROFILE_AUTH_METRICS);
332 } 359 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", 491 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn",
465 GetProfileType(profile_path), 492 GetProfileType(profile_path),
466 NUM_PROFILE_TYPE_METRICS); 493 NUM_PROFILE_TYPE_METRICS);
467 } 494 }
468 495
469 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { 496 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) {
470 UMA_HISTOGRAM_ENUMERATION("Profile.Update", 497 UMA_HISTOGRAM_ENUMERATION("Profile.Update",
471 GetProfileType(profile_path), 498 GetProfileType(profile_path),
472 NUM_PROFILE_TYPE_METRICS); 499 NUM_PROFILE_TYPE_METRICS);
473 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698