Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Unified Diff: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc

Issue 1194783002: Add fileManagerPrivate.onCopyError event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698