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 6f06e3252d6d50b2bc89f8cd68d821edf547cb3b..e2bf57a2c0cbc6dde6e0b190f61c8a87db147ed6 100644 |
--- a/content/browser/download/download_item_impl.cc |
+++ b/content/browser/download/download_item_impl.cc |
@@ -369,6 +369,15 @@ void DownloadItemImpl::Cancel(bool user_cancel) { |
request_handle_->CancelRequest(); |
} |
+ // Remove the intermediate file if we are cancelling an interrupted download. |
+ // Continuable interruptions leave the intermediate file around. |
+ if ((state_ == INTERRUPTED_INTERNAL || state_ == RESUMING_INTERNAL) && |
+ !current_path_.empty()) { |
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
+ base::Bind(&DeleteDownloadedFile, current_path_)); |
+ current_path_.clear(); |
+ } |
+ |
TransitionTo(CANCELLED_INTERNAL); |
} |
@@ -406,15 +415,6 @@ void DownloadItemImpl::Remove() { |
VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true); |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- // Remove the intermediate file if we are removing an interrupted download. |
- // Continuable interruptions leave the intermediate file around. However, the |
- // intermediate file will be unusable if the download item is removed. |
- if (!current_path_.empty() && IsInterrupted() && !download_file_.get()) { |
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
- base::Bind(&DeleteDownloadedFile, current_path_)); |
- current_path_.clear(); |
- } |
- |
delegate_->AssertStateConsistent(this); |
Cancel(true); |
delegate_->AssertStateConsistent(this); |