diff options
author | mtomasz <mtomasz@chromium.org> | 2014-10-26 23:42:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-27 06:42:27 +0000 |
commit | b524db20a4704fb8e3047680d090c25d7a0a52c7 (patch) | |
tree | d7fe719f831814333733738798d06a9efda296a8 /storage | |
parent | fba4353dbd0f7c28fc4caca968715fba22397f0c (diff) | |
download | chromium_src-b524db20a4704fb8e3047680d090c25d7a0a52c7.zip chromium_src-b524db20a4704fb8e3047680d090c25d7a0a52c7.tar.gz chromium_src-b524db20a4704fb8e3047680d090c25d7a0a52c7.tar.bz2 |
[ew] Simplify the entry watcher logic.
The responsibility of EntryWatcherService has been moved to WatcherManager
implementations.
Note, that the original code was unnecesarily complicated. After replacing
the observer interface with a simple callback, there is no need for an extra
service managing watchers anymore.
This was possible because with the new design entry watchers will no longer
survive reboots.
TEST=Compiles.
BUG=261491
Review URL: https://codereview.chromium.org/642343004
Cr-Commit-Position: refs/heads/master@{#301319}
Diffstat (limited to 'storage')
-rw-r--r-- | storage/browser/fileapi/watcher_manager.h | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/storage/browser/fileapi/watcher_manager.h b/storage/browser/fileapi/watcher_manager.h index 40f3733..1c4f3d1 100644 --- a/storage/browser/fileapi/watcher_manager.h +++ b/storage/browser/fileapi/watcher_manager.h @@ -27,35 +27,24 @@ class FileSystemURL; // can assume that they don't get any null callbacks. class WatcherManager { public: - typedef base::Callback<void(base::File::Error result)> StatusCallback; - - // Observes watched entries. - class Observer { - public: - Observer() {} - virtual ~Observer() {} - - // Notifies about an entry represented by |url| being changed. - virtual void OnEntryChanged(const FileSystemURL& url) = 0; + enum Action { CHANGED, REMOVED }; - // Notifies about an entry represented by |url| being removed. - virtual void OnEntryRemoved(const FileSystemURL& url) = 0; - }; + typedef base::Callback<void(base::File::Error result)> StatusCallback; + typedef base::Callback<void(Action action)> NotificationCallback; virtual ~WatcherManager() {} - virtual void AddObserver(Observer* observer) = 0; - virtual void RemoveObserver(Observer* observer) = 0; - virtual bool HasObserver(Observer* observer) const = 0; - // Observes a directory entry. If the |recursive| mode is not supported then // FILE_ERROR_INVALID_OPERATION must be returned as an error. If the |url| is // already watched, or setting up the watcher fails, then |callback| // must be called with a specific error code. Otherwise |callback| must be - // called with the FILE_OK error code. - virtual void WatchDirectory(const FileSystemURL& url, - bool recursive, - const StatusCallback& callback) = 0; + // called with the FILE_OK error code. |notification_callback| is called for + // every change related to the watched directory. + virtual void WatchDirectory( + const FileSystemURL& url, + bool recursive, + const StatusCallback& callback, + const NotificationCallback& notification_callback) = 0; // Stops observing an entry represented by |url|. virtual void UnwatchEntry(const FileSystemURL& url, |