Chromium Code Reviews| 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 "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class URLFetcher; | 21 class URLFetcher; |
| 22 class URLRequestContextGetter; | 22 class URLRequestContextGetter; |
| 23 } // namespace net | 23 } // namespace net |
| 24 | 24 |
| 25 namespace image_fetcher { | 25 namespace image_fetcher { |
| 26 | 26 |
| 27 struct RequestMetadata { | |
|
gambard
2017/02/09 13:44:12
I don't know if this should be inside the class?
Marc Treib
2017/02/09 13:49:48
That's mostly a matter of taste IMO. I tend to sli
sdefresne
2017/02/09 13:55:28
drive-by: having the class separate make it easier
gambard
2017/02/09 15:10:32
Actually, I have moved it to its own class.
gambard
2017/02/09 15:10:32
Ok, I think I will let it outside the class as it
| |
| 28 std::string mime_type; | |
| 29 | |
| 30 bool operator==(const RequestMetadata& rhs) const { | |
|
Marc Treib
2017/02/09 13:49:48
Are the equality operators required?
sdefresne
2017/02/09 13:55:28
Even if they are required, they generally do not n
gambard
2017/02/09 15:10:32
They are mainly here for testing (verifying that t
| |
| 31 return mime_type == rhs.mime_type; | |
| 32 } | |
| 33 | |
| 34 bool operator!=(const RequestMetadata& rhs) const { return !operator==(rhs); } | |
| 35 }; | |
| 36 | |
| 27 class ImageDataFetcher : public net::URLFetcherDelegate { | 37 class ImageDataFetcher : public net::URLFetcherDelegate { |
| 28 public: | 38 public: |
| 29 using ImageDataFetcherCallback = | 39 using ImageDataFetcherCallback = |
| 30 base::Callback<void(const std::string& image_data)>; | 40 base::Callback<void(const std::string& image_data, |
| 41 const RequestMetadata& request_metadata)>; | |
| 31 | 42 |
| 32 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; | 43 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; |
| 33 | 44 |
| 34 explicit ImageDataFetcher( | 45 explicit ImageDataFetcher( |
| 35 net::URLRequestContextGetter* url_request_context_getter); | 46 net::URLRequestContextGetter* url_request_context_getter); |
| 36 ~ImageDataFetcher() override; | 47 ~ImageDataFetcher() override; |
| 37 | 48 |
| 38 // Sets a service name against which to track data usage. | 49 // Sets a service name against which to track data usage. |
| 39 void SetDataUseServiceName(DataUseServiceName data_use_service_name); | 50 void SetDataUseServiceName(DataUseServiceName data_use_service_name); |
| 40 | 51 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 70 // get individual URLFetchers and modify their state. Outside of tests this ID | 81 // get individual URLFetchers and modify their state. Outside of tests this ID |
| 71 // is not used. | 82 // is not used. |
| 72 int next_url_fetcher_id_; | 83 int next_url_fetcher_id_; |
| 73 | 84 |
| 74 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher); | 85 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher); |
| 75 }; | 86 }; |
| 76 | 87 |
| 77 } // namespace image_fetcher | 88 } // namespace image_fetcher |
| 78 | 89 |
| 79 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ | 90 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_DATA_FETCHER_H_ |
| OLD | NEW |