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

Side by Side Diff: chrome/browser/notifications/sync_notifier/image_holder.cc

Issue 222313005: [Profiles] Download high-res avatars using the --new-profile-management flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This class holds the URL to an image and the bitmap for the fetched image, 5 // This class holds the URL to an image and the bitmap for the fetched image,
6 // and has code to fetch the bitmap from the URL. 6 // and has code to fetch the bitmap from the URL.
7 7
8 #include "chrome/browser/notifications/sync_notifier/image_holder.h" 8 #include "chrome/browser/notifications/sync_notifier/image_holder.h"
9 9
10 #include "chrome/browser/profiles/profile.h"
11
10 namespace notifier { 12 namespace notifier {
11 13
12 ImageHolder::ImageHolder(const GURL& low_dpi_url, 14 ImageHolder::ImageHolder(const GURL& low_dpi_url,
13 const GURL& high_dpi_url, 15 const GURL& high_dpi_url,
14 Profile* profile, 16 Profile* profile,
15 ImageHolderDelegate* delegate) 17 ImageHolderDelegate* delegate)
16 : low_dpi_url_(low_dpi_url), 18 : low_dpi_url_(low_dpi_url),
17 high_dpi_url_(high_dpi_url), 19 high_dpi_url_(high_dpi_url),
18 low_dpi_fetched_(false), 20 low_dpi_fetched_(false),
19 high_dpi_fetched_(false), 21 high_dpi_fetched_(false),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (url.is_valid()) { 60 if (url.is_valid()) {
59 fetchers_.push_back(new chrome::BitmapFetcher(url, this)); 61 fetchers_.push_back(new chrome::BitmapFetcher(url, this));
60 DVLOG(2) << __FUNCTION__ << "Pushing bitmap " << url; 62 DVLOG(2) << __FUNCTION__ << "Pushing bitmap " << url;
61 } 63 }
62 } 64 }
63 65
64 void ImageHolder::StartFetch() { 66 void ImageHolder::StartFetch() {
65 // Now that we have queued them all, start the fetching. 67 // Now that we have queued them all, start the fetching.
66 ScopedVector<chrome::BitmapFetcher>::iterator iter; 68 ScopedVector<chrome::BitmapFetcher>::iterator iter;
67 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { 69 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) {
68 (*iter)->Start(profile_); 70 (*iter)->Start(profile_->GetRequestContext());
69 } 71 }
70 } 72 }
71 73
72 // Method inherited from BitmapFetcher delegate. 74 // Method inherited from BitmapFetcher delegate.
73 void ImageHolder::OnFetchComplete(const GURL url, const SkBitmap* bitmap) { 75 void ImageHolder::OnFetchComplete(const GURL url, const SkBitmap* bitmap) {
74 // TODO(petewil): Should I retry if a fetch fails? 76 // TODO(petewil): Should I retry if a fetch fails?
75 // Match the bitmap to the URL to put it into the image with the correct scale 77 // Match the bitmap to the URL to put it into the image with the correct scale
76 // factor. 78 // factor.
77 if (url == low_dpi_url_) { 79 if (url == low_dpi_url_) {
78 low_dpi_fetched_ = true; 80 low_dpi_fetched_ = true;
79 if (bitmap != NULL) 81 if (bitmap != NULL)
80 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0)); 82 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0));
81 } else if (url == high_dpi_url_) { 83 } else if (url == high_dpi_url_) {
82 high_dpi_fetched_ = true; 84 high_dpi_fetched_ = true;
83 if (bitmap != NULL) 85 if (bitmap != NULL)
84 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); 86 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0));
85 } else { 87 } else {
86 DVLOG(2) << __FUNCTION__ << "Unmatched bitmap arrived " << url; 88 DVLOG(2) << __FUNCTION__ << "Unmatched bitmap arrived " << url;
87 } 89 }
88 90
89 // Notify callback of bitmap arrival. 91 // Notify callback of bitmap arrival.
90 delegate_->OnFetchComplete(); 92 delegate_->OnFetchComplete();
91 } 93 }
92 94
93 } // namespace notifier. 95 } // namespace notifier.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698