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

Side by Side Diff: content/browser/download/parallel_download_job.cc

Issue 2786523002: Add control to use If-Range header for range request. (Closed)
Patch Set: Rebase. Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/parallel_download_job.h" 5 #include "content/browser/download/parallel_download_job.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "content/browser/download/download_create_info.h" 8 #include "content/browser/download/download_create_info.h"
9 #include "content/browser/download/parallel_download_utils.h" 9 #include "content/browser/download/parallel_download_utils.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 storage_partition->GetURLRequestContext())); 181 storage_partition->GetURLRequestContext()));
182 download_params->set_file_path(download_item_->GetFullPath()); 182 download_params->set_file_path(download_item_->GetFullPath());
183 download_params->set_last_modified(download_item_->GetLastModifiedTime()); 183 download_params->set_last_modified(download_item_->GetLastModifiedTime());
184 download_params->set_etag(download_item_->GetETag()); 184 download_params->set_etag(download_item_->GetETag());
185 download_params->set_offset(offset); 185 download_params->set_offset(offset);
186 186
187 // Setting the length will result in range request to fetch a slice of the 187 // Setting the length will result in range request to fetch a slice of the
188 // file. 188 // file.
189 download_params->set_length(length); 189 download_params->set_length(length);
190 190
191 // Subsequent range requests don't need the "If-Range" header.
192 download_params->set_use_if_range(false);
qinmin 2017/03/30 05:21:43 still need this?
xingliu 2017/03/30 17:16:46 Yes, I think so. Precondition failed for initial
193
191 // Subsequent range requests have the same referrer URL as the original 194 // Subsequent range requests have the same referrer URL as the original
192 // download request. 195 // download request.
193 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), 196 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(),
194 blink::WebReferrerPolicyAlways)); 197 blink::WebReferrerPolicyAlways));
195 // Send the request. 198 // Send the request.
196 worker->SendRequest(std::move(download_params)); 199 worker->SendRequest(std::move(download_params));
197 DCHECK(workers_.find(offset) == workers_.end()); 200 DCHECK(workers_.find(offset) == workers_.end());
198 workers_[offset] = std::move(worker); 201 workers_[offset] = std::move(worker);
199 } 202 }
200 203
201 } // namespace content 204 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698