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

Side by Side Diff: components/image_fetcher/core/image_data_fetcher.h

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: Annotation updated. Created 3 years, 7 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
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_CORE_IMAGE_DATA_FETCHER_H_ 5 #ifndef COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_DATA_FETCHER_H_
6 #define COMPONENTS_IMAGE_FETCHER_CORE_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 "base/optional.h" 15 #include "base/optional.h"
16 #include "components/data_use_measurement/core/data_use_user_data.h" 16 #include "components/data_use_measurement/core/data_use_user_data.h"
17 #include "components/image_fetcher/core/request_metadata.h" 17 #include "components/image_fetcher/core/request_metadata.h"
18 #include "net/traffic_annotation/network_traffic_annotation.h"
18 #include "net/url_request/url_fetcher_delegate.h" 19 #include "net/url_request/url_fetcher_delegate.h"
19 #include "net/url_request/url_request.h" 20 #include "net/url_request/url_request.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 namespace net { 23 namespace net {
23 class URLFetcher; 24 class URLFetcher;
24 class URLRequestContextGetter; 25 class URLRequestContextGetter;
25 } // namespace net 26 } // namespace net
26 27
27 namespace image_fetcher { 28 namespace image_fetcher {
(...skipping 17 matching lines...) Expand all
45 // Sets a service name against which to track data usage. 46 // Sets a service name against which to track data usage.
46 void SetDataUseServiceName(DataUseServiceName data_use_service_name); 47 void SetDataUseServiceName(DataUseServiceName data_use_service_name);
47 48
48 // Sets an upper limit for image downloads. 49 // Sets an upper limit for image downloads.
49 // Already running downloads are affected. 50 // Already running downloads are affected.
50 void SetImageDownloadLimit(base::Optional<int64_t> max_download_bytes); 51 void SetImageDownloadLimit(base::Optional<int64_t> max_download_bytes);
51 52
52 // Fetches the raw image bytes from the given |image_url| and calls the given 53 // Fetches the raw image bytes from the given |image_url| and calls the given
53 // |callback|. The callback is run even if fetching the URL fails. In case 54 // |callback|. The callback is run even if fetching the URL fails. In case
54 // of an error an empty string is passed to the callback. 55 // of an error an empty string is passed to the callback.
55 void FetchImageData(const GURL& image_url, 56 void FetchImageData(
56 const ImageDataFetcherCallback& callback); 57 const GURL& image_url,
58 const ImageDataFetcherCallback& callback,
59 const net::NetworkTrafficAnnotationTag& traffic_annotation);
57 60
58 // Like above, but lets the caller set a referrer. 61 // Like above, but lets the caller set a referrer.
59 void FetchImageData(const GURL& image_url, 62 void FetchImageData(
60 const ImageDataFetcherCallback& callback, 63 const GURL& image_url,
61 const std::string& referrer, 64 const ImageDataFetcherCallback& callback,
62 net::URLRequest::ReferrerPolicy referrer_policy); 65 const std::string& referrer,
66 net::URLRequest::ReferrerPolicy referrer_policy,
67 const net::NetworkTrafficAnnotationTag& traffic_annotation);
63 68
64 private: 69 private:
65 struct ImageDataFetcherRequest; 70 struct ImageDataFetcherRequest;
66 71
67 // Methods inherited from URLFetcherDelegate 72 // Methods inherited from URLFetcherDelegate
68 void OnURLFetchComplete(const net::URLFetcher* source) override; 73 void OnURLFetchComplete(const net::URLFetcher* source) override;
69 void OnURLFetchDownloadProgress(const net::URLFetcher* source, 74 void OnURLFetchDownloadProgress(const net::URLFetcher* source,
70 int64_t current, 75 int64_t current,
71 int64_t total, 76 int64_t total,
72 int64_t current_network_bytes) override; 77 int64_t current_network_bytes) override;
(...skipping 19 matching lines...) Expand all
92 97
93 // Upper limit for the number of bytes to download per image. 98 // Upper limit for the number of bytes to download per image.
94 base::Optional<int64_t> max_download_bytes_; 99 base::Optional<int64_t> max_download_bytes_;
95 100
96 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher); 101 DISALLOW_COPY_AND_ASSIGN(ImageDataFetcher);
97 }; 102 };
98 103
99 } // namespace image_fetcher 104 } // namespace image_fetcher
100 105
101 #endif // COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_DATA_FETCHER_H_ 106 #endif // COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_DATA_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698