OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This module provides a way to monitor a file or directory for changes. | 5 // This module provides a way to monitor a file or directory for changes. |
6 | 6 |
7 #ifndef BASE_FILES_FILE_PATH_WATCHER_H_ | 7 #ifndef BASE_FILES_FILE_PATH_WATCHER_H_ |
8 #define BASE_FILES_FILE_PATH_WATCHER_H_ | 8 #define BASE_FILES_FILE_PATH_WATCHER_H_ |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 }; | 81 }; |
82 | 82 |
83 FilePathWatcher(); | 83 FilePathWatcher(); |
84 virtual ~FilePathWatcher(); | 84 virtual ~FilePathWatcher(); |
85 | 85 |
86 // A callback that always cleans up the PlatformDelegate, either when executed | 86 // A callback that always cleans up the PlatformDelegate, either when executed |
87 // or when deleted without having been executed at all, as can happen during | 87 // or when deleted without having been executed at all, as can happen during |
88 // shutdown. | 88 // shutdown. |
89 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate); | 89 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate); |
90 | 90 |
| 91 // Returns true if the platform and OS version support recursive watches. |
| 92 static bool RecursiveWatchAvailable(); |
| 93 |
91 // Invokes |callback| whenever updates to |path| are detected. This should be | 94 // Invokes |callback| whenever updates to |path| are detected. This should be |
92 // called at most once, and from a MessageLoop of TYPE_IO. Set |recursive| to | 95 // called at most once, and from a MessageLoop of TYPE_IO. Set |recursive| to |
93 // true, to watch |path| and its children. The callback will be invoked on | 96 // true, to watch |path| and its children. The callback will be invoked on |
94 // the same loop. Returns true on success. | 97 // the same loop. Returns true on success. |
95 // | 98 // |
96 // NOTE: Recursive watch is not supported on all platforms and file systems. | 99 // Recursive watch is not supported on all platforms and file systems. |
97 // Watch() will return false in the case of failure. | 100 // Watch() will return false in the case of failure. |
98 bool Watch(const FilePath& path, bool recursive, const Callback& callback); | 101 bool Watch(const FilePath& path, bool recursive, const Callback& callback); |
99 | 102 |
100 private: | 103 private: |
101 scoped_refptr<PlatformDelegate> impl_; | 104 scoped_refptr<PlatformDelegate> impl_; |
102 | 105 |
103 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); | 106 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); |
104 }; | 107 }; |
105 | 108 |
106 } // namespace base | 109 } // namespace base |
107 | 110 |
108 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ | 111 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ |
OLD | NEW |