Chromium Code Reviews| Index: chrome/browser/profiles/profile_metrics.cc |
| diff --git a/chrome/browser/profiles/profile_metrics.cc b/chrome/browser/profiles/profile_metrics.cc |
| index a7bb17fd1487dd6ef646085cf760300f82f50320..327e0dd1b4ae667d2fa93c7b3d5bef8a73f1b68c 100644 |
| --- a/chrome/browser/profiles/profile_metrics.cc |
| +++ b/chrome/browser/profiles/profile_metrics.cc |
| @@ -9,7 +9,8 @@ |
| #include "base/metrics/histogram.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/profiles/profile.h" |
| -#include "chrome/browser/profiles/profile_info_cache.h" |
| +#include "chrome/browser/profiles/profile_attributes_entry.h" |
| +#include "chrome/browser/profiles/profile_attributes_storage.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/signin/signin_header_helper.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| @@ -71,17 +72,17 @@ ProfileMetrics::ProfileType GetProfileType( |
| } |
| void LogLockedProfileInformation(ProfileManager* manager) { |
| - const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); |
| - size_t number_of_profiles = info_cache.GetNumberOfProfiles(); |
| + ProfileAttributesStorage& storage = manager->GetProfileAttributesStorage(); |
| + std::vector<ProfileAttributesEntry*> entries = |
| + storage.GetAllProfilesAttributes(); |
| base::Time now = base::Time::Now(); |
| const int kMinutesInProfileValidDuration = |
| base::TimeDelta::FromDays(28).InMinutes(); |
| - for (size_t i = 0; i < number_of_profiles; ++i) { |
| + for (ProfileAttributesEntry* entry: entries) { |
| // Find when locked profiles were locked |
| - if (info_cache.ProfileIsSigninRequiredAtIndex(i)) { |
| - base::TimeDelta time_since_lock = now - |
| - info_cache.GetProfileActiveTimeAtIndex(i); |
| + if (entry->IsSigninRequired()) { |
| + base::TimeDelta time_since_lock = now - entry->GetActiveTime(); |
| // Specifying 100 buckets for the histogram to get a higher level of |
| // granularity in the reported data, given the large number of possible |
| // values (kMinutesInProfileValidDuration > 40,000). |
| @@ -94,13 +95,12 @@ void LogLockedProfileInformation(ProfileManager* manager) { |
| } |
| } |
| -bool HasProfileAtIndexBeenActiveSince(const ProfileInfoCache& info_cache, |
| - int index, |
| +bool HasProfileAtIndexBeenActiveSince(const ProfileAttributesEntry* entry, |
| const base::Time& active_limit) { |
| #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| // TODO(mlerman): iOS and Android should set an ActiveTime in the |
| // ProfileInfoCache. (see ProfileManager::OnBrowserSetLastActive) |
| - if (info_cache.GetProfileActiveTimeAtIndex(index) < active_limit) |
| + if (entry->GetActiveTime() < active_limit) |
| return false; |
| #endif |
| return true; |
| @@ -143,29 +143,30 @@ enum ProfileAvatar { |
| bool ProfileMetrics::CountProfileInformation(ProfileManager* manager, |
| ProfileCounts* counts) { |
| - const ProfileInfoCache& info_cache = manager->GetProfileInfoCache(); |
| - size_t number_of_profiles = info_cache.GetNumberOfProfiles(); |
| - counts->total = number_of_profiles; |
| + ProfileAttributesStorage& storage = manager->GetProfileAttributesStorage(); |
| + counts->total = storage.GetNumberOfProfiles(); |
| // Ignore other metrics if we have no profiles. |
| - if (!number_of_profiles) |
| + if (!counts->total) |
| return false; |
| // Maximum age for "active" profile is 4 weeks. |
| base::Time oldest = base::Time::Now() - |
| base::TimeDelta::FromDays(kMaximumDaysOfDisuse); |
| - for (size_t i = 0; i < number_of_profiles; ++i) { |
| - if (!HasProfileAtIndexBeenActiveSince(info_cache, i, oldest)) { |
| + std::vector<ProfileAttributesEntry*> entries = |
| + storage.GetAllProfilesAttributes(); |
| + for (ProfileAttributesEntry* entry: entries) { |
|
Mike Lerman
2015/08/06 16:06:20
nit: space between entry and :
|
| + if (!HasProfileAtIndexBeenActiveSince(entry, oldest)) { |
| counts->unused++; |
| } else { |
| - if (info_cache.ProfileIsSupervisedAtIndex(i)) |
| + if (entry->IsSupervised()) |
| counts->supervised++; |
| - if (info_cache.ProfileIsAuthenticatedAtIndex(i)) { |
| + if (entry->IsAuthenticated()) { |
| counts->signedin++; |
| - if (info_cache.IsUsingGAIAPictureOfProfileAtIndex(i)) |
| + if (entry->IsUsingGAIAPicture()) |
| counts->gaia_icon++; |
| - if (info_cache.ProfileIsAuthErrorAtIndex(i)) |
| + if (entry->IsAuthError()) |
| counts->auth_errors++; |
| } |
| } |