Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_BROWSER_FILEAPI_WATCHER_MANAGER_H_ | |
| 6 #define WEBKIT_BROWSER_FILEAPI_WATCHER_MANAGER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/files/file.h" | |
| 13 #include "base/files/file_util_proxy.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "webkit/browser/fileapi/file_system_operation.h" | |
| 16 #include "webkit/browser/webkit_storage_browser_export.h" | |
| 17 #include "webkit/common/fileapi/directory_entry.h" | |
| 18 | |
| 19 namespace base { | |
| 20 class Time; | |
| 21 } | |
| 22 | |
| 23 namespace fileapi { | |
| 24 | |
| 25 class FileSystemOperationContext; | |
| 26 class FileSystemURL; | |
| 27 | |
| 28 // An interface for providing entry observing capability for file system | |
| 29 // backends. | |
| 30 // | |
| 31 // It is NOT valid to give null callback to this class, and implementors | |
| 32 // can assume that they don't get any null callbacks. | |
| 33 class WatcherManager { | |
| 34 public: | |
| 35 typedef base::Callback<void(base::File::Error result)> StatusCallback; | |
| 36 | |
| 37 // Observes watched entries. | |
| 38 class Observer { | |
| 39 public: | |
| 40 Observer() {} | |
| 41 virtual ~Observer() {} | |
| 42 | |
| 43 // Notifies about an entry represented by |url| being changed. | |
| 44 virtual void OnEntryChanged(const FileSystemURL& url) = 0; | |
| 45 | |
| 46 // Notifies about an entry represented by |url| being removed. | |
| 47 virtual void OnEntryRemoved(const FileSystemURL& url) = 0; | |
| 48 }; | |
| 49 | |
| 50 virtual ~WatcherManager() {} | |
| 51 | |
| 52 virtual void AddObserver(Observer* observer) = 0; | |
| 53 virtual void RemoveObserver(Observer* observer) = 0; | |
| 54 virtual bool HasObserver(Observer* observer) const = 0; | |
| 55 | |
| 56 // Observes a directory entry. If the |recursive| mode is not supported then | |
| 57 // FILE_ERROR_INVALID_OPERATION must be returned as an error. If the |url| is | |
| 58 // already watched, or setting up the watcher fails, then |callback| | |
|
kinaba
2014/08/12 09:15:37
I have some questions on the "if already watched =
mtomasz
2014/08/12 09:31:37
I was thinking about it a lot, and I couldn't find
kinaba
2014/08/14 05:22:49
Thanks for the explanation. Made sense to me.
mtomasz
2014/08/15 05:35:56
How about doing it in the service, but with a Sequ
kinaba
2014/08/18 02:32:15
Sounds good.
| |
| 59 // must be called with a specific error code. Otherwise |callback| must be | |
| 60 // called with the FILE_OK error code. | |
| 61 virtual void WatchDirectory(const FileSystemURL& url, | |
| 62 bool recursive, | |
| 63 const StatusCallback& callback) = 0; | |
| 64 | |
| 65 // Stops observing an entry represented by |url|. | |
| 66 virtual void UnwatchEntry(const FileSystemURL& url, | |
| 67 const StatusCallback& callback) = 0; | |
| 68 }; | |
| 69 | |
| 70 } // namespace fileapi | |
| 71 | |
| 72 #endif // WEBKIT_BROWSER_FILEAPI_WATCHER_MANAGER_H_ | |
| OLD | NEW |