Chromium Code Reviews| Index: webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
| diff --git a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc b/webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
| index 8b706902b5c84396c675b884a01422d75f638b4b..c487c0423b04091e1daea9aea396b2a639ea03c6 100644 |
| --- a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
| +++ b/webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
| @@ -111,7 +111,8 @@ void CopyOrMoveOperationDelegate::DidTryRemoveDestRoot( |
| // http://crbug.com/172187 |
| StartRecursiveOperation( |
| src_root_, base::Bind(&CopyOrMoveOperationDelegate::DidFinishCopy, |
| - AsWeakPtr(), src_root_, callback_)); |
| + AsWeakPtr(), URLPair(src_root_, dest_root_), |
| + callback_)); |
| } |
| void CopyOrMoveOperationDelegate::CopyOrMoveFile(const URLPair& url_pair, |
| @@ -131,7 +132,7 @@ void CopyOrMoveOperationDelegate::CopyOrMoveFile(const URLPair& url_pair, |
| // copy_callback which removes the source file if operation_type == MOVE. |
| StatusCallback copy_callback = |
| base::Bind(&CopyOrMoveOperationDelegate::DidFinishCopy, AsWeakPtr(), |
| - url_pair.src, callback); |
| + url_pair, callback); |
| operation_runner()->CreateSnapshotFile( |
| url_pair.src, |
| base::Bind(&CopyOrMoveOperationDelegate::DidCreateSnapshot, AsWeakPtr(), |
| @@ -189,11 +190,60 @@ void CopyOrMoveOperationDelegate::DidValidateFile( |
| } |
| void CopyOrMoveOperationDelegate::DidFinishCopy( |
| - const FileSystemURL& src, |
| + const URLPair& url_pair, |
| + const StatusCallback& callback, |
| + base::PlatformFileError error) { |
| + if (error != base::PLATFORM_FILE_OK) { |
| + callback.Run(error); |
| + return; |
| + } |
| + |
| + if (validator_.get()) { |
|
kinuko
2013/07/04 03:10:12
nit: Can you add a comment here to clarify that va
Greg Billock
2013/07/08 20:01:53
Done.
|
| + operation_runner()->CreateSnapshotFile( |
| + url_pair.dest, |
| + base::Bind(&CopyOrMoveOperationDelegate::DoPostWriteValidation, |
| + AsWeakPtr(), url_pair, callback)); |
| + } else { |
| + DidPostWriteValidation(url_pair, callback, base::PLATFORM_FILE_OK); |
| + } |
| +} |
| + |
| +void CopyOrMoveOperationDelegate::DoPostWriteValidation( |
| + const URLPair& url_pair, |
| + const StatusCallback& callback, |
| + base::PlatformFileError error, |
| + const base::PlatformFileInfo& file_info, |
| + const base::FilePath& platform_path, |
| + const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { |
| + // TODO(gbillock): need to check here that file_ref is null or anything? |
|
kinuko
2013/07/04 03:10:12
I think you can just bind the ref to the callback
Greg Billock
2013/07/08 20:01:53
Yeah. Steve and I figured this out I think. I'm ju
|
| + if (error != base::PLATFORM_FILE_OK) { |
| + operation_runner()->Remove( |
| + url_pair.dest, true, |
| + base::Bind(&CopyOrMoveOperationDelegate::DidRemoveDestForError, |
| + AsWeakPtr(), error, callback)); |
| + return; |
| + } |
| + |
| + DCHECK(validator_.get()); |
| + validator_->StartPostWriteValidation( |
| + platform_path, file_ref, |
| + base::Bind(&CopyOrMoveOperationDelegate::DidPostWriteValidation, |
| + AsWeakPtr(), url_pair, callback)); |
| +} |
| + |
| +void CopyOrMoveOperationDelegate::DidPostWriteValidation( |
| + const URLPair& url_pair, |
| const StatusCallback& callback, |
| base::PlatformFileError error) { |
| - if (error != base::PLATFORM_FILE_OK || |
| - operation_type_ == OPERATION_COPY) { |
| + if (error != base::PLATFORM_FILE_OK) { |
| + operation_runner()->Remove( |
| + url_pair.dest, true, |
| + base::Bind(&CopyOrMoveOperationDelegate::DidRemoveDestForError, |
| + AsWeakPtr(), error, callback)); |
| + return; |
| + } |
| + |
| + if (operation_type_ == OPERATION_COPY) { |
| callback.Run(error); |
| return; |
| } |
| @@ -202,7 +252,7 @@ void CopyOrMoveOperationDelegate::DidFinishCopy( |
| // Remove the source for finalizing move operation. |
| operation_runner()->Remove( |
| - src, true /* recursive */, |
| + url_pair.src, true /* recursive */, |
| base::Bind(&CopyOrMoveOperationDelegate::DidRemoveSourceForMove, |
| AsWeakPtr(), callback)); |
| } |
| @@ -229,4 +279,11 @@ FileSystemURL CopyOrMoveOperationDelegate::CreateDestURL( |
| relative); |
| } |
| +void CopyOrMoveOperationDelegate::DidRemoveDestForError( |
| + base::PlatformFileError prior_error, |
| + const StatusCallback& callback, |
| + base::PlatformFileError error) { |
| + callback.Run(prior_error); |
| +} |
| + |
| } // namespace fileapi |