Chromium Code Reviews| Index: chrome/browser/profiles/profile_avatar_downloader.cc |
| diff --git a/chrome/browser/profiles/profile_avatar_downloader.cc b/chrome/browser/profiles/profile_avatar_downloader.cc |
| index 69f4a4c94130debd1adb8a4ae19a419b63130465..46b255d82c1eed5e471c54cc307f4655c8f52977 100644 |
| --- a/chrome/browser/profiles/profile_avatar_downloader.cc |
| +++ b/chrome/browser/profiles/profile_avatar_downloader.cc |
| @@ -19,10 +19,11 @@ const char kHighResAvatarDownloadUrlPrefix[] = |
| ProfileAvatarDownloader::ProfileAvatarDownloader( |
| size_t icon_index, |
| const base::FilePath& profile_path, |
| - ProfileInfoCache* cache) |
| + ProfileAttributesStorage* storage) |
| : icon_index_(icon_index), |
| profile_path_(profile_path), |
| - cache_(cache) { |
| + storage_(storage) { |
| + DCHECK(storage); |
| GURL url(std::string(kHighResAvatarDownloadUrlPrefix) + |
| profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index)); |
| fetcher_.reset(new chrome::BitmapFetcher(url, this)); |
| @@ -48,13 +49,20 @@ void ProfileAvatarDownloader::Start() { |
| // BitmapFetcherDelegate overrides. |
| void ProfileAvatarDownloader::OnFetchComplete(const GURL& url, |
| const SkBitmap* bitmap) { |
| - if (!bitmap || !cache_) |
| + if (!bitmap) |
| return; |
| - // Decode the downloaded bitmap. Ownership of the image is taken by |cache_|. |
| + ProfileAttributesEntry* entry; |
| + if (storage_->GetProfileAttributesWithPath(profile_path_, &entry)) { |
|
Mike Lerman
2016/03/18 17:10:44
just confirming... we don't use this flow for the
lwchkg
2016/03/19 18:48:46
Currently no, but it DOES make sense for guests to
Mike Lerman
2016/03/30 01:18:10
Sure, leave it as is for now, then. I like reducin
lwchkg
2016/03/31 19:32:26
We have those funny anonymous animals in Google Do
|
| + // If the profile is deleted during the async operation, we cannot find the |
| + // profile attributes entry. In this case, discard the downloaded bitmap. |
| + return; |
| + } |
| + |
| + // Decode the downloaded bitmap. Ownership of the image is taken by profile |
| + // attributes storage. |
| gfx::Image image = gfx::Image::CreateFrom1xBitmap(*bitmap); |
| - cache_->SaveAvatarImageAtPath(&image, |
| + entry->SaveAvatarImage(&image, |
| profiles::GetDefaultAvatarIconFileNameAtIndex(icon_index_), |
| - profiles::GetPathOfHighResAvatarAtIndex(icon_index_), |
| - profile_path_); |
| + profiles::GetPathOfHighResAvatarAtIndex(icon_index_)); |
| } |