Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5153)

Unified Diff: chrome/browser/profiles/profile_metrics.cc

Issue 1794353003: Refactor ProfileInfoCache in c/b/profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a bug that causes unit tests without debug code to fail. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_metrics.cc
diff --git a/chrome/browser/profiles/profile_metrics.cc b/chrome/browser/profiles/profile_metrics.cc
index 6d4bcea17fd6ce0937b4237b631e03698228255d..dcf31521777bda2fb683378908571ea8b21d201f 100644
--- a/chrome/browser/profiles/profile_metrics.cc
+++ b/chrome/browser/profiles/profile_metrics.cc
@@ -4,13 +4,16 @@
#include "chrome/browser/profiles/profile_metrics.h"
+#include <vector>
+
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "build/build_config.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/chrome_signin_helper.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -74,17 +77,15 @@ ProfileMetrics::ProfileType GetProfileType(
}
void LogLockedProfileInformation(ProfileManager* manager) {
- const ProfileInfoCache& info_cache = manager->GetProfileInfoCache();
- size_t number_of_profiles = info_cache.GetNumberOfProfiles();
-
base::Time now = base::Time::Now();
const int kMinutesInProfileValidDuration =
base::TimeDelta::FromDays(28).InMinutes();
- for (size_t i = 0; i < number_of_profiles; ++i) {
+ std::vector<ProfileAttributesEntry*> entries =
+ manager->GetProfileAttributesStorage().GetAllProfilesAttributes();
+ 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).
@@ -97,13 +98,12 @@ void LogLockedProfileInformation(ProfileManager* manager) {
}
}
-bool HasProfileAtIndexBeenActiveSince(const ProfileInfoCache& info_cache,
- int index,
- const base::Time& active_limit) {
+bool HasProfileBeenActiveSince(const ProfileAttributesEntry* entry,
+ const base::Time& active_limit) {
#if !defined(OS_ANDROID)
// TODO(mlerman): iOS and Android should set an ActiveTime in the
- // ProfileInfoCache. (see ProfileManager::OnBrowserSetLastActive)
- if (info_cache.GetProfileActiveTimeAtIndex(index) < active_limit)
+ // ProfileAttributesStorage. (see ProfileManager::OnBrowserSetLastActive)
+ if (entry->GetActiveTime() < active_limit)
return false;
#endif
return true;
@@ -146,8 +146,8 @@ enum ProfileAvatar {
bool ProfileMetrics::CountProfileInformation(ProfileManager* manager,
profile_metrics::Counts* counts) {
- const ProfileInfoCache& info_cache = manager->GetProfileInfoCache();
- size_t number_of_profiles = info_cache.GetNumberOfProfiles();
+ ProfileAttributesStorage& storage = manager->GetProfileAttributesStorage();
+ size_t number_of_profiles = storage.GetNumberOfProfiles();
counts->total = number_of_profiles;
// Ignore other metrics if we have no profiles.
@@ -158,17 +158,19 @@ bool ProfileMetrics::CountProfileInformation(ProfileManager* manager,
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) {
+ if (!HasProfileBeenActiveSince(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++;
}
}
« no previous file with comments | « chrome/browser/profiles/profile_manager_unittest.cc ('k') | chrome/browser/profiles/profile_shortcut_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698