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

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 e2bf57a2c0cbc6dde6e0b190f61c8a87db147ed6..2f3a7a093d43fe93177c8c4abf2efcd40f34d2e6 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -1068,18 +1068,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()));
@@ -1122,6 +1110,15 @@ 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.
+ 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

Powered by Google App Engine
This is Rietveld 408576698