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

Side by Side Diff: chrome/browser/search/thumbnail_source.cc

Issue 2757643002: components/image_fetcher: Expose RequestMetadata from ImageFetcher (Closed)
Patch Set: logo_bridge Created 3 years, 9 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
« no previous file with comments | « chrome/browser/search/thumbnail_source.h ('k') | components/image_fetcher/image_fetcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/search/thumbnail_source.h" 5 #include "chrome/browser/search/thumbnail_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 fallback_thumbnail_url_str = path.substr(pos + strlen(kUrlDelimiter)); 112 fallback_thumbnail_url_str = path.substr(pos + strlen(kUrlDelimiter));
113 } 113 }
114 114
115 *page_url = GURL(page_url_str); 115 *page_url = GURL(page_url_str);
116 *fallback_thumbnail_url = GURL(fallback_thumbnail_url_str); 116 *fallback_thumbnail_url = GURL(fallback_thumbnail_url_str);
117 } 117 }
118 118
119 void ThumbnailSource::SendFetchedUrlImage( 119 void ThumbnailSource::SendFetchedUrlImage(
120 const content::URLDataSource::GotDataCallback& callback, 120 const content::URLDataSource::GotDataCallback& callback,
121 const std::string& url, 121 const std::string& url,
122 const gfx::Image& image) { 122 const gfx::Image& image,
123 const image_fetcher::RequestMetadata& metadata) {
123 // In case the image could not be retrieved an empty image is returned. 124 // In case the image could not be retrieved an empty image is returned.
124 if (image.IsEmpty()) { 125 if (image.IsEmpty()) {
125 callback.Run(default_thumbnail_.get()); 126 callback.Run(default_thumbnail_.get());
126 return; 127 return;
127 } 128 }
128 129
129 const SkBitmap* bitmap = image.ToSkBitmap(); 130 const SkBitmap* bitmap = image.ToSkBitmap();
130 scoped_refptr<base::RefCountedBytes> encoded_data( 131 scoped_refptr<base::RefCountedBytes> encoded_data(
131 new base::RefCountedBytes()); 132 new base::RefCountedBytes());
132 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) { 133 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) {
133 callback.Run(default_thumbnail_.get()); 134 callback.Run(default_thumbnail_.get());
134 return; 135 return;
135 } 136 }
136 137
137 callback.Run(encoded_data.get()); 138 callback.Run(encoded_data.get());
138 } 139 }
OLDNEW
« no previous file with comments | « chrome/browser/search/thumbnail_source.h ('k') | components/image_fetcher/image_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698