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

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

Issue 625463002: [fsp] Add support for observing entries and notifying about changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 2 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_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 4bb966f1aa6186d9bc845faef1f09a3a22d13e98..66f44a190c19214c72ca3c9f52569326a5f8a721 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
@@ -24,6 +24,13 @@ using chromeos::file_system_provider::RequestValue;
using chromeos::file_system_provider::Service;
namespace extensions {
+namespace {
+
+const char kNotifyFailedErrorMessage[] =
+ "Sending a response for the request failed.";
+const char kInvalidNotificationErrorMessage[] = "The notification is invalid.";
+
+} // namespace
bool FileSystemProviderMountFunction::RunSync() {
using api::file_system_provider::Mount::Params;
@@ -56,7 +63,8 @@ bool FileSystemProviderMountFunction::RunSync() {
if (!service->MountFileSystem(extension_id(),
params->options.file_system_id,
params->options.display_name,
- params->options.writable)) {
+ params->options.writable,
+ params->options.supports_notify_tag)) {
base::ListValue* const result = new base::ListValue();
result->Append(CreateError(kSecurityErrorName, kMountFailedErrorMessage));
SetResult(result);
@@ -118,6 +126,45 @@ bool FileSystemProviderGetAllFunction::RunSync() {
return true;
}
+bool FileSystemProviderNotifyFunction::RunSync() {
+ using api::file_system_provider::Notify::Params;
+ scoped_ptr<Params> params(Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params);
+
+ Service* const service = Service::Get(GetProfile());
+ DCHECK(service);
+ if (!service)
+ return false;
+
+ ProvidedFileSystemInterface* const file_system =
+ service->GetProvidedFileSystem(extension_id(),
+ params->options.file_system_id);
+ if (!file_system) {
+ base::ListValue* const result = new base::ListValue();
+ result->Append(CreateError(kNotFoundErrorName, kNotifyFailedErrorMessage));
+ SetResult(result);
+ return true;
+ }
+
+ // TODO(mtomasz): Pass real data to Notify() instead of fake ones.
+ if (!file_system->Notify(
+ base::FilePath::FromUTF8Unsafe(params->options.observed_path),
+ chromeos::file_system_provider::ProvidedFileSystemObserver::CHANGED,
+ chromeos::file_system_provider::ProvidedFileSystemObserver::
+ ChildChanges(),
+ "todo-tag")) {
+ base::ListValue* const result = new base::ListValue();
+ result->Append(
+ CreateError(kSecurityErrorName, kInvalidNotificationErrorMessage));
+ SetResult(result);
+ return true;
+ }
+
+ base::ListValue* const result = new base::ListValue();
+ SetResult(result);
+ return 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