| Index: content/browser/download/parallel_download_job.cc
|
| diff --git a/content/browser/download/parallel_download_job.cc b/content/browser/download/parallel_download_job.cc
|
| index 7e5221178b8f2bbb4285eb46cd1a40d748692210..8bf1a1b5bdb494e29c86dbceb4ee3b692bb08ce4 100644
|
| --- a/content/browser/download/parallel_download_job.cc
|
| +++ b/content/browser/download/parallel_download_job.cc
|
| @@ -11,6 +11,11 @@
|
| #include "content/public/browser/storage_partition.h"
|
|
|
| namespace content {
|
| +namespace {
|
| +
|
| +const int kVerboseLevel = 1;
|
| +
|
| +} // namespace
|
|
|
| ParallelDownloadJob::ParallelDownloadJob(
|
| DownloadItemImpl* download_item,
|
| @@ -69,7 +74,6 @@ void ParallelDownloadJob::Resume(bool resume_request) {
|
| worker.second->Resume();
|
| }
|
|
|
| -
|
| int ParallelDownloadJob::GetParallelRequestCount() const {
|
| return GetParallelRequestCountConfig();
|
| }
|
| @@ -90,8 +94,15 @@ void ParallelDownloadJob::BuildParallelRequestAfterDelay() {
|
| void ParallelDownloadJob::OnByteStreamReady(
|
| DownloadWorker* worker,
|
| std::unique_ptr<ByteStreamReader> stream_reader) {
|
| - DownloadJob::AddByteStream(std::move(stream_reader), worker->offset(),
|
| - worker->length());
|
| + bool success = DownloadJob::AddByteStream(std::move(stream_reader),
|
| + worker->offset(), worker->length());
|
| +
|
| + // Destroy the request if the sink is gone.
|
| + if (!success) {
|
| + VLOG(kVerboseLevel)
|
| + << "Byte stream arrived after download file is released.";
|
| + worker->Cancel();
|
| + }
|
| }
|
|
|
| void ParallelDownloadJob::OnServerResponseError(
|
| @@ -105,6 +116,10 @@ void ParallelDownloadJob::OnServerResponseError(
|
|
|
| void ParallelDownloadJob::BuildParallelRequests() {
|
| DCHECK(!requests_sent_);
|
| + DCHECK(!is_paused());
|
| + if (is_canceled())
|
| + return;
|
| +
|
| // TODO(qinmin): The size of |slices_to_download| should be no larger than
|
| // |kParallelRequestCount| unless |kParallelRequestCount| is changed after
|
| // a download is interrupted. This could happen if we use finch to config
|
|
|