Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_IMAGE_FETCHER_IOS_IOS_IMAGE_DATA_FETCHER_WRAPPER_H_ | |
| 6 #define COMPONENTS_IMAGE_FETCHER_IOS_IOS_IMAGE_DATA_FETCHER_WRAPPER_H_ | |
| 7 | |
| 8 #import <Foundation/Foundation.h> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "components/data_use_measurement/core/data_use_user_data.h" | |
| 12 | |
| 13 namespace base { | |
| 14 class TaskRunner; | |
| 15 } | |
| 16 | |
| 17 namespace net { | |
| 18 class URLRequestContextGetter; | |
| 19 } | |
| 20 | |
| 21 namespace image_fetcher { | |
| 22 class ImageDataFetcher; | |
| 23 } | |
| 24 | |
| 25 class GURL; | |
| 26 | |
| 27 namespace image_fetcher { | |
| 28 | |
| 29 // Callback that informs of the download of an image encoded in |data|. | |
| 30 using IOSImageDataFetcherCallback = void (^)(NSData* data); | |
| 31 | |
| 32 class IOSImageDataFetcherWrapper { | |
| 33 public: | |
| 34 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; | |
| 35 | |
| 36 // The TaskRunner is used to eventually decode the image. | |
|
Marc Treib
2017/01/31 16:17:25
...in case it is WebP (right?)
gambard
2017/01/31 16:55:53
Done.
| |
| 37 IOSImageDataFetcherWrapper( | |
| 38 net::URLRequestContextGetter* url_request_context_getter, | |
| 39 const scoped_refptr<base::TaskRunner>& task_runner); | |
| 40 virtual ~IOSImageDataFetcherWrapper(); | |
| 41 | |
| 42 // Start downloading the image at the given |image_url|. The |callback| will | |
| 43 // be called with the downloaded image, or nil if any error happened or the | |
| 44 // http response header is not HTTP_OK (200). If the url is a data URL, the | |
| 45 // http response header is considered to be HTTP_OK. | |
| 46 void FetchImageDataWebpDecoded(const GURL& image_url, | |
| 47 IOSImageDataFetcherCallback callback); | |
| 48 | |
| 49 // Sets a service name against which to track data usage. | |
| 50 void SetDataUseServiceName(DataUseServiceName data_use_service_name); | |
| 51 | |
| 52 private: | |
| 53 // The task runner used to decode images if necessary. | |
| 54 const scoped_refptr<base::TaskRunner> task_runner_; | |
| 55 std::unique_ptr<ImageDataFetcher> image_data_fetcher_; | |
| 56 }; | |
| 57 } // namespace image_fetcher | |
| 58 | |
| 59 #endif // COMPONENTS_IMAGE_FETCHER_IOS_IOS_IMAGE_DATA_FETCHER_WRAPPER_H_ | |
| OLD | NEW |