OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef STORAGE_BROWSER_FILEAPI_WATCHER_MANAGER_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_WATCHER_MANAGER_H_ |
6 #define STORAGE_BROWSER_FILEAPI_WATCHER_MANAGER_H_ | 6 #define STORAGE_BROWSER_FILEAPI_WATCHER_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
13 | 13 |
14 namespace base { | |
15 class Time; | |
16 } | |
17 | |
18 namespace storage { | 14 namespace storage { |
19 | 15 |
20 class FileSystemOperationContext; | 16 class FileSystemOperationContext; |
21 class FileSystemURL; | 17 class FileSystemURL; |
22 | 18 |
23 // An interface for providing entry observing capability for file system | 19 // An interface for providing entry observing capability for file system |
24 // backends. | 20 // backends. |
25 // | 21 // |
26 // It is NOT valid to give null callback to this class, and implementors | 22 // It is NOT valid to give null callback to this class, and implementors |
27 // can assume that they don't get any null callbacks. | 23 // can assume that they don't get any null callbacks. |
28 class WatcherManager { | 24 class WatcherManager { |
29 public: | 25 public: |
30 enum Action { CHANGED, REMOVED }; | 26 enum ChangeType { CHANGED, DELETED }; |
31 | 27 |
32 typedef base::Callback<void(base::File::Error result)> StatusCallback; | 28 typedef base::Callback<void(base::File::Error result)> StatusCallback; |
33 typedef base::Callback<void(Action action)> NotificationCallback; | 29 typedef base::Callback<void(ChangeType change_type)> NotificationCallback; |
34 | 30 |
35 virtual ~WatcherManager() {} | 31 virtual ~WatcherManager() {} |
36 | 32 |
37 // Observes a directory entry. If the |recursive| mode is not supported then | 33 // Adds an entry watcher. If the |recursive| mode is not supported then |
38 // FILE_ERROR_INVALID_OPERATION must be returned as an error. If the |url| is | 34 // FILE_ERROR_INVALID_OPERATION must be returned as an error. If the |url| is |
39 // already watched, or setting up the watcher fails, then |callback| | 35 // already watched with the same |recursive|, or setting up the watcher fails, |
40 // must be called with a specific error code. Otherwise |callback| must be | 36 // then |callback| must be called with a specific error code. |
41 // called with the FILE_OK error code. |notification_callback| is called for | 37 // |
42 // every change related to the watched directory. | 38 // There may be up to two watchers for the same |url| as well as one of them |
43 virtual void WatchDirectory( | 39 // is recursive, and the other one is not. |
| 40 // |
| 41 // In case of a success |callback| must be called with the FILE_OK error code. |
| 42 // |notification_callback| is called for every change related to the watched |
| 43 // directory. |
| 44 virtual void AddWatcher( |
44 const FileSystemURL& url, | 45 const FileSystemURL& url, |
45 bool recursive, | 46 bool recursive, |
46 const StatusCallback& callback, | 47 const StatusCallback& callback, |
47 const NotificationCallback& notification_callback) = 0; | 48 const NotificationCallback& notification_callback) = 0; |
48 | 49 |
49 // Stops observing an entry represented by |url|. | 50 // Removes a watcher represented by |url| in |recursive| mode. |
50 virtual void UnwatchEntry(const FileSystemURL& url, | 51 virtual void RemoveWatcher(const FileSystemURL& url, |
51 const StatusCallback& callback) = 0; | 52 bool recursive, |
| 53 const StatusCallback& callback) = 0; |
52 }; | 54 }; |
53 | 55 |
54 } // namespace storage | 56 } // namespace storage |
55 | 57 |
56 #endif // STORAGE_BROWSER_FILEAPI_WATCHER_MANAGER_H_ | 58 #endif // STORAGE_BROWSER_FILEAPI_WATCHER_MANAGER_H_ |
OLD | NEW |