Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: content/browser/download/download_item_impl.cc

Issue 14958002: [Resumption 8/11] Remove intermediate files when no longer necessary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r201622 Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698