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

Side by Side Diff: components/image_fetcher/ios/ios_image_data_fetcher.h

Issue 2652893005: Create the IOSImageDataFetcher (Closed)
Patch Set: Address comments 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 unified diff | Download patch
OLDNEW
(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_H_
6 #define COMPONENTS_IMAGE_FETCHER_IOS_IOS_IMAGE_DATA_FETCHER_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 (^)(int http_response_code,
31 NSData* data);
32
33 class IOSImageDataFetcher {
34 public:
35 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName;
36
37 // The TaskRunner is used to eventually decode the image.
38 IOSImageDataFetcher(net::URLRequestContextGetter* url_request_context_getter,
39 const scoped_refptr<base::TaskRunner>& task_runner);
40 virtual ~IOSImageDataFetcher();
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_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698