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

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: Better creation of KSReportingAttributes 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"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // In unittests, we do not always have a profile_manager so check. 60 // In unittests, we do not always have a profile_manager so check.
61 if (manager) { 61 if (manager) {
62 user_data_dir = manager->user_data_dir(); 62 user_data_dir = manager->user_data_dir();
63 } 63 }
64 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) { 64 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) {
65 metric = ProfileMetrics::ORIGINAL; 65 metric = ProfileMetrics::ORIGINAL;
66 } 66 }
67 return metric; 67 return metric;
68 } 68 }
69 69
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) { 70 void LogLockedProfileInformation(ProfileManager* manager) {
77 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); 71 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache();
78 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); 72 size_t number_of_profiles = info_cache.GetNumberOfProfiles();
79 73
80 base::Time now = base::Time::Now(); 74 base::Time now = base::Time::Now();
81 const int kMinutesInProfileValidDuration = 75 const int kMinutesInProfileValidDuration =
82 base::TimeDelta::FromDays(28).InMinutes(); 76 base::TimeDelta::FromDays(28).InMinutes();
83 for (size_t i = 0; i < number_of_profiles; ++i) { 77 for (size_t i = 0; i < number_of_profiles; ++i) {
84 // Find when locked profiles were locked 78 // Find when locked profiles were locked
85 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) { 79 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 counts->gaia_icon++; 164 counts->gaia_icon++;
171 if (info_cache.ProfileIsAuthErrorAtIndex(i)) 165 if (info_cache.ProfileIsAuthErrorAtIndex(i))
172 counts->auth_errors++; 166 counts->auth_errors++;
173 } 167 }
174 } 168 }
175 } 169 }
176 return true; 170 return true;
177 } 171 }
178 172
179 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { 173 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) {
174 #if defined(OS_WIN) || defined(OS_MACOSX)
180 ProfileCounts counts; 175 ProfileCounts counts;
181 if (CountProfileInformation(manager, &counts)) { 176 if (CountProfileInformation(manager, &counts)) {
182 int limited_total = counts.total; 177 size_t limited_total = counts.total;
183 int limited_signedin = counts.signedin; 178 size_t limited_signedin = counts.signedin;
184 if (limited_total > kMaximumReportedProfileCount) { 179 if (limited_total > kMaximumReportedProfileCount) {
185 limited_total = kMaximumReportedProfileCount + 1; 180 limited_total = kMaximumReportedProfileCount + 1;
186 limited_signedin = 181 limited_signedin =
187 (int)((float)(counts.signedin * limited_total) 182 (int)((float)(counts.signedin * limited_total)
188 / counts.total + 0.5); 183 / counts.total + 0.5);
189 } 184 }
190 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); 185 UpdateReportedOSProfileStatistics(limited_total, limited_signedin);
191 } 186 }
187 #endif
192 } 188 }
193 189
194 void ProfileMetrics::LogNumberOfProfileSwitches() { 190 void ProfileMetrics::LogNumberOfProfileSwitches() {
195 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSwitches", 191 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSwitches",
196 number_of_profile_switches_); 192 number_of_profile_switches_);
197 } 193 }
198 194
195 // The MACOSX implementation of this function is in profile_metrics_mac.mm.
Mark Mentovai 2015/02/20 21:54:19 What is MACOSX?
Mike Lerman 2015/02/23 16:12:11 That's the name of the OS constant we use for ifde
196 #if defined(OS_WIN)
197 void ProfileMetrics::UpdateReportedOSProfileStatistics(
198 size_t active, size_t signedin) {
199 GoogleUpdateSettings::UpdateProfileCounts(active, signedin);
200 }
201 #endif
202
199 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { 203 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) {
200 ProfileCounts counts; 204 ProfileCounts counts;
201 bool success = CountProfileInformation(manager, &counts); 205 bool success = CountProfileInformation(manager, &counts);
202 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); 206 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total);
203 207
204 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. 208 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests.
205 if (success) { 209 if (success) {
206 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", 210 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles",
207 counts.supervised); 211 counts.supervised);
208 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", 212 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles",
209 100 * counts.supervised / counts.total); 213 100 * counts.supervised / counts.total);
210 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", 214 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles",
211 counts.signedin); 215 counts.signedin);
212 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles", 216 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles",
213 counts.unused); 217 counts.unused);
214 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons", 218 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons",
215 counts.gaia_icon); 219 counts.gaia_icon);
216 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesWithAuthErrors", 220 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesWithAuthErrors",
217 counts.auth_errors); 221 counts.auth_errors);
218 222
219 LogLockedProfileInformation(manager); 223 LogLockedProfileInformation(manager);
224
225 #if defined(OS_WIN) || defined(OS_MACOSX)
220 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); 226 UpdateReportedOSProfileStatistics(counts.total, counts.signedin);
227 #endif
221 } 228 }
222 } 229 }
223 230
224 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { 231 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) {
225 DCHECK(metric < NUM_PROFILE_ADD_METRICS); 232 DCHECK(metric < NUM_PROFILE_ADD_METRICS);
226 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, 233 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric,
227 NUM_PROFILE_ADD_METRICS); 234 NUM_PROFILE_ADD_METRICS);
228 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, 235 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER,
229 NUM_PROFILE_NET_METRICS); 236 NUM_PROFILE_NET_METRICS);
230 } 237 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", 535 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn",
529 GetProfileType(profile_path), 536 GetProfileType(profile_path),
530 NUM_PROFILE_TYPE_METRICS); 537 NUM_PROFILE_TYPE_METRICS);
531 } 538 }
532 539
533 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { 540 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) {
534 UMA_HISTOGRAM_ENUMERATION("Profile.Update", 541 UMA_HISTOGRAM_ENUMERATION("Profile.Update",
535 GetProfileType(profile_path), 542 GetProfileType(profile_path),
536 NUM_PROFILE_TYPE_METRICS); 543 NUM_PROFILE_TYPE_METRICS);
537 } 544 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698