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

Unified Diff: chrome/browser/search/suggestions/image_fetcher_impl.cc

Issue 1974013002: Replace SkBitmap with gfx::Image in the ImageFetcher API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync again Created 4 years, 7 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
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..5a1c57c69388dd7fa9ed6735f6a61b9950414f10 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,22 @@ 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.
- for (CallbackVector::iterator callback_iter = request->callbacks.begin();
- callback_iter != request->callbacks.end(); ++callback_iter) {
- callback_iter->Run(request->url, bitmap);
+ // 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 (const auto& callback : request->callbacks) {
+ callback.Run(request->url, image);
}
// Inform the ImageFetcherDelegate.
if (delegate_) {
- delegate_->OnImageFetched(request->url, bitmap);
+ delegate_->OnImageFetched(request->url, image);
}
// Erase the completed ImageRequest.

Powered by Google App Engine
This is Rietveld 408576698