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" |
| (...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 (info_cache.GetProfileActiveTimeAtIndex(index) < active_limit) { | |
|
bcwhite
2014/07/18 16:38:44
Can the entire condition test be moved inside the
Mike Lerman
2014/07/18 17:44:52
You can! Done.
| |
| 75 // TODO(mlerman): iOS and Android should set an ActiveTime in the | |
|
bcwhite
2014/07/18 16:38:44
Put the comment inside the appropriate #ifdef and
Mike Lerman
2014/07/18 17:44:52
Acknowledged.
| |
| 76 // ProfileInfoCache. (see ProfileManager::OnBrowserSetLastActive) | |
| 77 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 78 return true; | |
| 79 #else | |
| 80 return false; | |
| 81 #endif | |
| 82 } | |
| 83 return true; | |
| 84 } | |
| 85 | |
| 71 } // namespace | 86 } // namespace |
| 72 | 87 |
| 73 enum ProfileAvatar { | 88 enum ProfileAvatar { |
| 74 AVATAR_GENERIC = 0, // The names for avatar icons | 89 AVATAR_GENERIC = 0, // The names for avatar icons |
| 75 AVATAR_GENERIC_AQUA, | 90 AVATAR_GENERIC_AQUA, |
| 76 AVATAR_GENERIC_BLUE, | 91 AVATAR_GENERIC_BLUE, |
| 77 AVATAR_GENERIC_GREEN, | 92 AVATAR_GENERIC_GREEN, |
| 78 AVATAR_GENERIC_ORANGE, | 93 AVATAR_GENERIC_ORANGE, |
| 79 AVATAR_GENERIC_PURPLE, | 94 AVATAR_GENERIC_PURPLE, |
| 80 AVATAR_GENERIC_RED, | 95 AVATAR_GENERIC_RED, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 111 | 126 |
| 112 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. | 127 // Ignore other metrics if we have no profiles, e.g. in Chrome Frame tests. |
| 113 if (!number_of_profiles) | 128 if (!number_of_profiles) |
| 114 return false; | 129 return false; |
| 115 | 130 |
| 116 // Maximum age for "active" profile is 4 weeks. | 131 // Maximum age for "active" profile is 4 weeks. |
| 117 base::Time oldest = base::Time::Now() - | 132 base::Time oldest = base::Time::Now() - |
| 118 base::TimeDelta::FromDays(kMaximumDaysOfDisuse); | 133 base::TimeDelta::FromDays(kMaximumDaysOfDisuse); |
| 119 | 134 |
| 120 for (size_t i = 0; i < number_of_profiles; ++i) { | 135 for (size_t i = 0; i < number_of_profiles; ++i) { |
| 121 if (info_cache.GetProfileActiveTimeAtIndex(i) < oldest) { | 136 if (HasProfileAtIndexBeenActiveSince(info_cache, i, oldest)) { |
| 122 counts->unused++; | 137 counts->unused++; |
| 123 } else { | 138 } else { |
| 124 if (info_cache.ProfileIsSupervisedAtIndex(i)) | 139 if (info_cache.ProfileIsSupervisedAtIndex(i)) |
| 125 counts->supervised++; | 140 counts->supervised++; |
| 126 if (!info_cache.GetUserNameOfProfileAtIndex(i).empty()) { | 141 if (!info_cache.GetUserNameOfProfileAtIndex(i).empty()) { |
| 127 counts->signedin++; | 142 counts->signedin++; |
| 128 if (info_cache.IsUsingGAIAPictureOfProfileAtIndex(i)) | 143 if (info_cache.IsUsingGAIAPictureOfProfileAtIndex(i)) |
| 129 counts->gaia_icon++; | 144 counts->gaia_icon++; |
| 130 } | 145 } |
| 131 } | 146 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", | 436 UMA_HISTOGRAM_ENUMERATION("Profile.SyncSignIn", |
| 422 GetProfileType(profile_path), | 437 GetProfileType(profile_path), |
| 423 NUM_PROFILE_TYPE_METRICS); | 438 NUM_PROFILE_TYPE_METRICS); |
| 424 } | 439 } |
| 425 | 440 |
| 426 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { | 441 void ProfileMetrics::LogProfileUpdate(const base::FilePath& profile_path) { |
| 427 UMA_HISTOGRAM_ENUMERATION("Profile.Update", | 442 UMA_HISTOGRAM_ENUMERATION("Profile.Update", |
| 428 GetProfileType(profile_path), | 443 GetProfileType(profile_path), |
| 429 NUM_PROFILE_TYPE_METRICS); | 444 NUM_PROFILE_TYPE_METRICS); |
| 430 } | 445 } |
| OLD | NEW |