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

Unified Diff: ios/web/public/image_fetcher/image_data_fetcher.h

Issue 2686023003: Use mime type for image extension (Closed)
Patch Set: 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
Index: ios/web/public/image_fetcher/image_data_fetcher.h
diff --git a/ios/web/public/image_fetcher/image_data_fetcher.h b/ios/web/public/image_fetcher/image_data_fetcher.h
index 797a2d3e970456ef0e0e9664528fdc95c8f0a2ff..f5e36bf5edd858edc302e4c1cc54c8393286573f 100644
--- a/ios/web/public/image_fetcher/image_data_fetcher.h
+++ b/ios/web/public/image_fetcher/image_data_fetcher.h
@@ -33,6 +33,14 @@ using ImageFetchedCallback = void (^)(const GURL& url,
int http_response_code,
NSData* data);
+// Callback that informs of the download of an image encoded in |data|,
+// downloaded from |url|, and with the http status |http_response_code|. If the
+// url is a data URL, |http_response_code| is always 200.
+using ImageFetchedCallbackWithMime = void (^)(const GURL& url,
+ int http_response_code,
+ const std::string& mime_type,
+ NSData* data);
+
// Utility class that will retrieve an image from an URL. The image is returned
// as NSData which can be used with +[UIImage imageWithData:]. This class
// usually returns the raw bytes retrieved from the network without any
@@ -51,6 +59,18 @@ class ImageDataFetcher : public net::URLFetcherDelegate {
// URLFetcher.
// This method assumes the request context getter has been set.
// (virtual for testing)
+ virtual void StartDownloadWithMime(
+ const GURL& url,
+ ImageFetchedCallbackWithMime callback,
+ const std::string& referrer,
+ net::URLRequest::ReferrerPolicy referrer_policy);
+
+ // Start downloading the image at the given |url|. The |callback| will be
+ // called with the downloaded image, or nil if any error happened. The
+ // |referrer| and |referrer_policy| will be passed on to the underlying
+ // URLFetcher.
+ // This method assumes the request context getter has been set.
+ // (virtual for testing)
virtual void StartDownload(const GURL& url,
ImageFetchedCallback callback,
const std::string& referrer,
@@ -71,16 +91,19 @@ class ImageDataFetcher : public net::URLFetcherDelegate {
private:
// Runs the callback with the given arguments.
- void RunCallback(const base::mac::ScopedBlock<ImageFetchedCallback>& callback,
- const GURL& url,
- const int http_response_code,
- NSData* data);
+ void RunCallback(
+ const base::mac::ScopedBlock<ImageFetchedCallbackWithMime>& callback,
+ const GURL& url,
+ const int http_response_code,
+ const std::string& mime_type,
+ NSData* data);
// Tracks open download requests. The key is the URLFetcher object doing the
// fetch; the value is the callback to use when the download request
// completes. When a download request completes, the URLFetcher must be
// deleted and the callback called and released.
- std::map<const net::URLFetcher*, ImageFetchedCallback> downloads_in_progress_;
+ std::map<const net::URLFetcher*, ImageFetchedCallbackWithMime>
+ downloads_in_progress_;
scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
// The task runner used to decode images if necessary.
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | ios/web/public/image_fetcher/image_data_fetcher.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698