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

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: Created 6 years, 3 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 e8fafd7a408e200fda0571cb05feca3f1e2da6da..384e38778aee7694766e3153b864ba7d7022bf38 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,12 @@ 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.";
+
+} // namespace
bool FileSystemProviderMountFunction::RunSync() {
using api::file_system_provider::Mount::Params;
@@ -116,6 +122,41 @@ 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;
+ }
+
+ FOR_EACH_OBSERVER(
+ chromeos::file_system_provider::ProvidedFileSystemInterface::Observer,
+ *file_system->GetObservers(),
+ OnEntryChanged(
+ base::FilePath::FromUTF8Unsafe(params->options.observed_path),
+ chromeos::file_system_provider::ProvidedFileSystemInterface::
+ CHANGED /* TODO(mtomasz) */,
+ chromeos::file_system_provider::ProvidedFileSystemInterface::
+ ChildChanges()));
+
+ 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