Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| index cfdd9e3bdb58c7675d4c6b45b31fd338cbeb8bd8..bde8520b526e5ba290971d9cb8540cec1ebab29f 100644 |
| --- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc |
| @@ -159,16 +159,30 @@ void NotifyCopyCompletion( |
| source_url.ToGURL(), destination_url.ToGURL(), error); |
| } |
| +void OnRemoveAfterFailedCopyCompleted(base::File::Error error) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + |
| + // We just ignore the status. |
| + DLOG_IF(WARNING, error != base::File::FILE_OK) |
| + << "Failed to remove the destination file after failed copy: " << error; |
| +} |
| + |
| // Callback invoked upon completion of Copy() (regardless of succeeded or |
| // failed). |
| void OnCopyCompleted( |
| void* profile_id, |
| + scoped_refptr<storage::FileSystemContext> file_system_context, |
| storage::FileSystemOperationRunner::OperationID* operation_id, |
| const FileSystemURL& source_url, |
| const FileSystemURL& destination_url, |
| base::File::Error error) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + if (error != base::File::FILE_OK) { |
| + file_system_context->operation_runner()->Remove( |
| + destination_url, false, base::Bind(&OnRemoveAfterFailedCopyCompleted)); |
|
fukino
2017/06/05 04:20:08
Is it safe to call NotifyCopyCompletion before Rem
|
| + } |
| + |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| base::BindOnce(&NotifyCopyCompletion, profile_id, *operation_id, |
| @@ -197,8 +211,8 @@ storage::FileSystemOperationRunner::OperationID StartCopyOnIOThread( |
| storage::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, |
| storage::FileSystemOperation::ERROR_BEHAVIOR_ABORT, |
| base::Bind(&OnCopyProgress, profile_id, base::Unretained(operation_id)), |
| - base::Bind(&OnCopyCompleted, profile_id, base::Owned(operation_id), |
| - source_url, destination_url)); |
| + base::Bind(&OnCopyCompleted, profile_id, file_system_context, |
| + base::Owned(operation_id), source_url, destination_url)); |
| return *operation_id; |
| } |