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

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

Issue 2901383007: Don't create parallel request until download file is initialized (Closed)
Patch Set: Created 3 years, 6 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 16 matching lines...) Expand all
27 std::unique_ptr<DownloadRequestHandleInterface> request_handle, 27 std::unique_ptr<DownloadRequestHandleInterface> request_handle,
28 const DownloadCreateInfo& create_info) 28 const DownloadCreateInfo& create_info)
29 : DownloadJobImpl(download_item, std::move(request_handle), true), 29 : DownloadJobImpl(download_item, std::move(request_handle), true),
30 initial_request_offset_(create_info.offset), 30 initial_request_offset_(create_info.offset),
31 content_length_(create_info.total_bytes), 31 content_length_(create_info.total_bytes),
32 requests_sent_(false), 32 requests_sent_(false),
33 is_canceled_(false) {} 33 is_canceled_(false) {}
34 34
35 ParallelDownloadJob::~ParallelDownloadJob() = default; 35 ParallelDownloadJob::~ParallelDownloadJob() = default;
36 36
37 void ParallelDownloadJob::Start() { 37 void ParallelDownloadJob::OnDownloadFileInitialized(
38 DownloadJobImpl::Start(); 38 const DownloadFile::InitializeCallback& callback,
39 39 DownloadInterruptReason result) {
40 BuildParallelRequestAfterDelay(); 40 DownloadJobImpl::OnDownloadFileInitialized(callback, result);
41 if (result == DOWNLOAD_INTERRUPT_REASON_NONE)
42 BuildParallelRequestAfterDelay();
41 } 43 }
42 44
43 void ParallelDownloadJob::Cancel(bool user_cancel) { 45 void ParallelDownloadJob::Cancel(bool user_cancel) {
44 is_canceled_ = true; 46 is_canceled_ = true;
45 DownloadJobImpl::Cancel(user_cancel); 47 DownloadJobImpl::Cancel(user_cancel);
46 48
47 if (!requests_sent_) { 49 if (!requests_sent_) {
48 timer_.Stop(); 50 timer_.Stop();
49 return; 51 return;
50 } 52 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // download request. 230 // download request.
229 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), 231 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(),
230 blink::kWebReferrerPolicyAlways)); 232 blink::kWebReferrerPolicyAlways));
231 // Send the request. 233 // Send the request.
232 worker->SendRequest(std::move(download_params)); 234 worker->SendRequest(std::move(download_params));
233 DCHECK(workers_.find(offset) == workers_.end()); 235 DCHECK(workers_.find(offset) == workers_.end());
234 workers_[offset] = std::move(worker); 236 workers_[offset] = std::move(worker);
235 } 237 }
236 238
237 } // namespace content 239 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/parallel_download_job.h ('k') | content/browser/download/parallel_download_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698