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

Unified Diff: chrome/browser/profiles/gaia_info_update_service.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/avatar_menu_desktop.cc ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/gaia_info_update_service.cc
diff --git a/chrome/browser/profiles/gaia_info_update_service.cc b/chrome/browser/profiles/gaia_info_update_service.cc
index 79013032160e8f029002affc530edc5b546352c9..1c4e64e48d5c83256332f6dfd7d789526991a52f 100644
--- a/chrome/browser/profiles/gaia_info_update_service.cc
+++ b/chrome/browser/profiles/gaia_info_update_service.cc
@@ -114,40 +114,38 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess(
ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
- if (profile_index == std::string::npos)
+
+ ProfileInfoEntry entry;
+ if (!cache.GetInfoForProfile(profile_->GetPath(), &entry))
return;
- cache.SetGAIANameOfProfileAtIndex(profile_index, full_name);
- cache.SetGAIAGivenNameOfProfileAtIndex(profile_index, given_name);
+ entry.set_GAIA_full_name(full_name);
+ entry.set_GAIA_given_name(given_name);
- // The profile index may have changed.
- profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
- if (profile_index == std::string::npos)
- return;
if (picture_status == ProfileDownloader::PICTURE_SUCCESS) {
profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL,
picture_url);
gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap);
- cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image);
+ cache.SetGAIAPictureOfProfile(entry.path(), &gfx_image);
} else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) {
- cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL);
+ cache.SetGAIAPictureOfProfile(entry.path(), NULL);
}
// If this profile hasn't switched to using GAIA information for the profile
// name and picture then switch it now. Once the profile has switched this
// preference guards against clobbering the user's custom settings.
- if (!cache.GetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index)) {
- cache.SetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index, true);
+ if (!entry.has_migrated_to_GAIA_info_of_profile()) {
+ entry.set_has_migrated_to_GAIA_info_of_profile(true);
// Order matters here for shortcut management, like in
// ProfileShortcutManagerWin::OnProfileAdded, as the picture update does not
// allow us to change the target, so we have to apply any renaming first. We
// also need to re-fetch the index, as SetIsUsingGAIANameOfProfileAtIndex
// may alter it.
- cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, true);
- profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
- cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true);
+ entry.set_is_using_GAIA_name(true);
+ entry.set_is_using_GAIA_picture(true);
}
+
+ cache.SetInfoForProfile(entry);
}
void GAIAInfoUpdateService::OnProfileDownloadFailure(
@@ -165,20 +163,18 @@ void GAIAInfoUpdateService::OnProfileDownloadFailure(
void GAIAInfoUpdateService::OnUsernameChanged() {
ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
- if (profile_index == std::string::npos)
+
+ ProfileInfoEntry entry;
+ if (!cache.GetInfoForProfile(profile_->GetPath(), &entry))
return;
std::string username = profile_->GetPrefs()->GetString(
prefs::kGoogleServicesUsername);
if (username.empty()) {
// Unset the old user's GAIA info.
- cache.SetGAIANameOfProfileAtIndex(profile_index, string16());
- // The profile index may have changed.
- profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
- if (profile_index == std::string::npos)
- return;
- cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL);
+ entry.set_GAIA_full_name(string16());
+ cache.SetGAIAPictureOfProfile(entry.path(), NULL);
+ cache.SetInfoForProfile(entry);
// Unset the cached URL.
profile_->GetPrefs()->ClearPref(prefs::kProfileGAIAInfoPictureURL);
} else {
« no previous file with comments | « chrome/browser/profiles/avatar_menu_desktop.cc ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698