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

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

Issue 10702151: Revert 146162 - Move Rename functionality from DownloadFileManager to DownloadFileImple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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_file_manager.cc
===================================================================
--- content/browser/download/download_file_manager.cc (revision 146176)
+++ content/browser/download/download_file_manager.cc (working copy)
@@ -195,14 +195,42 @@
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DownloadFile* download_file = GetDownloadFile(global_id);
if (!download_file) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(callback, FilePath()));
+ return;
+ }
+
+ FilePath new_path(full_path);
+ if (!overwrite_existing_file) {
+ // Make the file unique if requested.
+ int uniquifier =
+ file_util::GetUniquePathNumber(new_path, FILE_PATH_LITERAL(""));
+ if (uniquifier > 0) {
+ new_path = new_path.InsertBeforeExtensionASCII(
+ StringPrintf(" (%d)", uniquifier));
+ }
+ }
+
+ // Do the actual rename
+ content::DownloadInterruptReason rename_error =
+ download_file->Rename(new_path);
+ if (content::DOWNLOAD_INTERRUPT_REASON_NONE != rename_error) {
+ DownloadManager* download_manager = download_file->GetDownloadManager();
+ DCHECK(download_manager);
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(callback, content::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED,
- FilePath()));
- return;
+ base::Bind(&DownloadManager::OnDownloadInterrupted,
+ download_manager,
+ global_id.local(),
+ download_file->BytesSoFar(),
+ download_file->GetHashState(),
+ rename_error));
+
+ new_path.clear();
}
-
- download_file->Rename(full_path, overwrite_existing_file, callback);
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(callback, new_path));
}
int DownloadFileManager::NumberOfActiveDownloads() const {
« no previous file with comments | « content/browser/download/download_file_manager.h ('k') | content/browser/download/download_file_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698