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

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

Issue 1127113003: Don't try to download 'NothingToDownload' placeholder avatar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify the comments a bit. Created 5 years, 7 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/profile_info_cache.cc
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index b83881a561093bbac9f629c7546ac0acaa6f8e82..e80e0304a4f78b564b1f23f672230c73931bf196 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -905,6 +905,12 @@ void ProfileInfoCache::DownloadHighResAvatarIfNeeded(
#endif
DCHECK(!disable_avatar_download_for_testing_);
+ // If this is the placeholder avatar, it is already included in the
+ // resources, so it doesn't need to be downloaded (and it will never be
+ // requested from disk by GetHighResAvatarOfProfileAtIndex).
+ if (icon_index == profiles::GetPlaceholderAvatarIndex())
+ return;
+
const base::FilePath& file_path =
profiles::GetPathOfHighResAvatarAtIndex(icon_index);
base::Closure callback =
@@ -1036,20 +1042,21 @@ void ProfileInfoCache::UpdateSortForProfileIndex(size_t index) {
const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex(
size_t index) const {
- int avatar_index = GetAvatarIconIndexOfProfileAtIndex(index);
- std::string key = profiles::GetDefaultAvatarIconFileNameAtIndex(avatar_index);
+ const size_t avatar_index = GetAvatarIconIndexOfProfileAtIndex(index);
// If this is the placeholder avatar, it is already included in the
// resources, so it doesn't need to be downloaded.
- if (!strcmp(key.c_str(), profiles::GetNoHighResAvatarFileName())) {
+ if (avatar_index == profiles::GetPlaceholderAvatarIndex()) {
return &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
profiles::GetPlaceholderAvatarIconResourceID());
}
- base::FilePath image_path =
+ const std::string file_name =
+ profiles::GetDefaultAvatarIconFileNameAtIndex(avatar_index);
+ const base::FilePath image_path =
profiles::GetPathOfHighResAvatarAtIndex(avatar_index);
- return LoadAvatarPictureFromPath(GetPathOfProfileAtIndex(index),
- key, image_path);
+ return LoadAvatarPictureFromPath(GetPathOfProfileAtIndex(index), file_name,
+ image_path);
}
void ProfileInfoCache::DownloadHighResAvatar(
@@ -1064,8 +1071,9 @@ void ProfileInfoCache::DownloadHighResAvatar(
tracked_objects::ScopedTracker tracking_profile1(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"461175 ProfileInfoCache::DownloadHighResAvatar::GetFileName"));
- const std::string file_name =
+ const char* file_name =
profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index);
+ DCHECK(file_name);
// If the file is already being downloaded, don't start another download.
if (avatar_images_downloads_in_progress_.count(file_name))
return;
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.h ('k') | chrome/browser/profiles/profile_info_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698