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

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

Issue 593243002: Profile_Metrics integration with Keystone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Google Updater handles unsigned values Created 5 years, 10 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/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
17 #include "chrome/installer/util/google_update_settings.h" 17 #include "chrome/installer/util/google_update_settings.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/user_metrics.h" 19 #include "content/public/browser/user_metrics.h"
20 20
21 namespace { 21 namespace {
22 22
23 #if defined(OS_WIN) || defined(OS_MACOSX)
23 const int kMaximumReportedProfileCount = 5; 24 const int kMaximumReportedProfileCount = 5;
25 #endif
26
24 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks. 27 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks.
25 28
26 size_t number_of_profile_switches_ = 0; 29 size_t number_of_profile_switches_ = 0;
27 30
28 // Enum for tracking the state of profiles being switched to. 31 // Enum for tracking the state of profiles being switched to.
29 enum ProfileOpenState { 32 enum ProfileOpenState {
30 // Profile being switched to is already opened and has browsers opened. 33 // Profile being switched to is already opened and has browsers opened.
31 PROFILE_OPENED = 0, 34 PROFILE_OPENED = 0,
32 // Profile being switched to is already opened but has no browsers opened. 35 // Profile being switched to is already opened but has no browsers opened.
33 PROFILE_OPENED_NO_BROWSER, 36 PROFILE_OPENED_NO_BROWSER,
(...skipping 26 matching lines...) Expand all
60 // In unittests, we do not always have a profile_manager so check. 63 // In unittests, we do not always have a profile_manager so check.
61 if (manager) { 64 if (manager) {
62 user_data_dir = manager->user_data_dir(); 65 user_data_dir = manager->user_data_dir();
63 } 66 }
64 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) { 67 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) {
65 metric = ProfileMetrics::ORIGINAL; 68 metric = ProfileMetrics::ORIGINAL;
66 } 69 }
67 return metric; 70 return metric;
68 } 71 }
69 72
70 void UpdateReportedOSProfileStatistics(int active, int signedin) {
71 #if defined(OS_WIN)
72 GoogleUpdateSettings::UpdateProfileCounts(active, signedin);
73 #endif
74 }
75
76 void LogLockedProfileInformation(ProfileManager* manager) { 73 void LogLockedProfileInformation(ProfileManager* manager) {
77 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); 74 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache();
78 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); 75 size_t number_of_profiles = info_cache.GetNumberOfProfiles();
79 76
80 base::Time now = base::Time::Now(); 77 base::Time now = base::Time::Now();
81 const int kMinutesInProfileValidDuration = 78 const int kMinutesInProfileValidDuration =
82 base::TimeDelta::FromDays(28).InMinutes(); 79 base::TimeDelta::FromDays(28).InMinutes();
83 for (size_t i = 0; i < number_of_profiles; ++i) { 80 for (size_t i = 0; i < number_of_profiles; ++i) {
84 // Find when locked profiles were locked 81 // Find when locked profiles were locked
85 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) { 82 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 counts->gaia_icon++; 167 counts->gaia_icon++;
171 if (info_cache.ProfileIsAuthErrorAtIndex(i)) 168 if (info_cache.ProfileIsAuthErrorAtIndex(i))
172 counts->auth_errors++; 169 counts->auth_errors++;
173 } 170 }
174 } 171 }
175 } 172 }
176 return true; 173 return true;
177 } 174 }
178 175
179 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { 176 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) {
177 #if defined(OS_WIN) || defined(OS_MACOSX)
180 ProfileCounts counts; 178 ProfileCounts counts;
181 if (CountProfileInformation(manager, &counts)) { 179 if (CountProfileInformation(manager, &counts)) {
182 int limited_total = counts.total; 180 size_t limited_total = counts.total;
183 int limited_signedin = counts.signedin; 181 size_t limited_signedin = counts.signedin;
184 if (limited_total > kMaximumReportedProfileCount) { 182 if (limited_total > kMaximumReportedProfileCount) {
185 limited_total = kMaximumReportedProfileCount + 1; 183 limited_total = kMaximumReportedProfileCount + 1;
186 limited_signedin = 184 limited_signedin =
187 (int)((float)(counts.signedin * limited_total) 185 (int)((float)(counts.signedin * limited_total)
188 / counts.total + 0.5); 186 / counts.total + 0.5);
189 } 187 }
190 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); 188 UpdateReportedOSProfileStatistics(limited_total, limited_signedin);
191 } 189 }
190 #endif
192 } 191 }
193 192
194 void ProfileMetrics::LogNumberOfProfileSwitches() { 193 void ProfileMetrics::LogNumberOfProfileSwitches() {
195 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSwitches", 194 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSwitches",
196 number_of_profile_switches_); 195 number_of_profile_switches_);
197 } 196 }
198 197
198 // The MACOS implementation of this function is in profile_metrics_mac.mm.
Mark Mentovai 2015/02/25 21:38:06 Mac OS X or OS_MACOSX.
Mike Lerman 2015/02/25 21:45:56 OS_MACOSX :)
199 #if defined(OS_WIN)
200 void ProfileMetrics::UpdateReportedOSProfileStatistics(
201 size_t active, size_t signedin) {
202 GoogleUpdateSettings::UpdateProfileCounts(active, signedin);
203 }
204 #endif
205
199 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { 206 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) {
200 ProfileCounts counts; 207 ProfileCounts counts;
201 bool success = CountProfileInformation(manager, &counts); 208 bool success = CountProfileInformation(manager, &counts);
202 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); 209 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total);
203 210
204 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. 211 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests.
205 if (success) { 212 if (success) {
206 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", 213 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles",
207 counts.supervised); 214 counts.supervised);
208 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", 215 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles",
209 100 * counts.supervised / counts.total); 216 100 * counts.supervised / counts.total);
210 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", 217 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles",
211 counts.signedin); 218 counts.signedin);
212 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles", 219 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles",
213 counts.unused); 220 counts.unused);
214 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons", 221 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons",
215 counts.gaia_icon); 222 counts.gaia_icon);
216 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesWithAuthErrors", 223 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesWithAuthErrors",
217 counts.auth_errors); 224 counts.auth_errors);
218 225
219 LogLockedProfileInformation(manager); 226 LogLockedProfileInformation(manager);
227
228 #if defined(OS_WIN) || defined(OS_MACOSX)
220 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); 229 UpdateReportedOSProfileStatistics(counts.total, counts.signedin);
230 #endif
221 } 231 }
222 } 232 }
223 233
224 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { 234 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) {
225 DCHECK(metric < NUM_PROFILE_ADD_METRICS); 235 DCHECK(metric < NUM_PROFILE_ADD_METRICS);
226 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, 236 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric,
227 NUM_PROFILE_ADD_METRICS); 237 NUM_PROFILE_ADD_METRICS);
228 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, 238 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER,
229 NUM_PROFILE_NET_METRICS); 239 NUM_PROFILE_NET_METRICS);
230 } 240 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", 538 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn",
529 GetProfileType(profile_path), 539 GetProfileType(profile_path),
530 NUM_PROFILE_TYPE_METRICS); 540 NUM_PROFILE_TYPE_METRICS);
531 } 541 }
532 542
533 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { 543 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) {
534 UMA_HISTOGRAM_ENUMERATION("Profile.Update", 544 UMA_HISTOGRAM_ENUMERATION("Profile.Update",
535 GetProfileType(profile_path), 545 GetProfileType(profile_path),
536 NUM_PROFILE_TYPE_METRICS); 546 NUM_PROFILE_TYPE_METRICS);
537 } 547 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_metrics.h ('k') | chrome/browser/profiles/profile_metrics_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698