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

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

Issue 1794353003: Refactor ProfileInfoCache in c/b/profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced LOG(WARNING) by UMA histograms 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/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 acae5daaa62ea0ccd1290e60c4ceabb338276b1b..5c55f51c25802a452628d85a23993e7b72681192 100644
--- a/chrome/browser/profiles/gaia_info_update_service.cc
+++ b/chrome/browser/profiles/gaia_info_update_service.cc
@@ -11,7 +11,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"
@@ -117,29 +118,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)
+ ProfileAttributesEntry* entry;
+ if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
+ 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(nullptr);
}
const base::string16 hosted_domain = downloader->GetProfileHostedDomain();
@@ -161,21 +155,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)
+ ProfileAttributesEntry* entry;
+ if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
+ 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(nullptr);
// Unset the cached URL.
profile_->GetPrefs()->ClearPref(prefs::kProfileGAIAInfoPictureURL);
} else {
@@ -194,7 +184,7 @@ void GAIAInfoUpdateService::Shutdown() {
// OK to reset |profile_| pointer here because GAIAInfoUpdateService will not
// access it again. This pointer is also used to implement the delegate for
// |profile_image_downloader_|. However that object was destroyed above.
- profile_ = NULL;
+ profile_ = nullptr;
}
void GAIAInfoUpdateService::ScheduleNextUpdate() {

Powered by Google App Engine
This is Rietveld 408576698