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, |