| 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" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // values (kMinutesInProfileValidDuration > 40,000). | 61 // values (kMinutesInProfileValidDuration > 40,000). |
| 62 UMA_HISTOGRAM_CUSTOM_COUNTS("Profile.LockedProfilesDuration", | 62 UMA_HISTOGRAM_CUSTOM_COUNTS("Profile.LockedProfilesDuration", |
| 63 time_since_lock.InMinutes(), | 63 time_since_lock.InMinutes(), |
| 64 1, | 64 1, |
| 65 kMinutesInProfileValidDuration, | 65 kMinutesInProfileValidDuration, |
| 66 100); | 66 100); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool HasProfileAtIndexBeenActiveSince(const ProfileInfoCache& info_cache, |
| 72 int index, |
| 73 const base::Time& active_limit) { |
| 74 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 75 // TODO(mlerman): iOS and Android should set an ActiveTime in the |
| 76 // ProfileInfoCache. (see ProfileManager::OnBrowserSetLastActive) |
| 77 if (info_cache.GetProfileActiveTimeAtIndex(index) < active_limit) |
| 78 return false; |
| 79 #endif |
| 80 return true; |
| 81 } |
| 82 |
| 71 } // namespace | 83 } // namespace |
| 72 | 84 |
| 73 enum ProfileAvatar { | 85 enum ProfileAvatar { |
| 74 AVATAR_GENERIC = 0, // The names for avatar icons | 86 AVATAR_GENERIC = 0, // The names for avatar icons |
| 75 AVATAR_GENERIC_AQUA, | 87 AVATAR_GENERIC_AQUA, |
| 76 AVATAR_GENERIC_BLUE, | 88 AVATAR_GENERIC_BLUE, |
| 77 AVATAR_GENERIC_GREEN, | 89 AVATAR_GENERIC_GREEN, |
| 78 AVATAR_GENERIC_ORANGE, | 90 AVATAR_GENERIC_ORANGE, |
| 79 AVATAR_GENERIC_PURPLE, | 91 AVATAR_GENERIC_PURPLE, |
| 80 AVATAR_GENERIC_RED, | 92 AVATAR_GENERIC_RED, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 111 | 123 |
| 112 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. | 124 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. |
| 113 if (!number_of_profiles) | 125 if (!number_of_profiles) |
| 114 return false; | 126 return false; |
| 115 | 127 |
| 116 // Maximum age for "active" profile is 4 weeks. | 128 // Maximum age for "active" profile is 4 weeks. |
| 117 base::Time oldest = base::Time::Now() - | 129 base::Time oldest = base::Time::Now() - |
| 118 base::TimeDelta::FromDays(kMaximumDaysOfDisuse); | 130 base::TimeDelta::FromDays(kMaximumDaysOfDisuse); |
| 119 | 131 |
| 120 for (size_t i = 0; i < number_of_profiles; ++i) { | 132 for (size_t i = 0; i < number_of_profiles; ++i) { |
| 121 if (info_cache.GetProfileActiveTimeAtIndex(i) < oldest) { | 133 if (!HasProfileAtIndexBeenActiveSince(info_cache, i, oldest)) { |
| 122 counts->unused++; | 134 counts->unused++; |
| 123 } else { | 135 } else { |
| 124 if (info_cache.ProfileIsSupervisedAtIndex(i)) | 136 if (info_cache.ProfileIsSupervisedAtIndex(i)) |
| 125 counts->supervised++; | 137 counts->supervised++; |
| 126 if (!info_cache.GetUserNameOfProfileAtIndex(i).empty()) { | 138 if (!info_cache.GetUserNameOfProfileAtIndex(i).empty()) { |
| 127 counts->signedin++; | 139 counts->signedin++; |
| 128 if (info_cache.IsUsingGAIAPictureOfProfileAtIndex(i)) | 140 if (info_cache.IsUsingGAIAPictureOfProfileAtIndex(i)) |
| 129 counts->gaia_icon++; | 141 counts->gaia_icon++; |
| 130 } | 142 } |
| 131 } | 143 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", | 433 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", |
| 422 GetProfileType(profile_path), | 434 GetProfileType(profile_path), |
| 423 NUM_PROFILE_TYPE_METRICS); | 435 NUM_PROFILE_TYPE_METRICS); |
| 424 } | 436 } |
| 425 | 437 |
| 426 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { | 438 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { |
| 427 UMA_HISTOGRAM_ENUMERATION("Profile.Update", | 439 UMA_HISTOGRAM_ENUMERATION("Profile.Update", |
| 428 GetProfileType(profile_path), | 440 GetProfileType(profile_path), |
| 429 NUM_PROFILE_TYPE_METRICS); | 441 NUM_PROFILE_TYPE_METRICS); |
| 430 } | 442 } |
| OLD | NEW |