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

Unified Diff: components/image_fetcher/ios/ios_image_data_fetcher_wrapper.mm

Issue 2674653003: Use IOSImageDataFetcherWrapper in BrowserViewController (Closed)
Patch Set: Change IOSImageDataFetcherWrapper wrapping Created 3 years, 10 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
« no previous file with comments | « components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h ('k') | ios/chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/image_fetcher/ios/ios_image_data_fetcher_wrapper.mm
diff --git a/components/image_fetcher/ios/ios_image_data_fetcher_wrapper.mm b/components/image_fetcher/ios/ios_image_data_fetcher_wrapper.mm
index 6bf24c690c545a74e944eada8636b97af9fa2669..30eeb6b16a5020ede34d0863c39e73aa82c0de32 100644
--- a/components/image_fetcher/ios/ios_image_data_fetcher_wrapper.mm
+++ b/components/image_fetcher/ios/ios_image_data_fetcher_wrapper.mm
@@ -86,28 +86,20 @@ IOSImageDataFetcherWrapper::~IOSImageDataFetcherWrapper() {}
void IOSImageDataFetcherWrapper::FetchImageDataWebpDecoded(
const GURL& image_url,
IOSImageDataFetcherCallback callback) {
+ image_data_fetcher_.FetchImageData(image_url,
+ CallbackForImageDataFetcher(callback));
+}
+
+void IOSImageDataFetcherWrapper::FetchImageDataWebpDecoded(
+ const GURL& image_url,
+ IOSImageDataFetcherCallback callback,
+ const std::string& referrer,
+ net::URLRequest::ReferrerPolicy referrer_policy) {
DCHECK(callback);
- scoped_refptr<base::TaskRunner> task_runner = task_runner_;
- ImageDataFetcher::ImageDataFetcherCallback local_callback =
- base::BindBlockArc(^(const std::string& image_data) {
- // Create a NSData from the returned data and notify the callback.
- NSData* data =
- [NSData dataWithBytes:image_data.data() length:image_data.size()];
-
- if (data.length < 12 ||
- image_data.compare(0, 4, kWEBPFirstMagicPattern) != 0 ||
- image_data.compare(8, 4, kWEBPSecondMagicPattern) != 0) {
- callback(data);
- return;
- }
-
- // The image is a webp image.
- base::PostTaskAndReplyWithResult(task_runner.get(), FROM_HERE,
- base::Bind(&DecodeWebpImage, data),
- base::BindBlockArc(callback));
- });
- image_data_fetcher_.FetchImageData(image_url, local_callback);
+ image_data_fetcher_.FetchImageData(image_url,
+ CallbackForImageDataFetcher(callback),
+ referrer, referrer_policy);
}
void IOSImageDataFetcherWrapper::SetDataUseServiceName(
@@ -115,4 +107,28 @@ void IOSImageDataFetcherWrapper::SetDataUseServiceName(
image_data_fetcher_.SetDataUseServiceName(data_use_service_name);
}
+ImageDataFetcher::ImageDataFetcherCallback
+IOSImageDataFetcherWrapper::CallbackForImageDataFetcher(
+ IOSImageDataFetcherCallback callback) {
+ scoped_refptr<base::TaskRunner> task_runner = task_runner_;
+
+ return base::BindBlockArc(^(const std::string& image_data) {
+ // Create a NSData from the returned data and notify the callback.
+ NSData* data =
+ [NSData dataWithBytes:image_data.data() length:image_data.size()];
+
+ if (data.length < 12 ||
+ image_data.compare(0, 4, kWEBPFirstMagicPattern) != 0 ||
+ image_data.compare(8, 4, kWEBPSecondMagicPattern) != 0) {
+ callback(data);
+ return;
+ }
+
+ // The image is a webp image.
+ base::PostTaskAndReplyWithResult(task_runner.get(), FROM_HERE,
+ base::Bind(&DecodeWebpImage, data),
+ base::BindBlockArc(callback));
+ });
+}
+
} // namespace image_fetcher
« no previous file with comments | « components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h ('k') | ios/chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698