| Index: content/browser/download/download_worker.cc
|
| diff --git a/content/browser/download/download_worker.cc b/content/browser/download/download_worker.cc
|
| index 5f65d9eb82c2e9882b905e5f284fbdd41d8f667d..e677352ebd0709d9abb82936bec7d60f8daffdd6 100644
|
| --- a/content/browser/download/download_worker.cc
|
| +++ b/content/browser/download/download_worker.cc
|
| @@ -77,6 +77,13 @@ void DownloadWorker::OnUrlDownloaderStarted(
|
| // |callback| is not used in subsequent requests.
|
| DCHECK(callback.is_null());
|
|
|
| + // Destroy the request if user canceled.
|
| + if (delegate_->IsCanceled()) {
|
| + VLOG(kVerboseLevel) << "Byte stream arrived after user cancel the request.";
|
| + create_info->request_handle->CancelRequest();
|
| + return;
|
| + }
|
| +
|
| // TODO(xingliu): Add the interrupt reason and metric data for precondition
|
| // failure. Make DownloadRequestCore know if it should return error if the
|
| // the server gives a different part of the content, e.g. "If-Match" return
|
| @@ -90,8 +97,14 @@ void DownloadWorker::OnUrlDownloaderStarted(
|
| }
|
|
|
| request_handle_ = std::move(create_info->request_handle);
|
| - if (delegate_)
|
| - delegate_->OnByteStreamReady(this, std::move(stream_reader));
|
| +
|
| + // Pause the stream if user paused, still push the stream reader to the sink.
|
| + if (delegate_->IsPaused()) {
|
| + VLOG(kVerboseLevel) << "Byte stream arrived after user pause the request.";
|
| + Pause();
|
| + }
|
| +
|
| + delegate_->OnByteStreamReady(this, std::move(stream_reader));
|
| }
|
|
|
| void DownloadWorker::OnUrlDownloaderStopped(UrlDownloader* downloader) {
|
|
|