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

Unified Diff: chrome/browser/profiles/gaia_info_update_service.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/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 083e21db4168cd2bae61de94c9afe53917fb4ca3..62bc882ac52dec33d1e9b2af4a6e9645ec64207c 100644
--- a/chrome/browser/profiles/gaia_info_update_service.cc
+++ b/chrome/browser/profiles/gaia_info_update_service.cc
@@ -9,7 +9,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.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/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profiles_state.h"
@@ -112,29 +113,22 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess(
downloader->GetProfilePictureStatus();
std::string picture_url = downloader->GetProfilePictureURL();
- 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;
- cache.SetGAIANameOfProfileAtIndex(profile_index, full_name);
- // The profile index may have changed.
- profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
- DCHECK_NE(profile_index, std::string::npos);
-
- cache.SetGAIAGivenNameOfProfileAtIndex(profile_index, given_name);
- // The profile index may have changed.
- profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
- DCHECK_NE(profile_index, std::string::npos);
+ entry->SetGAIAName(full_name);
+ entry->SetGAIAGivenName(given_name);
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);
+ entry->SetGAIAPicture(&gfx_image);
} else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) {
- cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL);
+ entry->SetGAIAPicture(NULL);
}
const base::string16 hosted_domain = downloader->GetProfileHostedDomain();
@@ -156,21 +150,17 @@ void GAIAInfoUpdateService::OnProfileDownloadFailure(
}
void GAIAInfoUpdateService::OnUsernameChanged(const std::string& username) {
- 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 (username.empty()) {
// Unset the old user's GAIA info.
- cache.SetGAIANameOfProfileAtIndex(profile_index, base::string16());
- cache.SetGAIAGivenNameOfProfileAtIndex(profile_index, base::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->SetGAIAName(base::string16());
+ entry->SetGAIAGivenName(base::string16());
+ entry->SetGAIAPicture(NULL);
// Unset the cached URL.
profile_->GetPrefs()->ClearPref(prefs::kProfileGAIAInfoPictureURL);
} else {

Powered by Google App Engine
This is Rietveld 408576698