OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ | 5 #ifndef COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ |
6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ | 6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "components/data_use_measurement/core/data_use_user_data.h" | 15 #include "components/data_use_measurement/core/data_use_user_data.h" |
16 #include "components/image_fetcher/request_metadata.h" | 16 #include "components/image_fetcher/request_metadata.h" |
17 #include "net/url_request/url_fetcher.h" | |
18 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
19 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
21 | 20 |
22 namespace net { | 21 namespace net { |
23 class URLFetcher; | 22 class URLFetcher; |
24 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
25 } // namespace net | 24 } // namespace net |
26 | 25 |
27 namespace image_fetcher { | 26 namespace image_fetcher { |
28 | 27 |
29 class ImageDataFetcher : public net::URLFetcherDelegate { | 28 class ImageDataFetcher : public net::URLFetcherDelegate { |
30 public: | 29 public: |
31 // Impossible http response code. Used to signal that no http response code | |
32 // was received. | |
33 enum ResponseCode { | |
34 RESPONSE_CODE_INVALID = net::URLFetcher::RESPONSE_CODE_INVALID | |
35 }; | |
36 | |
37 // Callback with the |image_data|. If an error prevented a http response, | |
38 // |request_metadata.response_code| will be RESPONSE_CODE_INVALID. | |
39 using ImageDataFetcherCallback = | 30 using ImageDataFetcherCallback = |
40 base::Callback<void(const std::string& image_data, | 31 base::Callback<void(const std::string& image_data, |
41 const RequestMetadata& request_metadata)>; | 32 const RequestMetadata& request_metadata)>; |
42 | 33 |
43 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; | 34 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; |
44 | 35 |
45 explicit ImageDataFetcher( | 36 explicit ImageDataFetcher( |
46 net::URLRequestContextGetter* url_request_context_getter); | 37 net::URLRequestContextGetter* url_request_context_getter); |
47 ~ImageDataFetcher() override; | 38 ~ImageDataFetcher() override; |
48 | 39 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // get individual URLFetchers and modify their state. Outside of tests this ID | 72 // get individual URLFetchers and modify their state. Outside of tests this ID |
82 // is not used. | 73 // is not used. |
83 int next_url_fetcher_id_; | 74 int next_url_fetcher_id_; |
84 | 75 |
85 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher); | 76 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher); |
86 }; | 77 }; |
87 | 78 |
88 } // namespace image_fetcher | 79 } // namespace image_fetcher |
89 | 80 |
90 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ | 81 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ |
OLD | NEW |