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

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

Issue 8742009: Cache GAIA profile picture URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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_downloader.cc
diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc
index da6eccb92c2e55f1dee4994df7b482e33d1c512e..e22950956d72f3aa45b6b98c391941d4832c702a 100644
--- a/chrome/browser/profiles/profile_downloader.cc
+++ b/chrome/browser/profiles/profile_downloader.cc
@@ -172,7 +172,8 @@ bool ProfileDownloader::IsDefaultProfileImageURL(const std::string& url) const {
}
ProfileDownloader::ProfileDownloader(ProfileDownloaderDelegate* delegate)
- : delegate_(delegate) {
+ : delegate_(delegate),
+ picture_result_(PICTURE_FAILED) {
DCHECK(delegate_);
}
@@ -209,6 +210,15 @@ SkBitmap ProfileDownloader::GetProfilePicture() const {
return profile_picture_;
}
+ProfileDownloader::PictureResult ProfileDownloader::GetProfilePictureResult()
+ const {
+ return picture_result_;
+}
+
+std::string ProfileDownloader::GetProfilePictureURL() const {
+ return picture_url_;
+}
+
void ProfileDownloader::StartFetchingImage() {
VLOG(1) << "Fetching user entry with token: " << auth_token_;
user_entry_fetcher_.reset(content::URLFetcher::Create(
@@ -243,10 +253,17 @@ void ProfileDownloader::OnURLFetchComplete(const content::URLFetcher* source) {
return;
}
if (IsDefaultProfileImageURL(image_url)) {
+ picture_result_ = PICTURE_DEFAULT;
Ivan Korotkov 2011/11/30 14:35:44 Please add VLOG here and in the next if ()
sail 2011/11/30 19:00:23 Done.
+ delegate_->OnDownloadComplete(this, true);
+ return;
+ }
+ if (image_url == delegate_->GetCachedPictureURL()) {
Ivan Korotkov 2011/11/30 14:35:44 Since GetCachedPictureURL() has to return somethin
sail 2011/11/30 19:00:23 Done.
+ picture_result_ = PICTURE_CACHED;
delegate_->OnDownloadComplete(this, true);
return;
}
VLOG(1) << "Fetching profile image from " << image_url;
+ picture_url_ = image_url;
profile_image_fetcher_.reset(content::URLFetcher::Create(
GURL(image_url), content::URLFetcher::GET, this));
profile_image_fetcher_->SetRequestContext(
@@ -273,6 +290,7 @@ void ProfileDownloader::OnImageDecoded(const ImageDecoder* decoder,
skia::ImageOperations::RESIZE_BEST,
image_size,
image_size);
+ picture_result_ = PICTURE_SUCCESS;
delegate_->OnDownloadComplete(this, true);
}

Powered by Google App Engine
This is Rietveld 408576698