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

Unified Diff: content/browser/download/download_file_impl.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
« no previous file with comments | « content/browser/download/download_file_impl.h ('k') | content/browser/download/download_file_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_file_impl.cc
===================================================================
--- content/browser/download/download_file_impl.cc (revision 146176)
+++ content/browser/download/download_file_impl.cc (working copy)
@@ -88,39 +88,11 @@
content::DOWNLOAD_INTERRUPT_FROM_DISK);
}
-void DownloadFileImpl::Rename(const FilePath& full_path,
- bool overwrite_existing_file,
- const RenameCompletionCallback& callback) {
- 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));
- }
- }
-
- net::Error rename_error = file_.Rename(new_path);
- content::DownloadInterruptReason reason(
- content::DOWNLOAD_INTERRUPT_REASON_NONE);
- if (net::OK != rename_error) {
- // Make sure our information is updated, since we're about to
- // error out.
- SendUpdate();
-
- reason =
- content::ConvertNetErrorToInterruptReason(
- rename_error,
- content::DOWNLOAD_INTERRUPT_FROM_DISK);
-
- new_path.clear();
- }
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(callback, reason, new_path));
+content::DownloadInterruptReason DownloadFileImpl::Rename(
+ const FilePath& full_path) {
+ return content::ConvertNetErrorToInterruptReason(
+ file_.Rename(full_path),
+ content::DOWNLOAD_INTERRUPT_FROM_DISK);
}
void DownloadFileImpl::Detach() {
@@ -218,10 +190,6 @@
base::TimeTicks write_start(base::TimeTicks::Now());
reason = AppendDataToFile(
incoming_data.get()->data(), incoming_data_size);
- // Note that if we're after a rename failure but before any
- // cancel that our owner generates based on that rename failure,
- // we'll get an ERR_UNEXPECTED from the above. Our consumers
- // need to handle this situation.
disk_writes_time_ += (base::TimeTicks::Now() - write_start);
bytes_seen_ += incoming_data_size;
total_incoming_data_size += incoming_data_size;
@@ -270,11 +238,11 @@
// Our controller will clean us up.
stream_reader_->RegisterCallback(base::Closure());
weak_factory_.InvalidateWeakPtrs();
- SendUpdate(); // Make info up to date before error.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&DownloadManager::OnDownloadInterrupted,
- download_manager_, id_.local(), reason));
+ download_manager_, id_.local(),
+ BytesSoFar(), GetHashState(), reason));
} else if (state == content::ByteStreamReader::STREAM_COMPLETE) {
// Signal successful completion and shut down processing.
stream_reader_->RegisterCallback(base::Closure());
« no previous file with comments | « content/browser/download/download_file_impl.h ('k') | content/browser/download/download_file_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698