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

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: 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
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 37ddf76e915e905d508f8cd2551007f534cc5ea7..2a2986e88bce8288a3932261c5629389d1f5fc4e 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -369,6 +369,13 @@ void DownloadItemImpl::Cancel(bool user_cancel) {
request_handle_->CancelRequest();
}
+ if ((state_ == INTERRUPTED_INTERNAL || state_ == RESUMING_INTERNAL) &&
+ !current_path_.empty() && current_path_ != target_path_) {
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DeleteDownloadedFile, current_path_));
+ current_path_.clear();
+ }
+
TransitionTo(CANCELLED_INTERNAL);
}
@@ -409,7 +416,13 @@ void DownloadItemImpl::Remove() {
// 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()) {
+ //
+ // Be extra cautious here and only delete an intermediate file if we sure it's
+ // really an intermediate file. Downloads imported from history may have a
+ // non-empty current_path_ that's the same as target_path_.
Randy Smith (Not in Mondays) 2013/05/15 15:34:56 I'm slightly confused. If the download was import
asanka 2013/05/21 21:09:02 https://codereview.chromium.org/11363222 introduce
Randy Smith (Not in Mondays) 2013/05/21 21:40:37 I hear you about the entries from before we starte
asanka 2013/05/22 22:55:52 Yeah. I got rid of the check.
+ if (IsInterrupted() && !current_path_.empty() && !target_path_.empty() &&
+ current_path_ != target_path_) {
+ DCHECK(!download_file_.get());
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&DeleteDownloadedFile, current_path_));
current_path_.clear();

Powered by Google App Engine
This is Rietveld 408576698