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/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) | |
24 const int kMaximumReportedProfileCount = 5; | 23 const int kMaximumReportedProfileCount = 5; |
25 #endif | |
26 | |
27 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks. | 24 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks. |
28 | 25 |
29 size_t number_of_profile_switches_ = 0; | 26 size_t number_of_profile_switches_ = 0; |
30 | 27 |
31 // Enum for tracking the state of profiles being switched to. | 28 // Enum for tracking the state of profiles being switched to. |
32 enum ProfileOpenState { | 29 enum ProfileOpenState { |
33 // Profile being switched to is already opened and has browsers opened. | 30 // Profile being switched to is already opened and has browsers opened. |
34 PROFILE_OPENED = 0, | 31 PROFILE_OPENED = 0, |
35 // Profile being switched to is already opened but has no browsers opened. | 32 // Profile being switched to is already opened but has no browsers opened. |
36 PROFILE_OPENED_NO_BROWSER, | 33 PROFILE_OPENED_NO_BROWSER, |
(...skipping 26 matching lines...) Expand all Loading... |
63 // 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. |
64 if (manager) { | 61 if (manager) { |
65 user_data_dir = manager->user_data_dir(); | 62 user_data_dir = manager->user_data_dir(); |
66 } | 63 } |
67 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) { | 64 if (profile_path == user_data_dir.AppendASCII(chrome::kInitialProfile)) { |
68 metric = ProfileMetrics::ORIGINAL; | 65 metric = ProfileMetrics::ORIGINAL; |
69 } | 66 } |
70 return metric; | 67 return metric; |
71 } | 68 } |
72 | 69 |
| 70 void UpdateReportedOSProfileStatistics(int active, int signedin) { |
| 71 #if defined(OS_WIN) |
| 72 GoogleUpdateSettings::UpdateProfileCounts(active, signedin); |
| 73 #endif |
| 74 } |
| 75 |
73 void LogLockedProfileInformation(ProfileManager* manager) { | 76 void LogLockedProfileInformation(ProfileManager* manager) { |
74 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); | 77 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); |
75 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); | 78 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); |
76 | 79 |
77 base::Time now = base::Time::Now(); | 80 base::Time now = base::Time::Now(); |
78 const int kMinutesInProfileValidDuration = | 81 const int kMinutesInProfileValidDuration = |
79 base::TimeDelta::FromDays(28).InMinutes(); | 82 base::TimeDelta::FromDays(28).InMinutes(); |
80 for (size_t i = 0; i < number_of_profiles; ++i) { | 83 for (size_t i = 0; i < number_of_profiles; ++i) { |
81 // Find when locked profiles were locked | 84 // Find when locked profiles were locked |
82 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) { | 85 if (info_cache.ProfileIsSigninRequiredAtIndex(i)) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 counts->gaia_icon++; | 170 counts->gaia_icon++; |
168 if (info_cache.ProfileIsAuthErrorAtIndex(i)) | 171 if (info_cache.ProfileIsAuthErrorAtIndex(i)) |
169 counts->auth_errors++; | 172 counts->auth_errors++; |
170 } | 173 } |
171 } | 174 } |
172 } | 175 } |
173 return true; | 176 return true; |
174 } | 177 } |
175 | 178 |
176 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { | 179 void ProfileMetrics::UpdateReportedProfilesStatistics(ProfileManager* manager) { |
177 #if defined(OS_WIN) || defined(OS_MACOSX) | |
178 ProfileCounts counts; | 180 ProfileCounts counts; |
179 if (CountProfileInformation(manager, &counts)) { | 181 if (CountProfileInformation(manager, &counts)) { |
180 size_t limited_total = counts.total; | 182 int limited_total = counts.total; |
181 size_t limited_signedin = counts.signedin; | 183 int limited_signedin = counts.signedin; |
182 if (limited_total > kMaximumReportedProfileCount) { | 184 if (limited_total > kMaximumReportedProfileCount) { |
183 limited_total = kMaximumReportedProfileCount + 1; | 185 limited_total = kMaximumReportedProfileCount + 1; |
184 limited_signedin = | 186 limited_signedin = |
185 (int)((float)(counts.signedin * limited_total) | 187 (int)((float)(counts.signedin * limited_total) |
186 / counts.total + 0.5); | 188 / counts.total + 0.5); |
187 } | 189 } |
188 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); | 190 UpdateReportedOSProfileStatistics(limited_total, limited_signedin); |
189 } | 191 } |
190 #endif | |
191 } | 192 } |
192 | 193 |
193 void ProfileMetrics::LogNumberOfProfileSwitches() { | 194 void ProfileMetrics::LogNumberOfProfileSwitches() { |
194 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSwitches", | 195 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSwitches", |
195 number_of_profile_switches_); | 196 number_of_profile_switches_); |
196 } | 197 } |
197 | 198 |
198 // The OS_MACOSX implementation of this function is in profile_metrics_mac.mm. | |
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 | |
206 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { | 199 void ProfileMetrics::LogNumberOfProfiles(ProfileManager* manager) { |
207 ProfileCounts counts; | 200 ProfileCounts counts; |
208 bool success = CountProfileInformation(manager, &counts); | 201 bool success = CountProfileInformation(manager, &counts); |
209 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); | 202 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); |
210 | 203 |
211 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. | 204 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. |
212 if (success) { | 205 if (success) { |
213 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", | 206 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", |
214 counts.supervised); | 207 counts.supervised); |
215 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", | 208 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", |
216 100 * counts.supervised / counts.total); | 209 100 * counts.supervised / counts.total); |
217 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", | 210 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", |
218 counts.signedin); | 211 counts.signedin); |
219 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles", | 212 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles", |
220 counts.unused); | 213 counts.unused); |
221 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons", | 214 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfilesWithGAIAIcons", |
222 counts.gaia_icon); | 215 counts.gaia_icon); |
223 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesWithAuthErrors", | 216 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfilesWithAuthErrors", |
224 counts.auth_errors); | 217 counts.auth_errors); |
225 | 218 |
226 LogLockedProfileInformation(manager); | 219 LogLockedProfileInformation(manager); |
227 | |
228 #if defined(OS_WIN) || defined(OS_MACOSX) | |
229 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); | 220 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); |
230 #endif | |
231 } | 221 } |
232 } | 222 } |
233 | 223 |
234 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { | 224 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { |
235 DCHECK(metric < NUM_PROFILE_ADD_METRICS); | 225 DCHECK(metric < NUM_PROFILE_ADD_METRICS); |
236 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, | 226 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, |
237 NUM_PROFILE_ADD_METRICS); | 227 NUM_PROFILE_ADD_METRICS); |
238 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, | 228 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, |
239 NUM_PROFILE_NET_METRICS); | 229 NUM_PROFILE_NET_METRICS); |
240 } | 230 } |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", | 528 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", |
539 GetProfileType(profile_path), | 529 GetProfileType(profile_path), |
540 NUM_PROFILE_TYPE_METRICS); | 530 NUM_PROFILE_TYPE_METRICS); |
541 } | 531 } |
542 | 532 |
543 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { | 533 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { |
544 UMA_HISTOGRAM_ENUMERATION("Profile.Update", | 534 UMA_HISTOGRAM_ENUMERATION("Profile.Update", |
545 GetProfileType(profile_path), | 535 GetProfileType(profile_path), |
546 NUM_PROFILE_TYPE_METRICS); | 536 NUM_PROFILE_TYPE_METRICS); |
547 } | 537 } |
OLD | NEW |