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

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

Issue 890873004: ProfileInfoCache: Don't delete ProfileAvatarDownloader while we're being called by it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/profile_info_cache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 be3618a423e757bb492ec475e42d233959585b99..7a10af3b887a1c2ddfd256f3d14be4d2c2424bb6 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -148,6 +148,10 @@ void DeleteBitmap(const base::FilePath& image_path) {
base::DeleteFile(image_path, false);
}
+void DeleteDownloader(ProfileAvatarDownloader* downloader) {
noms (inactive) 2015/01/30 16:05:40 nit: add a comment as to why we would need to post
Marc Treib 2015/01/30 16:12:40 Done. This would be much nicer as an inline lambda
+ delete downloader;
+}
+
} // namespace
ProfileInfoCache::ProfileInfoCache(PrefService* prefs,
@@ -903,9 +907,14 @@ void ProfileInfoCache::SaveAvatarImageAtPath(
// Remove the file from the list of downloads in progress. Note that this list
// only contains the high resolution avatars, and not the Gaia profile images.
- if (avatar_images_downloads_in_progress_[key]) {
- delete avatar_images_downloads_in_progress_[key];
- avatar_images_downloads_in_progress_[key] = NULL;
+ auto downloader_iter = avatar_images_downloads_in_progress_.find(key);
noms (inactive) 2015/01/30 16:05:40 YAY AUTO!!!
+ if (downloader_iter != avatar_images_downloads_in_progress_.end()) {
+ // We mustn't delete the avatar downloader right here, since we're being
+ // called by it.
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&DeleteDownloader,
+ downloader_iter->second));
+ avatar_images_downloads_in_progress_.erase(downloader_iter);
}
if (!data->size()) {
@@ -1048,7 +1057,7 @@ void ProfileInfoCache::DownloadHighResAvatar(
const std::string file_name =
profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index);
// If the file is already being downloaded, don't start another download.
- if (avatar_images_downloads_in_progress_[file_name])
+ if (avatar_images_downloads_in_progress_.count(file_name))
return;
// Start the download for this file. The cache takes ownership of the
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698