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 #include "components/image_fetcher/core/image_data_fetcher.h" | 5 #include "components/image_fetcher/core/image_data_fetcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
| 10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
| 11 #include "net/http/http_status_code.h" | 11 #include "net/http/http_status_code.h" |
| 12 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 12 #include "net/url_request/url_fetcher.h" | 13 #include "net/url_request/url_fetcher.h" |
| 13 #include "net/url_request/url_request_context_getter.h" | 14 #include "net/url_request/url_request_context_getter.h" |
| 14 #include "net/url_request/url_request_status.h" | 15 #include "net/url_request/url_request_status.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 using data_use_measurement::DataUseUserData; | 18 using data_use_measurement::DataUseUserData; |
| 18 | 19 |
| 19 namespace image_fetcher { | 20 namespace image_fetcher { |
| 20 | 21 |
| 21 // An active image URL fetcher request. The struct contains the related requests | 22 // An active image URL fetcher request. The struct contains the related requests |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 FetchImageData( | 59 FetchImageData( |
| 59 image_url, callback, /*referrer=*/std::string(), | 60 image_url, callback, /*referrer=*/std::string(), |
| 60 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE); | 61 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void ImageDataFetcher::FetchImageData( | 64 void ImageDataFetcher::FetchImageData( |
| 64 const GURL& image_url, | 65 const GURL& image_url, |
| 65 const ImageDataFetcherCallback& callback, | 66 const ImageDataFetcherCallback& callback, |
| 66 const std::string& referrer, | 67 const std::string& referrer, |
| 67 net::URLRequest::ReferrerPolicy referrer_policy) { | 68 net::URLRequest::ReferrerPolicy referrer_policy) { |
| 68 std::unique_ptr<net::URLFetcher> url_fetcher = net::URLFetcher::Create( | 69 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 69 next_url_fetcher_id_++, image_url, net::URLFetcher::GET, this); | 70 net::DefineNetworkTrafficAnnotation("...", R"( |
| 71 semantics { | |
| 72 sender: "..." | |
|
markusheintz_
2017/05/03 09:04:07
Is there a description of the fields?
E.g. sender
| |
| 73 description: "..." | |
| 74 trigger: "..." | |
|
markusheintz_
2017/05/03 09:04:07
What do you expect here? This list of trigger is d
| |
| 75 data: "..." | |
|
markusheintz_
2017/05/03 09:04:07
raw image data is fetch for a given URL
| |
| 76 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
|
markusheintz_
2017/05/03 09:04:07
It could be all of the options. Not sure how clien
| |
| 77 } | |
| 78 policy { | |
| 79 cookies_allowed: false/true | |
|
markusheintz_
2017/05/03 09:04:07
false.
| |
| 80 cookies_store: "..." | |
|
markusheintz_
2017/05/03 09:04:07
NA
| |
| 81 setting: "..." | |
|
markusheintz_
2017/05/03 09:04:07
none. clients have to do the right thing
| |
| 82 chrome_policy { | |
|
markusheintz_
2017/05/03 09:04:07
There exists no policy. It the responsibility of t
| |
| 83 [POLICY_NAME] { | |
| 84 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 85 [POLICY_NAME]: ... //(value to disable it) | |
| 86 } | |
| 87 } | |
| 88 policy_exception_justification: "..." | |
| 89 })"); | |
| 90 std::unique_ptr<net::URLFetcher> url_fetcher = | |
| 91 net::URLFetcher::Create(next_url_fetcher_id_++, image_url, | |
| 92 net::URLFetcher::GET, this, traffic_annotation); | |
| 70 | 93 |
| 71 DataUseUserData::AttachToFetcher(url_fetcher.get(), data_use_service_name_); | 94 DataUseUserData::AttachToFetcher(url_fetcher.get(), data_use_service_name_); |
| 72 | 95 |
| 73 std::unique_ptr<ImageDataFetcherRequest> request( | 96 std::unique_ptr<ImageDataFetcherRequest> request( |
| 74 new ImageDataFetcherRequest(callback, std::move(url_fetcher))); | 97 new ImageDataFetcherRequest(callback, std::move(url_fetcher))); |
| 75 request->url_fetcher->SetRequestContext(url_request_context_getter_.get()); | 98 request->url_fetcher->SetRequestContext(url_request_context_getter_.get()); |
| 76 request->url_fetcher->SetReferrer(referrer); | 99 request->url_fetcher->SetReferrer(referrer); |
| 77 request->url_fetcher->SetReferrerPolicy(referrer_policy); | 100 request->url_fetcher->SetReferrerPolicy(referrer_policy); |
| 78 request->url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 101 request->url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 79 net::LOAD_DO_NOT_SAVE_COOKIES | | 102 net::LOAD_DO_NOT_SAVE_COOKIES | |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 void ImageDataFetcher::FinishRequest(const net::URLFetcher* source, | 148 void ImageDataFetcher::FinishRequest(const net::URLFetcher* source, |
| 126 const RequestMetadata& metadata, | 149 const RequestMetadata& metadata, |
| 127 const std::string& image_data) { | 150 const std::string& image_data) { |
| 128 auto request_iter = pending_requests_.find(source); | 151 auto request_iter = pending_requests_.find(source); |
| 129 DCHECK(request_iter != pending_requests_.end()); | 152 DCHECK(request_iter != pending_requests_.end()); |
| 130 request_iter->second->callback.Run(image_data, metadata); | 153 request_iter->second->callback.Run(image_data, metadata); |
| 131 pending_requests_.erase(request_iter); | 154 pending_requests_.erase(request_iter); |
| 132 } | 155 } |
| 133 | 156 |
| 134 } // namespace image_fetcher | 157 } // namespace image_fetcher |
| OLD | NEW |