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

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

Issue 656393002: [fsp] Pass proper data to Notify(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1be0316818ccc2439175f2c1f8c28b666e9a928f..e3fe876b372fb203802c209bbcebbe789c11961a 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
@@ -21,16 +21,60 @@
using chromeos::file_system_provider::MountOptions;
using chromeos::file_system_provider::ProvidedFileSystemInfo;
using chromeos::file_system_provider::ProvidedFileSystemInterface;
+using chromeos::file_system_provider::ProvidedFileSystemObserver;
using chromeos::file_system_provider::RequestValue;
using chromeos::file_system_provider::Service;
namespace extensions {
namespace {
+typedef std::vector<linked_ptr<api::file_system_provider::ChildChange>>
+ IDLChildChanges;
+
const char kNotifyFailedErrorMessage[] =
"Sending a response for the request failed.";
const char kInvalidNotificationErrorMessage[] = "The notification is invalid.";
+// Converts the change type from the IDL type to a native type. |changed_type|
+// must be specified (not CHANGE_TYPE_NONE).
+ProvidedFileSystemObserver::ChangeType ParseChangeType(
+ const api::file_system_provider::ChangeType& change_type) {
+ switch (change_type) {
+ case api::file_system_provider::CHANGE_TYPE_CHANGED:
+ return ProvidedFileSystemObserver::CHANGED;
+ case api::file_system_provider::CHANGE_TYPE_DELETED:
+ return ProvidedFileSystemObserver::DELETED;
+ default:
+ break;
+ }
+ NOTREACHED();
+ return ProvidedFileSystemObserver::CHANGED;
+}
+
+// Convert the child change from the IDL type to a native type. The reason IDL
+// types are not used is since they are imperfect, eg. paths are stored as
+// strings.
+ProvidedFileSystemObserver::ChildChange ParseChildChange(
+ const api::file_system_provider::ChildChange& child_change) {
+ ProvidedFileSystemObserver::ChildChange result;
+ result.entry_path = base::FilePath::FromUTF8Unsafe(child_change.entry_path);
+ result.change_type = ParseChangeType(child_change.change_type);
+ return result;
+}
+
+// Converts a list of child changes from the IDL type to a native type.
+scoped_ptr<ProvidedFileSystemObserver::ChildChanges> ParseChildChanges(
+ const IDLChildChanges& child_changes) {
+ scoped_ptr<ProvidedFileSystemObserver::ChildChanges> results(
+ new ProvidedFileSystemObserver::ChildChanges);
+ for (IDLChildChanges::const_iterator it = child_changes.begin();
+ it != child_changes.end();
+ ++it) {
+ results->push_back(ParseChildChange(*it->get()));
+ }
+ return results;
+}
+
} // namespace
bool FileSystemProviderMountFunction::RunSync() {
@@ -149,13 +193,13 @@ bool FileSystemProviderNotifyFunction::RunSync() {
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")) {
+ ParseChangeType(params->options.change_type),
+ params->options.child_changes.get()
+ ? ParseChildChanges(*params->options.child_changes.get())
+ : make_scoped_ptr(new ProvidedFileSystemObserver::ChildChanges),
+ params->options.tag.get() ? *params->options.tag.get() : "")) {
base::ListValue* const result = new base::ListValue();
result->Append(
CreateError(kSecurityErrorName, kInvalidNotificationErrorMessage));
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698