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..2b90fb156c5fc22a2e344a4f7f8b532b5bec73c9 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,62 @@ 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 || |
| - operation_type_ == OPERATION_COPY) { |
| + if (error != base::PLATFORM_FILE_OK) { |
| + callback.Run(error); |
| + return; |
| + } |
| + |
| + if (validator_.get()) { |
| + 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? |
| + if (error != base::PLATFORM_FILE_OK) { |
| + operation_runner()->Remove( |
| + url_pair.dest, true, |
| + base::Bind(&CopyOrMoveOperationDelegate::DidRemoveDestForError, |
|
vandebo (ex-Chrome)
2013/07/02 20:15:02
Shouldn't this take the callback and invoke it aft
Greg Billock
2013/07/03 16:08:27
I want to return the validation error, not the rem
|
| + AsWeakPtr())); |
| + callback.Run(error); |
| + return; |
| + } |
| + |
| + DCHECK(validator_.get()); |
| + validator_->StartPostWriteValidation( |
| + platform_path, |
| + 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_runner()->Remove( |
| + url_pair.dest, true, |
| + base::Bind(&CopyOrMoveOperationDelegate::DidRemoveDestForError, |
| + AsWeakPtr())); |
| + callback.Run(error); |
|
vandebo (ex-Chrome)
2013/07/02 20:15:02
Same here
Greg Billock
2013/07/03 16:08:27
ditto
|
| + return; |
| + } |
| + |
| + if (operation_type_ == OPERATION_COPY) { |
| callback.Run(error); |
| return; |
| } |
| @@ -202,7 +254,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 +281,9 @@ FileSystemURL CopyOrMoveOperationDelegate::CreateDestURL( |
| relative); |
| } |
| +void CopyOrMoveOperationDelegate::DidRemoveDestForError( |
| + base::PlatformFileError error) { |
| + // TODO(gbillock): What to do here? Currently nothing.... |
|
vandebo (ex-Chrome)
2013/07/02 20:15:02
Remove it if you don't need it... but you do. You
Greg Billock
2013/07/03 16:08:27
That's basically what's happening now. I should wa
|
| +} |
| + |
| } // namespace fileapi |