OLD | NEW |
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/chrome_signin_helper.h" | 14 #include "chrome/browser/signin/chrome_signin_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 "components/profile_metrics/counts.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 #if defined(OS_WIN) || defined(OS_MACOSX) | 24 #if defined(OS_WIN) || defined(OS_MACOSX) |
24 const int kMaximumReportedProfileCount = 5; | 25 const int kMaximumReportedProfileCount = 5; |
25 #endif | 26 #endif |
26 | 27 |
27 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks. | 28 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 AVATAR_MARGARITA, | 137 AVATAR_MARGARITA, |
137 AVATAR_NOTE, | 138 AVATAR_NOTE, |
138 AVATAR_SUN_CLOUD, | 139 AVATAR_SUN_CLOUD, |
139 AVATAR_PLACEHOLDER, | 140 AVATAR_PLACEHOLDER, |
140 AVATAR_UNKNOWN, // 27 | 141 AVATAR_UNKNOWN, // 27 |
141 AVATAR_GAIA, // 28 | 142 AVATAR_GAIA, // 28 |
142 NUM_PROFILE_AVATAR_METRICS | 143 NUM_PROFILE_AVATAR_METRICS |
143 }; | 144 }; |
144 | 145 |
145 bool ProfileMetrics::CountProfileInformation(ProfileManager* manager, | 146 bool ProfileMetrics::CountProfileInformation(ProfileManager* manager, |
146 ProfileCounts* counts) { | 147 profile_metrics::Counts* counts) { |
147 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); | 148 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); |
148 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); | 149 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); |
149 counts->total = number_of_profiles; | 150 counts->total = number_of_profiles; |
150 | 151 |
151 // Ignore other metrics if we have no profiles. | 152 // Ignore other metrics if we have no profiles. |
152 if (!number_of_profiles) | 153 if (!number_of_profiles) |
153 return false; | 154 return false; |
154 | 155 |
155 // Maximum age for "active" profile is 4 weeks. | 156 // Maximum age for "active" profile is 4 weeks. |
156 base::Time oldest = base::Time::Now() - | 157 base::Time oldest = base::Time::Now() - |
(...skipping 12 matching lines...) Expand all Loading... |
169 if (info_cache.ProfileIsAuthErrorAtIndex(i)) | 170 if (info_cache.ProfileIsAuthErrorAtIndex(i)) |
170 counts->auth_errors++; | 171 counts->auth_errors++; |
171 } | 172 } |
172 } | 173 } |
173 } | 174 } |
174 return true; | 175 return true; |
175 } | 176 } |
176 | 177 |
177 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { | 178 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { |
178 #if defined(OS_WIN) || defined(OS_MACOSX) | 179 #if defined(OS_WIN) || defined(OS_MACOSX) |
179 ProfileCounts counts; | 180 profile_metrics::Counts counts; |
180 if (CountProfileInformation(manager, &counts)) { | 181 if (CountProfileInformation(manager, &counts)) { |
181 size_t limited_total = counts.total; | 182 size_t limited_total = counts.total; |
182 size_t limited_signedin = counts.signedin; | 183 size_t limited_signedin = counts.signedin; |
183 if (limited_total > kMaximumReportedProfileCount) { | 184 if (limited_total > kMaximumReportedProfileCount) { |
184 limited_total = kMaximumReportedProfileCount + 1; | 185 limited_total = kMaximumReportedProfileCount + 1; |
185 limited_signedin = | 186 limited_signedin = |
186 (int)((float)(counts.signedin * limited_total) | 187 (int)((float)(counts.signedin * limited_total) |
187 / counts.total + 0.5); | 188 / counts.total + 0.5); |
188 } | 189 } |
189 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); | 190 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); |
(...skipping 10 matching lines...) Expand all Loading... |
200 | 201 |
201 // The OS_MACOSX implementation of this function is in profile_metrics_mac.mm. | 202 // The OS_MACOSX implementation of this function is in profile_metrics_mac.mm. |
202 #if defined(OS_WIN) | 203 #if defined(OS_WIN) |
203 void ProfileMetrics::UpdateReportedOSProfileStatistics( | 204 void ProfileMetrics::UpdateReportedOSProfileStatistics( |
204 size_t active, size_t signedin) { | 205 size_t active, size_t signedin) { |
205 GoogleUpdateSettings::UpdateProfileCounts(active, signedin); | 206 GoogleUpdateSettings::UpdateProfileCounts(active, signedin); |
206 } | 207 } |
207 #endif | 208 #endif |
208 | 209 |
209 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { | 210 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { |
210 ProfileCounts counts; | 211 profile_metrics::Counts counts; |
211 bool success = CountProfileInformation(manager, &counts); | 212 bool success = CountProfileInformation(manager, &counts); |
212 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); | 213 |
| 214 profile_metrics::LogProfileMetricsCounts(counts); |
213 | 215 |
214 // Ignore other metrics if we have no profiles. | 216 // Ignore other metrics if we have no profiles. |
215 if (success) { | 217 if (success) { |
216 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", | |
217 counts.supervised); | |
218 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", | |
219 100 * counts.supervised / counts.total); | |
220 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", | |
221 counts.signedin); | |
222 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles", | |
223 counts.unused); | |
224 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons", | |
225 counts.gaia_icon); | |
226 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesWithAuthErrors", | |
227 counts.auth_errors); | |
228 | |
229 LogLockedProfileInformation(manager); | 218 LogLockedProfileInformation(manager); |
230 | 219 |
231 #if defined(OS_WIN) || defined(OS_MACOSX) | 220 #if defined(OS_WIN) || defined(OS_MACOSX) |
232 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); | 221 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); |
233 #endif | 222 #endif |
234 } | 223 } |
235 } | 224 } |
236 | 225 |
237 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { | 226 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { |
238 DCHECK(metric < NUM_PROFILE_ADD_METRICS); | 227 DCHECK(metric < NUM_PROFILE_ADD_METRICS); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", | 541 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", |
553 GetProfileType(profile_path), | 542 GetProfileType(profile_path), |
554 NUM_PROFILE_TYPE_METRICS); | 543 NUM_PROFILE_TYPE_METRICS); |
555 } | 544 } |
556 | 545 |
557 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { | 546 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { |
558 UMA_HISTOGRAM_ENUMERATION("Profile.Update", | 547 UMA_HISTOGRAM_ENUMERATION("Profile.Update", |
559 GetProfileType(profile_path), | 548 GetProfileType(profile_path), |
560 NUM_PROFILE_TYPE_METRICS); | 549 NUM_PROFILE_TYPE_METRICS); |
561 } | 550 } |
OLD | NEW |