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

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

Issue 14640020: [Resumption 9/11] Handle filename determination for resumed downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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 f4adec41437ee1c8a798bffdd0d9d0ec6e6faf9a..9d8e9f08d59b08ac87f92529e8f4aef497e76cb7 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -1064,18 +1064,6 @@ void DownloadItemImpl::OnDownloadFileInitialized(
return;
}
- // If we're resuming an interrupted download, we may already know the download
- // target so we can skip target name determination. GetFullPath() is non-empty
- // for interrupted downloads where the intermediate file is still present, and
- // also for downloads with forced paths.
- if (!GetTargetFilePath().empty() && !GetFullPath().empty()) {
- // TODO(rdsmith/asanka): Check to confirm that the target path isn't
- // present on disk; if it is, we should re-do filename determination to
- // give the user a chance not to collide.
- MaybeCompleteDownload();
- return;
- }
-
delegate_->DetermineDownloadTarget(
this, base::Bind(&DownloadItemImpl::OnDownloadTargetDetermined,
weak_ptr_factory_.GetWeakPtr()));
@@ -1118,6 +1106,19 @@ void DownloadItemImpl::OnDownloadTargetDetermined(
// space/permission/availability constraints.
DCHECK(intermediate_path.DirName() == target_path.DirName());
+ // During resumption, we may choose to proceed with the same intermediate
+ // file. No rename is necessary if our intermediate file already has the
+ // correct name.
+ //
+ // The intermediate name may change from its original value during filename
+ // determination on resumption, for example if the reason for the interruption
+ // was the download target running out space, resulting in a user prompt.
+ if (intermediate_path == current_path_) {
+ OnDownloadRenamedToIntermediateName(DOWNLOAD_INTERRUPT_REASON_NONE,
+ intermediate_path);
+ return;
+ }
+
// Rename to intermediate name.
// TODO(asanka): Skip this rename if AllDataSaved() is true. This avoids a
// spurious rename when we can just rename to the final
« no previous file with comments | « chrome/browser/download/download_target_determiner_unittest.cc ('k') | content/public/browser/download_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698