| 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_CORE_IMAGE_DATA_FETCHER_H_ |
| 6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ | 6 #define COMPONENTS_IMAGE_FETCHER_CORE_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/core/request_metadata.h" |
| 17 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
| 18 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 class URLFetcher; | 22 class URLFetcher; |
| 23 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
| 24 } // namespace net | 24 } // namespace net |
| 25 | 25 |
| 26 namespace image_fetcher { | 26 namespace image_fetcher { |
| 27 | 27 |
| 28 class ImageDataFetcher : public net::URLFetcherDelegate { | 28 class ImageDataFetcher : public net::URLFetcherDelegate { |
| 29 public: | 29 public: |
| 30 | |
| 31 // Callback with the |image_data|. If an error prevented a http response, | 30 // Callback with the |image_data|. If an error prevented a http response, |
| 32 // |request_metadata.response_code| will be RESPONSE_CODE_INVALID. | 31 // |request_metadata.response_code| will be RESPONSE_CODE_INVALID. |
| 33 using ImageDataFetcherCallback = | 32 using ImageDataFetcherCallback = |
| 34 base::Callback<void(const std::string& image_data, | 33 base::Callback<void(const std::string& image_data, |
| 35 const RequestMetadata& request_metadata)>; | 34 const RequestMetadata& request_metadata)>; |
| 36 | 35 |
| 37 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; | 36 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; |
| 38 | 37 |
| 39 explicit ImageDataFetcher( | 38 explicit ImageDataFetcher( |
| 40 net::URLRequestContextGetter* url_request_context_getter); | 39 net::URLRequestContextGetter* url_request_context_getter); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // newly created URLFetcher. The URLFetcher ID can be used during testing to | 73 // newly created URLFetcher. The URLFetcher ID can be used during testing to |
| 75 // get individual URLFetchers and modify their state. Outside of tests this ID | 74 // get individual URLFetchers and modify their state. Outside of tests this ID |
| 76 // is not used. | 75 // is not used. |
| 77 int next_url_fetcher_id_; | 76 int next_url_fetcher_id_; |
| 78 | 77 |
| 79 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher); | 78 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher); |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 } // namespace image_fetcher | 81 } // namespace image_fetcher |
| 83 | 82 |
| 84 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ | 83 #endif // COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_DATA_FETCHER_H_ |
| OLD | NEW |