| Index: content/browser/download/download_item_impl.cc
|
| diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
|
| index de2aab58d7f3487a05eea1e814a21d3e95600c57..ba748f0acaff7895bcd62b5d6a1c9bd13af2aa21 100644
|
| --- a/content/browser/download/download_item_impl.cc
|
| +++ b/content/browser/download/download_item_impl.cc
|
| @@ -107,7 +107,8 @@ class NullDownloadRequestHandle : public DownloadRequestHandleInterface {
|
| // takes ownership of the DownloadFile and hence implicitly destroys it
|
| // at the end of the function.
|
| static void DownloadFileDetach(
|
| - scoped_ptr<DownloadFile> download_file, base::Closure callback) {
|
| + scoped_ptr<DownloadFile> download_file,
|
| + const DownloadFile::DetachCompletionCallback& callback) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| download_file->Detach(callback);
|
| }
|
| @@ -842,7 +843,7 @@ void DownloadItemImpl::Interrupt(content::DownloadInterruptReason reason) {
|
| // interrupts to race with cancels.
|
|
|
| // Whatever happens, the first one to hit the UI thread wins.
|
| - if (state_ != IN_PROGRESS_INTERNAL)
|
| + if (state_ != IN_PROGRESS_INTERNAL && state_ != COMPLETING_INTERNAL)
|
| return;
|
|
|
| last_reason_ = reason;
|
| @@ -1196,7 +1197,7 @@ void DownloadItemImpl::ReadyForDownloadCompletionDone() {
|
| if (is_save_package_download_) {
|
| // Avoid doing anything on the file thread; there's nothing we control
|
| // there.
|
| - OnDownloadFileReleased();
|
| + OnDownloadFileReleased(content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
| return;
|
| }
|
|
|
| @@ -1263,7 +1264,12 @@ void DownloadItemImpl::ReleaseDownloadFile() {
|
| TransitionTo(COMPLETING_INTERNAL);
|
| }
|
|
|
| -void DownloadItemImpl::OnDownloadFileReleased() {
|
| +void DownloadItemImpl::OnDownloadFileReleased(
|
| + content::DownloadInterruptReason reason) {
|
| + if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
|
| + Interrupt(reason);
|
| + return;
|
| + }
|
| if (delegate_->ShouldOpenDownload(this))
|
| Completed();
|
| else
|
| @@ -1307,8 +1313,9 @@ void DownloadItemImpl::Completed() {
|
| void DownloadItemImpl::CancelDownloadFile() {
|
| // TODO(rdsmith/benjhayden): Remove condition as part of
|
| // SavePackage integration.
|
| - if (!is_save_package_download_) {
|
| - DCHECK(download_file_.get());
|
| + // download_file_ can be NULL if Interrupt() is called after the download file
|
| + // has been released.
|
| + if (!is_save_package_download_ && download_file_.get()) {
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| // Will be deleted at end of task execution.
|
|
|