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

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

Issue 183743019: delete file if resume mode is invalid. DCHECK fails in DownloadItemImpl::OnDownloadRenamedToFinalNa… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit tests for RESUME_MODE_INVALID interrupt Created 6 years, 9 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 | « no previous file | content/browser/download/download_item_impl_unittest.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 865e7a01f34804c11fd4ca96243ba40ad9089d5a..8de0a1aff722a41de2ca163b21a2fefa98d3827e 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -1424,6 +1424,7 @@ void DownloadItemImpl::OnResumeRequestStarted(
// An error occurred somewhere.
void DownloadItemImpl::Interrupt(DownloadInterruptReason reason) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_NE(DOWNLOAD_INTERRUPT_REASON_NONE, reason);
// Somewhat counter-intuitively, it is possible for us to receive an
// interrupt after we've already been interrupted. The generation of
@@ -1443,11 +1444,15 @@ void DownloadItemImpl::Interrupt(DownloadInterruptReason reason) {
ResumeMode resume_mode = GetResumeMode();
if (state_ == IN_PROGRESS_INTERNAL) {
- // Cancel (delete file) if we're going to restart; no point in leaving
- // data around we aren't going to use. Also cancel if resumption isn't
- // enabled for the same reason.
+ // Cancel (delete file) if:
+ // 1) we're going to restart.
+ // 2) Resumption isn't possible (download was cancelled or blocked due to
+ // security restrictions).
+ // 3) Resumption isn't enabled.
+ // No point in leaving data around we aren't going to use.
ReleaseDownloadFile(resume_mode == RESUME_MODE_IMMEDIATE_RESTART ||
resume_mode == RESUME_MODE_USER_RESTART ||
+ resume_mode == RESUME_MODE_INVALID ||
!IsDownloadResumptionEnabled());
// Cancel the originating URL request.
« no previous file with comments | « no previous file | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698