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

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

Issue 33753002: Sooper experimental refactoring of the profile info cache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 2 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
« no previous file with comments | « chrome/browser/profiles/profile_list_desktop.cc ('k') | chrome/browser/profiles/profile_metrics.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index a6d1554ae94d2e4e0bd171984f3a52babbd02852..92717cac8db82d656c9516b15d86744b63658f8e 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -962,7 +962,9 @@ void ProfileManager::AddProfileToCache(Profile* profile) {
if (profile->GetPath().DirName() != cache.GetUserDataDir())
return;
- if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos)
+ // If the profile is already in the cache, there's nothing to do.
+ ProfileInfoEntry entry;
+ if (cache.GetInfoForProfile(profile->GetPath(), &entry))
return;
string16 username = UTF8ToUTF16(profile->GetPrefs()->GetString(
@@ -999,16 +1001,12 @@ void ProfileManager::InitProfileUserPrefs(Profile* profile) {
profile_name = l10n_util::GetStringUTF8(IDS_PROFILES_GUEST_PROFILE_NAME);
avatar_index = 0;
} else {
- size_t profile_cache_index =
- cache.GetIndexOfProfileWithPath(profile->GetPath());
+ ProfileInfoEntry entry;
// If the cache has an entry for this profile, use the cache data.
- if (profile_cache_index != std::string::npos) {
- avatar_index =
- cache.GetAvatarIconIndexOfProfileAtIndex(profile_cache_index);
- profile_name =
- UTF16ToUTF8(cache.GetNameOfProfileAtIndex(profile_cache_index));
- managed_user_id =
- cache.GetManagedUserIdOfProfileAtIndex(profile_cache_index);
+ if (cache.GetInfoForProfile(profile->GetPath(), &entry)) {
+ avatar_index = entry.icon_index();
+ profile_name = UTF16ToUTF8(entry.GetDisplayName());
+ managed_user_id = entry.managed_user_id();
} else if (profile->GetPath() ==
profiles::GetDefaultProfileDir(cache.GetUserDataDir())) {
avatar_index = 0;
@@ -1066,10 +1064,12 @@ void ProfileManager::ScheduleProfileForDeletion(
// Update the last used profile pref before closing browser windows. This
// way the correct last used profile is set for any notification observers.
base::FilePath last_non_managed_profile_path;
- for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
- base::FilePath cur_path = cache.GetPathOfProfileAtIndex(i);
+ const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName());
+ for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin();
+ it != entries.end(); ++it) {
+ base::FilePath cur_path = it->path();
// Make sure that this profile is not pending deletion.
- if (cur_path != profile_dir && !cache.ProfileIsManagedAtIndex(i) &&
+ if (cur_path != profile_dir && !it->IsManaged() &&
!IsProfileMarkedForDeletion(cur_path)) {
last_non_managed_profile_path = cur_path;
break;
@@ -1173,13 +1173,14 @@ void ProfileManager::AutoloadProfiles() {
}
ProfileInfoCache& cache = GetProfileInfoCache();
- size_t number_of_profiles = cache.GetNumberOfProfiles();
- for (size_t p = 0; p < number_of_profiles; ++p) {
- if (cache.GetBackgroundStatusOfProfileAtIndex(p)) {
+ const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName());
+ for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin();
+ it != entries.end(); ++it) {
+ if (it->is_running_background_apps()) {
// If status is true, that profile is running background apps. By calling
// GetProfile, we automatically cause the profile to be loaded which will
// register it with the BackgroundModeManager.
- GetProfile(cache.GetPathOfProfileAtIndex(p));
+ GetProfile(it->path());
}
}
}
« no previous file with comments | « chrome/browser/profiles/profile_list_desktop.cc ('k') | chrome/browser/profiles/profile_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698