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

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

Issue 1242793005: Refactor most c/b/profiles calls to ProfileInfoCache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows unit test and ChromeOS build Created 5 years, 5 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/profiles_state.cc
diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
index 930bc83adc7adf5f80cf012edda749ae5c964e99..5c14cca8cdcf00134b76e2f2a675a2c2bda0ce5c 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -14,7 +14,8 @@
#include "chrome/browser/profiles/gaia_info_update_service.h"
#include "chrome/browser/profiles/gaia_info_update_service_factory.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/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
@@ -64,11 +65,11 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) {
if (profile_path == ProfileManager::GetGuestProfilePath()) {
display_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME);
} else {
- const ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- size_t index = cache.GetIndexOfProfileWithPath(profile_path);
+ ProfileAttributesStorage& storage =
+ g_browser_process->profile_manager()->GetProfileAttributesStorage();
+ ProfileAttributesEntry* entry;
- if (index == std::string::npos)
+ if (!storage.GetProfileAttributesWithPath(profile_path, &entry))
return l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
// Using the --new-avatar-menu flag, there's a couple of rules about what
@@ -77,12 +78,12 @@ base::string16 GetAvatarNameForProfile(const base::FilePath& profile_path) {
// IDS_SINGLE_PROFILE_DISPLAY_NAME. If the profile is signed in but is using
// a default name, use the profiles's email address. Otherwise, it
// will return the actual name of the profile.
- const base::string16 profile_name = cache.GetNameOfProfileAtIndex(index);
- const base::string16 email = cache.GetUserNameOfProfileAtIndex(index);
- bool is_default_name = cache.ProfileIsUsingDefaultNameAtIndex(index) &&
- cache.IsDefaultProfileName(profile_name);
+ const base::string16 profile_name = entry->GetName();
+ const base::string16 email = entry->GetUserName();
+ bool is_default_name = entry->IsUsingDefaultName() &&
+ storage.IsDefaultProfileName(profile_name);
- if (cache.GetNumberOfProfiles() == 1 && is_default_name)
+ if (storage.GetNumberOfProfiles() == 1 && is_default_name)
display_name = l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
else
display_name = (is_default_name && !email.empty()) ? email : profile_name;
@@ -115,13 +116,13 @@ base::string16 GetProfileSwitcherTextForItem(const AvatarMenu::Item& item) {
void UpdateProfileName(Profile* profile,
const base::string16& new_profile_name) {
- const ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath());
- if (profile_index == std::string::npos)
+ ProfileAttributesStorage& storage =
+ g_browser_process->profile_manager()->GetProfileAttributesStorage();
+ ProfileAttributesEntry* entry;
+ if (!storage.GetProfileAttributesWithPath(profile->GetPath(), &entry))
return;
- if (new_profile_name == cache.GetNameOfProfileAtIndex(profile_index))
+ if (new_profile_name == entry->GetName())
return;
// This is only called when updating the profile name through the UI,
@@ -158,14 +159,14 @@ bool IsRegularOrGuestSession(Browser* browser) {
}
bool IsProfileLocked(const base::FilePath& path) {
- const ProfileInfoCache& cache =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- size_t profile_index = cache.GetIndexOfProfileWithPath(path);
+ ProfileAttributesStorage& storage =
+ g_browser_process->profile_manager()->GetProfileAttributesStorage();
+ ProfileAttributesEntry* entry;
- if (profile_index == std::string::npos)
+ if (!storage.GetProfileAttributesWithPath(path, &entry))
return false;
- return cache.ProfileIsSigninRequiredAtIndex(profile_index);
+ return entry->IsSigninRequired();
}
void UpdateIsProfileLockEnabledIfNeeded(Profile* profile) {
@@ -207,10 +208,13 @@ bool SetActiveProfileToGuestIfLocked() {
if (active_profile_path == guest_path)
return true;
- const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
- size_t index = cache.GetIndexOfProfileWithPath(active_profile_path);
- if (!cache.ProfileIsSigninRequiredAtIndex(index))
+ ProfileAttributesStorage& storage =
+ profile_manager->GetProfileAttributesStorage();
+ ProfileAttributesEntry* entry;
+ if (storage.GetProfileAttributesWithPath(active_profile_path, &entry) &&
+ !entry->IsSigninRequired()) {
return false;
+ }
SetLastUsedProfile(guest_path.BaseName().MaybeAsASCII());

Powered by Google App Engine
This is Rietveld 408576698