Chromium Code Reviews| 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/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/installer/util/google_update_settings.h" | 15 #include "chrome/installer/util/google_update_settings.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const int kMaximumReportedProfileCount = 5; | 21 const int kMaximumReportedProfileCount = 5; |
| 22 const int kMaximumDaysOfDisuse = 4 * 7; // Should be integral number of weeks. | |
| 22 | 23 |
| 23 struct ProfileCounts { | 24 struct ProfileCounts { |
| 24 size_t total; | 25 size_t total; |
| 25 size_t signedin; | 26 size_t signedin; |
| 26 size_t managed; | 27 size_t managed; |
| 28 size_t unused; | |
| 27 | 29 |
| 28 ProfileCounts() : total(0), signedin(0), managed(0) {} | 30 ProfileCounts() : total(0), signedin(0), managed(0), unused(0) {} |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 ProfileMetrics::ProfileType GetProfileType( | 33 ProfileMetrics::ProfileType GetProfileType( |
| 32 const base::FilePath& profile_path) { | 34 const base::FilePath& profile_path) { |
| 33 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 35 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 34 ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY; | 36 ProfileMetrics::ProfileType metric = ProfileMetrics::SECONDARY; |
| 35 ProfileManager* manager = g_browser_process->profile_manager(); | 37 ProfileManager* manager = g_browser_process->profile_manager(); |
| 36 base::FilePath user_data_dir; | 38 base::FilePath user_data_dir; |
| 37 // In unittests, we do not always have a profile_manager so check. | 39 // In unittests, we do not always have a profile_manager so check. |
| 38 if (manager) { | 40 if (manager) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 52 | 54 |
| 53 bool CountProfileInformation(ProfileManager* manager, ProfileCounts* counts) { | 55 bool CountProfileInformation(ProfileManager* manager, ProfileCounts* counts) { |
| 54 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); | 56 const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); |
| 55 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); | 57 size_t number_of_profiles = info_cache.GetNumberOfProfiles(); |
| 56 counts->total = number_of_profiles; | 58 counts->total = number_of_profiles; |
| 57 | 59 |
| 58 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. | 60 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. |
| 59 if (!number_of_profiles) | 61 if (!number_of_profiles) |
| 60 return false; | 62 return false; |
| 61 | 63 |
| 64 // Maximum age for "active" profile is 4 weeks. | |
| 65 base::Time oldest = base::Time::Now() - | |
| 66 base::TimeDelta::FromDays(kMaximumDaysOfDisuse); | |
| 67 | |
| 62 for (size_t i = 0; i < number_of_profiles; ++i) { | 68 for (size_t i = 0; i < number_of_profiles; ++i) { |
| 63 if (info_cache.ProfileIsManagedAtIndex(i)) | 69 if (info_cache.GetProfileActiveTimeAtIndex(i) < oldest) { |
|
rpetterson
2014/01/22 21:40:27
Overall I think this is an interesting metric to r
bcwhite
2014/01/23 14:07:38
From the point-of-view of "signed in" tracking, we
| |
| 64 counts->managed++; | 70 counts->unused++; |
| 65 if (!info_cache.GetUserNameOfProfileAtIndex(i).empty()) | 71 } else { |
| 66 counts->signedin++; | 72 if (info_cache.ProfileIsManagedAtIndex(i)) |
| 73 counts->managed++; | |
| 74 if (!info_cache.GetUserNameOfProfileAtIndex(i).empty()) | |
| 75 counts->signedin++; | |
| 76 } | |
| 67 } | 77 } |
| 68 return true; | 78 return true; |
| 69 } | 79 } |
| 70 | 80 |
| 71 } // namespace | 81 } // namespace |
| 72 | 82 |
| 73 enum ProfileAvatar { | 83 enum ProfileAvatar { |
| 74 AVATAR_GENERIC = 0, // The names for avatar icons | 84 AVATAR_GENERIC = 0, // The names for avatar icons |
| 75 AVATAR_GENERIC_AQUA, | 85 AVATAR_GENERIC_AQUA, |
| 76 AVATAR_GENERIC_BLUE, | 86 AVATAR_GENERIC_BLUE, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); | 133 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfProfiles", counts.total); |
| 124 | 134 |
| 125 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. | 135 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. |
| 126 if (success) { | 136 if (success) { |
| 127 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", | 137 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfManagedProfiles", |
| 128 counts.managed); | 138 counts.managed); |
| 129 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", | 139 UMA_HISTOGRAM_COUNTS_100("Profile.PercentageOfManagedProfiles", |
| 130 100 * counts.managed / counts.total); | 140 100 * counts.managed / counts.total); |
| 131 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", | 141 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfSignedInProfiles", |
| 132 counts.signedin); | 142 counts.signedin); |
| 143 UMA_HISTOGRAM_COUNTS_100("Profile.NumberOfUnusedProfiles", | |
| 144 counts.unused); | |
| 133 | 145 |
| 134 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); | 146 UpdateReportedOSProfileStatistics(counts.total, counts.signedin); |
| 135 } | 147 } |
| 136 } | 148 } |
| 137 | 149 |
| 138 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { | 150 void ProfileMetrics::LogProfileAddNewUser(ProfileAdd metric) { |
| 139 DCHECK(metric < NUM_PROFILE_ADD_METRICS); | 151 DCHECK(metric < NUM_PROFILE_ADD_METRICS); |
| 140 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, | 152 UMA_HISTOGRAM_ENUMERATION("Profile.AddNewUser", metric, |
| 141 NUM_PROFILE_ADD_METRICS); | 153 NUM_PROFILE_ADD_METRICS); |
| 142 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, | 154 UMA_HISTOGRAM_ENUMERATION("Profile.NetUserCount", ADD_NEW_USER, |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", | 296 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", |
| 285 GetProfileType(profile_path), | 297 GetProfileType(profile_path), |
| 286 NUM_PROFILE_TYPE_METRICS); | 298 NUM_PROFILE_TYPE_METRICS); |
| 287 } | 299 } |
| 288 | 300 |
| 289 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { | 301 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { |
| 290 UMA_HISTOGRAM_ENUMERATION("Profile.Update", | 302 UMA_HISTOGRAM_ENUMERATION("Profile.Update", |
| 291 GetProfileType(profile_path), | 303 GetProfileType(profile_path), |
| 292 NUM_PROFILE_TYPE_METRICS); | 304 NUM_PROFILE_TYPE_METRICS); |
| 293 } | 305 } |
| OLD | NEW |