| 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 3df5a307e003d826d19e8d12a03fefa6325c47ec..3bb6dd317c5eec7b3e3fd3bae601cdb75a19611d 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
|
| @@ -103,6 +103,36 @@ file_manager::EventRouter* GetEventRouterByProfileId(void* profile_id) {
|
| return file_manager::EventRouterFactory::GetForProfile(profile);
|
| }
|
|
|
| +// Notifies the error to extension via event router.
|
| +void NotifyCopyError(
|
| + void* profile_id,
|
| + storage::FileSystemOperationRunner::OperationID operation_id,
|
| + const FileSystemURL& source_url,
|
| + const FileSystemURL& destination_url) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +
|
| + file_manager::EventRouter* event_router =
|
| + GetEventRouterByProfileId(profile_id);
|
| + if (event_router) {
|
| + event_router->OnCopyError(operation_id, source_url.ToGURL(),
|
| + destination_url.ToGURL());
|
| + }
|
| +}
|
| +
|
| +// Callback invoked when an error had happened during copy operation.
|
| +void OnCopyError(void* profile_id,
|
| + storage::FileSystemOperationRunner::OperationID* operation_id,
|
| + base::File::Error /*error*/,
|
| + const FileSystemURL& source_url,
|
| + const FileSystemURL& destination_url) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| +
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE,
|
| + base::Bind(&NotifyCopyError, profile_id, *operation_id, source_url,
|
| + destination_url));
|
| +}
|
| +
|
| // Notifies the copy progress to extensions via event router.
|
| void NotifyCopyProgress(
|
| void* profile_id,
|
| @@ -184,18 +214,18 @@ storage::FileSystemOperationRunner::OperationID StartCopyOnIOThread(
|
| // Note: |operation_id| is owned by the callback for
|
| // FileSystemOperationRunner::Copy(). It is always called in the next message
|
| // loop or later, so at least during this invocation it should alive.
|
| + //
|
| + // TODO(yawano): Flip continue_with_error to true after copy error messages
|
| + // become to appear in the UI of Files.app.
|
| storage::FileSystemOperationRunner::OperationID* operation_id =
|
| new storage::FileSystemOperationRunner::OperationID;
|
| *operation_id = file_system_context->operation_runner()->Copy(
|
| - source_url,
|
| - destination_url,
|
| - storage::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
|
| + source_url, destination_url,
|
| + storage::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, false,
|
| + base::Bind(&OnCopyError, profile_id, base::Unretained(operation_id)),
|
| 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, base::Owned(operation_id),
|
| + source_url, destination_url));
|
| return *operation_id;
|
| }
|
|
|
|
|