| Index: content/browser/download/download_job.cc
|
| diff --git a/content/browser/download/download_job.cc b/content/browser/download/download_job.cc
|
| index 1ed38b82fa8d83d02b5910ad2399e4b8780b35e6..5bd7aa086fac020802df5ab00c1a620b76cdfef7 100644
|
| --- a/content/browser/download/download_job.cc
|
| +++ b/content/browser/download/download_job.cc
|
| @@ -12,10 +12,14 @@
|
| namespace content {
|
|
|
| DownloadJob::DownloadJob(DownloadItemImpl* download_item)
|
| - : download_item_(download_item), is_paused_(false) {}
|
| + : download_item_(download_item), is_paused_(false), is_canceled_(false) {}
|
|
|
| DownloadJob::~DownloadJob() = default;
|
|
|
| +void DownloadJob::Cancel(bool user_cancel) {
|
| + is_canceled_ = true;
|
| +}
|
| +
|
| void DownloadJob::Pause() {
|
| is_paused_ = true;
|
| }
|
| @@ -33,17 +37,13 @@ void DownloadJob::Interrupt(DownloadInterruptReason reason) {
|
| download_item_->UpdateObservers();
|
| }
|
|
|
| -void DownloadJob::AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader,
|
| +bool DownloadJob::AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader,
|
| int64_t offset,
|
| int64_t length) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| DownloadFile* download_file = download_item_->download_file_.get();
|
| - if (!download_file) {
|
| - // TODO(xingliu): Handle early and late incoming streams, see crbug/702683.
|
| - VLOG(1) << "Download file is released when byte stream arrived. Discard "
|
| - "the byte stream.";
|
| - return;
|
| - }
|
| + if (!download_file)
|
| + return false;
|
|
|
| // download_file_ is owned by download_item_ on the UI thread and is always
|
| // deleted on the FILE thread after download_file_ is nulled out.
|
| @@ -52,6 +52,7 @@ void DownloadJob::AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader,
|
| BrowserThread::FILE, FROM_HERE,
|
| base::Bind(&DownloadFile::AddByteStream, base::Unretained(download_file),
|
| base::Passed(&stream_reader), offset, length));
|
| + return true;
|
| }
|
|
|
| } // namespace content
|
|
|