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

Unified Diff: chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc

Issue 703123003: [fsp] Pass more detailed errors to the providing extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a bug. Created 6 years, 1 month 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_system_provider/file_system_provider_api.cc
diff --git a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc
index aa43ff77bee8c0caa7c0870bd8c06ed13b72e922..c315d406a1675865e75d86c95bf7935375aeb610 100644
--- a/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc
+++ b/chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc
@@ -77,13 +77,13 @@ bool FileSystemProviderMountFunction::RunSync() {
// It's an error if the file system Id is empty.
if (params->options.file_system_id.empty()) {
- SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY));
+ SetError(FileErrorToString(base::File::FILE_ERROR_INVALID_OPERATION));
return false;
}
// It's an error if the display name is empty.
if (params->options.display_name.empty()) {
- SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY));
+ SetError(FileErrorToString(base::File::FILE_ERROR_INVALID_OPERATION));
return false;
}
@@ -96,9 +96,10 @@ bool FileSystemProviderMountFunction::RunSync() {
options.writable = params->options.writable;
options.supports_notify_tag = params->options.supports_notify_tag;
- // TODO(mtomasz): Pass more detailed errors, rather than just a bool.
- if (!service->MountFileSystem(extension_id(), options)) {
- SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY));
+ const base::File::Error result =
+ service->MountFileSystem(extension_id(), options);
+ if (result != base::File::FILE_OK) {
+ SetError(FileErrorToString(result));
return false;
}
@@ -113,11 +114,11 @@ bool FileSystemProviderUnmountFunction::RunSync() {
Service* const service = Service::Get(GetProfile());
DCHECK(service);
- if (!service->UnmountFileSystem(extension_id(),
- params->options.file_system_id,
- Service::UNMOUNT_REASON_USER)) {
- // TODO(mtomasz): Pass more detailed errors, rather than just a bool.
- SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY));
+ const base::File::Error result =
+ service->UnmountFileSystem(extension_id(), params->options.file_system_id,
+ Service::UNMOUNT_REASON_USER);
+ if (result != base::File::FILE_OK) {
+ SetError(FileErrorToString(result));
return false;
}
@@ -171,7 +172,7 @@ bool FileSystemProviderGetAllFunction::RunSync() {
return true;
}
-bool FileSystemProviderNotifyFunction::RunSync() {
+bool FileSystemProviderNotifyFunction::RunAsync() {
using api::file_system_provider::Notify::Params;
scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
@@ -183,25 +184,33 @@ bool FileSystemProviderNotifyFunction::RunSync() {
service->GetProvidedFileSystem(extension_id(),
params->options.file_system_id);
if (!file_system) {
- SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY));
+ SetError(FileErrorToString(base::File::FILE_ERROR_NOT_FOUND));
return false;
}
- if (!file_system->Notify(
- base::FilePath::FromUTF8Unsafe(params->options.observed_path),
- params->options.recursive,
- ParseChangeType(params->options.change_type),
- params->options.changes.get()
- ? ParseChanges(*params->options.changes.get())
- : make_scoped_ptr(new ProvidedFileSystemObserver::Changes),
- params->options.tag.get() ? *params->options.tag.get() : "")) {
- SetError(FileErrorToString(base::File::FILE_ERROR_SECURITY));
- return false;
- }
+ file_system->Notify(
+ base::FilePath::FromUTF8Unsafe(params->options.observed_path),
+ params->options.recursive, ParseChangeType(params->options.change_type),
+ params->options.changes.get()
+ ? ParseChanges(*params->options.changes.get())
+ : make_scoped_ptr(new ProvidedFileSystemObserver::Changes),
+ params->options.tag.get() ? *params->options.tag.get() : "",
+ base::Bind(&FileSystemProviderNotifyFunction::OnNotifyCompleted, this));
return true;
}
+void FileSystemProviderNotifyFunction::OnNotifyCompleted(
+ base::File::Error result) {
+ if (result != base::File::FILE_OK) {
+ SetError(FileErrorToString(result));
+ SendResponse(false);
+ return;
+ }
+
+ SendResponse(true);
+}
+
bool FileSystemProviderInternalUnmountRequestedSuccessFunction::RunWhenValid() {
using api::file_system_provider_internal::UnmountRequestedSuccess::Params;
scoped_ptr<Params> params(Params::Create(*args_));

Powered by Google App Engine
This is Rietveld 408576698