OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/download/download_request_core.h" | 5 #include "content/browser/download/download_request_core.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
34 #include "device/power_save_blocker/power_save_blocker.h" | 34 #include "device/power_save_blocker/power_save_blocker.h" |
35 #include "net/base/elements_upload_data_stream.h" | 35 #include "net/base/elements_upload_data_stream.h" |
36 #include "net/base/io_buffer.h" | 36 #include "net/base/io_buffer.h" |
37 #include "net/base/load_flags.h" | 37 #include "net/base/load_flags.h" |
38 #include "net/base/net_errors.h" | 38 #include "net/base/net_errors.h" |
39 #include "net/base/upload_bytes_element_reader.h" | 39 #include "net/base/upload_bytes_element_reader.h" |
40 #include "net/http/http_request_headers.h" | 40 #include "net/http/http_request_headers.h" |
41 #include "net/http/http_response_headers.h" | 41 #include "net/http/http_response_headers.h" |
42 #include "net/http/http_status_code.h" | 42 #include "net/http/http_status_code.h" |
43 #include "net/traffic_annotation/network_traffic_annotation.h" | |
43 #include "net/url_request/url_request_context.h" | 44 #include "net/url_request/url_request_context.h" |
44 | 45 |
45 namespace content { | 46 namespace content { |
46 | 47 |
47 namespace { | 48 namespace { |
48 | 49 |
49 // This is a UserData::Data that will be attached to a URLRequest as a | 50 // This is a UserData::Data that will be attached to a URLRequest as a |
50 // side-channel for passing download parameters. | 51 // side-channel for passing download parameters. |
51 class DownloadRequestData : public base::SupportsUserData::Data { | 52 class DownloadRequestData : public base::SupportsUserData::Data { |
52 public: | 53 public: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // static | 110 // static |
110 std::unique_ptr<net::URLRequest> DownloadRequestCore::CreateRequestOnIOThread( | 111 std::unique_ptr<net::URLRequest> DownloadRequestCore::CreateRequestOnIOThread( |
111 uint32_t download_id, | 112 uint32_t download_id, |
112 DownloadUrlParameters* params) { | 113 DownloadUrlParameters* params) { |
113 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 114 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
114 DCHECK(download_id == DownloadItem::kInvalidId || | 115 DCHECK(download_id == DownloadItem::kInvalidId || |
115 !params->content_initiated()) | 116 !params->content_initiated()) |
116 << "Content initiated downloads shouldn't specify a download ID"; | 117 << "Content initiated downloads shouldn't specify a download ID"; |
117 DCHECK(params->offset() >= 0); | 118 DCHECK(params->offset() >= 0); |
118 | 119 |
120 net::NetworkTrafficAnnotationTag traffic_annotation = | |
121 net::DefineNetworkTrafficAnnotation("...", R"( | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
download_manager_url_request
| |
122 semantics { | |
123 sender: "..." | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
download_manager
| |
124 description: "..." | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
A download request that can come from a variety of
| |
125 trigger: "..." | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
This needs to be filled in based on who is buildin
| |
126 data: "..." | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
Could you clarify, do we want to describe the data
| |
127 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER/LOCAL | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
WEBSITE. Although in the future we'll need GOOGLE
| |
128 } | |
129 policy { | |
130 cookies_allowed: false/true | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
true. It depends on the caller and which UrlReque
| |
131 cookies_store: "..." | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
Same as above. Probably depends on the call site.
| |
132 setting: "..." | |
David Trainor- moved to gerrit
2017/05/23 01:07:40
Also depends on the call site. Sadly it looks lik
| |
133 chrome_policy { | |
134 [POLICY_NAME] { | |
135 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
136 [POLICY_NAME]: ... //(value to disable it) | |
137 } | |
138 } | |
139 policy_exception_justification: "..." | |
140 })"); | |
119 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and | 141 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and |
120 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so | 142 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so |
121 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. | 143 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. |
122 std::unique_ptr<net::URLRequest> request( | 144 std::unique_ptr<net::URLRequest> request( |
123 params->url_request_context_getter() | 145 params->url_request_context_getter() |
124 ->GetURLRequestContext() | 146 ->GetURLRequestContext() |
125 ->CreateRequest(params->url(), net::DEFAULT_PRIORITY, nullptr)); | 147 ->CreateRequest(params->url(), net::DEFAULT_PRIORITY, nullptr, |
148 traffic_annotation)); | |
126 request->set_method(params->method()); | 149 request->set_method(params->method()); |
127 | 150 |
128 if (!params->post_body().empty()) { | 151 if (!params->post_body().empty()) { |
129 const std::string& body = params->post_body(); | 152 const std::string& body = params->post_body(); |
130 std::unique_ptr<net::UploadElementReader> reader( | 153 std::unique_ptr<net::UploadElementReader> reader( |
131 net::UploadOwnedBytesElementReader::CreateWithString(body)); | 154 net::UploadOwnedBytesElementReader::CreateWithString(body)); |
132 request->set_upload( | 155 request->set_upload( |
133 net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); | 156 net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); |
134 } | 157 } |
135 | 158 |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 // old servers that didn't implement "If-Match" and must be ignored when | 713 // old servers that didn't implement "If-Match" and must be ignored when |
691 // "If-Match" presents. | 714 // "If-Match" presents. |
692 if (has_last_modified) { | 715 if (has_last_modified) { |
693 request->SetExtraRequestHeaderByName( | 716 request->SetExtraRequestHeaderByName( |
694 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), | 717 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), |
695 true); | 718 true); |
696 } | 719 } |
697 } | 720 } |
698 | 721 |
699 } // namespace content | 722 } // namespace content |
OLD | NEW |