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

Unified Diff: content/test/test_file_error_injector.cc

Issue 10689093: Move Rename functionality from DownloadFileManager to DownloadFileImple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload fater merging past revert to figure out if I still have a patch. 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/public/test/mock_download_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_file_error_injector.cc
diff --git a/content/test/test_file_error_injector.cc b/content/test/test_file_error_injector.cc
index 3af526aa9b7719ed83fa7452bfde9136af0925bc..26eaf8ea11a734800abe17cfdef56cb6f7af3c01 100644
--- a/content/test/test_file_error_injector.cc
+++ b/content/test/test_file_error_injector.cc
@@ -55,8 +55,9 @@ class DownloadFileWithErrors: public DownloadFileImpl {
virtual content::DownloadInterruptReason Initialize() OVERRIDE;
virtual content::DownloadInterruptReason AppendDataToFile(
const char* data, size_t data_len) OVERRIDE;
- virtual content::DownloadInterruptReason Rename(
- const FilePath& full_path) OVERRIDE;
+ virtual void Rename(const FilePath& full_path,
+ bool overwrite_existing_file,
+ const RenameCompletionCallback& callback) OVERRIDE;
private:
// Error generating helper.
@@ -64,6 +65,13 @@ class DownloadFileWithErrors: public DownloadFileImpl {
content::TestFileErrorInjector::FileOperationCode code,
content::DownloadInterruptReason original_error);
+ // Used in place of original rename callback to intercept with
+ // ShouldReturnError.
+ void RenameErrorCallback(
+ const RenameCompletionCallback& original_callback,
+ content::DownloadInterruptReason original_error,
+ const FilePath& path_result);
+
// Source URL for the file being downloaded.
GURL source_url_;
@@ -118,11 +126,16 @@ content::DownloadInterruptReason DownloadFileWithErrors::AppendDataToFile(
DownloadFileImpl::AppendDataToFile(data, data_len));
}
-content::DownloadInterruptReason DownloadFileWithErrors::Rename(
- const FilePath& full_path) {
- return ShouldReturnError(
- content::TestFileErrorInjector::FILE_OPERATION_RENAME,
- DownloadFileImpl::Rename(full_path));
+void DownloadFileWithErrors::Rename(
+ const FilePath& full_path,
+ bool overwrite_existing_file,
+ const RenameCompletionCallback& callback) {
+ DownloadFileImpl::Rename(
+ full_path, overwrite_existing_file,
+ base::Bind(&DownloadFileWithErrors::RenameErrorCallback,
+ // Unretained since this'll only be called from
+ // the DownloadFileImpl slice of the same object.
+ base::Unretained(this), callback));
}
content::DownloadInterruptReason DownloadFileWithErrors::ShouldReturnError(
@@ -152,6 +165,15 @@ content::DownloadInterruptReason DownloadFileWithErrors::ShouldReturnError(
return error_info_.error;
}
+void DownloadFileWithErrors::RenameErrorCallback(
+ const RenameCompletionCallback& original_callback,
+ content::DownloadInterruptReason original_error,
+ const FilePath& path_result) {
+ original_callback.Run(ShouldReturnError(
+ content::TestFileErrorInjector::FILE_OPERATION_RENAME,
+ original_error), path_result);
+}
+
} // namespace
namespace content {
@@ -167,7 +189,7 @@ class DownloadFileWithErrorsFactory
virtual ~DownloadFileWithErrorsFactory();
// DownloadFileFactory interface.
- virtual content::DownloadFile* CreateFile(
+ virtual DownloadFile* CreateFile(
DownloadCreateInfo* info,
scoped_ptr<content::ByteStreamReader> stream,
content::DownloadManager* download_manager,
« no previous file with comments | « content/public/test/mock_download_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698