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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 request->RemoveUserData(&kKey); | 108 request->RemoveUserData(&kKey); |
109 } | 109 } |
110 | 110 |
111 } // namespace | 111 } // namespace |
112 | 112 |
113 const int DownloadRequestCore::kDownloadByteStreamSize = 100 * 1024; | 113 const int DownloadRequestCore::kDownloadByteStreamSize = 100 * 1024; |
114 | 114 |
115 // static | 115 // static |
116 std::unique_ptr<net::URLRequest> DownloadRequestCore::CreateRequestOnIOThread( | 116 std::unique_ptr<net::URLRequest> DownloadRequestCore::CreateRequestOnIOThread( |
117 uint32_t download_id, | 117 uint32_t download_id, |
118 DownloadUrlParameters* params) { | 118 DownloadUrlParameters* params, |
| 119 const net::NetworkTrafficAnnotationTag& traffic_annotation) { |
119 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 120 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
120 DCHECK(download_id == DownloadItem::kInvalidId || | 121 DCHECK(download_id == DownloadItem::kInvalidId || |
121 !params->content_initiated()) | 122 !params->content_initiated()) |
122 << "Content initiated downloads shouldn't specify a download ID"; | 123 << "Content initiated downloads shouldn't specify a download ID"; |
123 DCHECK(params->offset() >= 0); | 124 DCHECK(params->offset() >= 0); |
124 | 125 |
125 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and | 126 // ResourceDispatcherHost{Base} is-not-a URLRequest::Delegate, and |
126 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so | 127 // DownloadUrlParameters can-not include resource_dispatcher_host_impl.h, so |
127 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. | 128 // we must down cast. RDHI is the only subclass of RDH as of 2012 May 4. |
128 std::unique_ptr<net::URLRequest> request( | 129 std::unique_ptr<net::URLRequest> request( |
129 params->url_request_context_getter() | 130 params->url_request_context_getter() |
130 ->GetURLRequestContext() | 131 ->GetURLRequestContext() |
131 ->CreateRequest(params->url(), net::DEFAULT_PRIORITY, nullptr)); | 132 ->CreateRequest(params->url(), net::DEFAULT_PRIORITY, nullptr, |
| 133 traffic_annotation)); |
132 request->set_method(params->method()); | 134 request->set_method(params->method()); |
133 | 135 |
134 if (!params->post_body().empty()) { | 136 if (!params->post_body().empty()) { |
135 const std::string& body = params->post_body(); | 137 const std::string& body = params->post_body(); |
136 std::unique_ptr<net::UploadElementReader> reader( | 138 std::unique_ptr<net::UploadElementReader> reader( |
137 net::UploadOwnedBytesElementReader::CreateWithString(body)); | 139 net::UploadOwnedBytesElementReader::CreateWithString(body)); |
138 request->set_upload( | 140 request->set_upload( |
139 net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); | 141 net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); |
140 } | 142 } |
141 | 143 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 // old servers that didn't implement "If-Match" and must be ignored when | 722 // old servers that didn't implement "If-Match" and must be ignored when |
721 // "If-Match" presents. | 723 // "If-Match" presents. |
722 if (has_last_modified) { | 724 if (has_last_modified) { |
723 request->SetExtraRequestHeaderByName( | 725 request->SetExtraRequestHeaderByName( |
724 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), | 726 net::HttpRequestHeaders::kIfUnmodifiedSince, params->last_modified(), |
725 true); | 727 true); |
726 } | 728 } |
727 } | 729 } |
728 | 730 |
729 } // namespace content | 731 } // namespace content |
OLD | NEW |