Chromium Code Reviews| Index: chrome/browser/search/suggestions/image_fetcher_impl.cc |
| diff --git a/chrome/browser/search/suggestions/image_fetcher_impl.cc b/chrome/browser/search/suggestions/image_fetcher_impl.cc |
| index 86c18a80c81cdf1f223e9972e033c9bc97cc8d69..4bb50ad100aaafd5951efec1682325d853ca8528 100644 |
| --- a/chrome/browser/search/suggestions/image_fetcher_impl.cc |
| +++ b/chrome/browser/search/suggestions/image_fetcher_impl.cc |
| @@ -9,6 +9,7 @@ |
| #include "content/public/browser/browser_thread.h" |
| #include "net/base/load_flags.h" |
| #include "net/url_request/url_request_context_getter.h" |
| +#include "ui/gfx/image/image.h" |
| namespace suggestions { |
| @@ -36,7 +37,7 @@ void ImageFetcherImpl::SetImageFetcherDelegate( |
| void ImageFetcherImpl::StartOrQueueNetworkRequest( |
| const GURL& url, const GURL& image_url, |
| - base::Callback<void(const GURL&, const SkBitmap*)> callback) { |
| + base::Callback<void(const GURL&, const gfx::Image&)> callback) { |
| // Before starting to fetch the image. Look for a request in progress for |
| // |image_url|, and queue if appropriate. |
| ImageRequestMap::iterator it = pending_net_requests_.find(image_url); |
| @@ -65,17 +66,23 @@ void ImageFetcherImpl::OnFetchComplete(const GURL& image_url, |
| ImageRequest* request = &image_iter->second; |
| - // Here |bitmap| could be NULL or a pointer to a bitmap which is owned by the |
| - // BitmapFetcher and which ceases to exist after this function. Pass the |
| - // un-owned pointer to the registered callbacks. |
| + // Here |bitmap| could be NULL. In this case an empty image is passed to the |
| + // callbacks and delegate. The pointer to the bitmap which is owned by the |
| + // BitmapFetcher ceases to exist after this function. The created gfx::Image |
| + // shares the pixels with the |bitmap|. The image is passed to the callbacks |
| + // and delegate that are run synchronously. |
| + gfx::Image image; |
| + if (bitmap != nullptr) |
| + image = gfx::Image::CreateFrom1xBitmap(*bitmap); |
| + |
| for (CallbackVector::iterator callback_iter = request->callbacks.begin(); |
| callback_iter != request->callbacks.end(); ++callback_iter) { |
|
Marc Treib
2016/05/17 14:12:01
optional nit: You could replace this with a range-
markusheintz_
2016/05/17 14:26:45
Good idea. Done
|
| - callback_iter->Run(request->url, bitmap); |
| + callback_iter->Run(request->url, image); |
| } |
| // Inform the ImageFetcherDelegate. |
| if (delegate_) { |
| - delegate_->OnImageFetched(request->url, bitmap); |
| + delegate_->OnImageFetched(request->url, image); |
| } |
| // Erase the completed ImageRequest. |