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

Unified Diff: chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h

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, 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/file_system_provider/provided_file_system_interface.h
diff --git a/chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h b/chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h
index 04b9054aaec04fb414ad7f6ba4b032e69e92040c..e282b05a45ae7c30fb2d899092db58dcc7fb1cbc 100644
--- a/chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h
+++ b/chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h
@@ -5,13 +5,16 @@
#ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERFACE_H_
#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERFACE_H_
+#include <map>
#include <string>
+#include <vector>
#include "base/callback.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "storage/browser/fileapi/async_file_util.h"
class EventRouter;
@@ -30,8 +33,7 @@ namespace file_system_provider {
class ProvidedFileSystemInfo;
class RequestManager;
-// Represents metadata for either a file or a directory. Returned by GetMetadata
-// method in ProvidedFileSystemInterface.
+// Represents metadata for either a file or a directory.
struct EntryMetadata {
EntryMetadata();
~EntryMetadata();
@@ -54,6 +56,9 @@ struct EntryMetadata {
// fails synchronously.
class ProvidedFileSystemInterface {
public:
+ struct ObservedEntry;
+ struct ChildChange;
+
// Mode of opening a file. Used by OpenFile().
enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE };
@@ -63,6 +68,9 @@ class ProvidedFileSystemInterface {
METADATA_FIELD_THUMBNAIL = 1 << 0
};
+ // Type of a change to an observed entry.
+ enum ChangeType { CHANGED, DELETED };
+
typedef base::Callback<void(int file_handle, base::File::Error result)>
OpenFileCallback;
@@ -79,6 +87,44 @@ class ProvidedFileSystemInterface {
// Mask of fields requested from the GetMetadata() call.
typedef int MetadataFieldMask;
+ // List of observed entries.
+ typedef std::map<base::FilePath, ObservedEntry> ObservedEntries;
+
+ // Lust of child changes.
+ typedef std::vector<ChildChange> ChildChanges;
+
+ // Represents an observed entry on the file system.
+ struct ObservedEntry {
+ ObservedEntry();
+ ~ObservedEntry();
+
+ base::FilePath entry_path;
+ bool recursive;
+ std::string last_tag;
+ };
+
+ // Describes a change in an entry contained in an observed directory.
+ struct ChildChange {
+ ChildChange();
+ ~ChildChange();
+
+ base::FilePath entry_path;
+ ChangeType change_type;
+ };
+
+ // Observer class to be notified about changes happened to the file system.
+ class Observer {
+ public:
+ // Called when an observed entry is changed, including removals.
+ virtual void OnEntryChanged(
+ const base::FilePath& observed_path,
+ ChangeType change_type,
+ const std::vector<ChildChange>& child_changes) = 0;
+
+ // Called when list of observed entries is changed.
+ virtual void OnObservedEntriesListChanged() = 0;
+ };
+
virtual ~ProvidedFileSystemInterface() {}
// Requests unmounting of the file system. The callback is called when the
@@ -170,12 +216,35 @@ class ProvidedFileSystemInterface {
int length,
const storage::AsyncFileUtil::StatusCallback& callback) = 0;
+ // Requests observing a directory.
+ virtual AbortCallback ObserveDirectory(
+ const base::FilePath& directory_path,
+ bool recursive,
+ const storage::AsyncFileUtil::StatusCallback& callback) = 0;
+
+ // Requests unobserving an entry.
+ virtual AbortCallback UnobserveEntry(
+ const base::FilePath& entry_path,
+ const storage::AsyncFileUtil::StatusCallback& callback) = 0;
+
// Returns a provided file system info for this file system.
virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0;
+ // Returns a mutable list of observed entries.
+ virtual ObservedEntries* GetObservedEntries() = 0;
+
// Returns a request manager for the file system.
virtual RequestManager* GetRequestManager() = 0;
+ // Adds an observer on the file system.
+ virtual void AddObserver(Observer* observer) = 0;
+
+ // Removes an observer.
+ virtual void RemoveObserver(Observer* observer) = 0;
+
+ // Gets a list of observers.
+ virtual ObserverList<Observer>* GetObservers() = 0;
+
// Returns a weak pointer to this object.
virtual base::WeakPtr<ProvidedFileSystemInterface> GetWeakPtr() = 0;
};

Powered by Google App Engine
This is Rietveld 408576698