Chromium Code Reviews| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 | 83 |
| 84 // A callback that always cleans up the PlatformDelegate, either when executed | 84 // A callback that always cleans up the PlatformDelegate, either when executed |
| 85 // or when deleted without having been executed at all, as can happen during | 85 // or when deleted without having been executed at all, as can happen during |
| 86 // shutdown. | 86 // shutdown. |
| 87 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate); | 87 static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate); |
| 88 | 88 |
| 89 // Returns true if the platform and OS version support recursive watches. | 89 // Returns true if the platform and OS version support recursive watches. |
| 90 static bool RecursiveWatchAvailable(); | 90 static bool RecursiveWatchAvailable(); |
| 91 | 91 |
| 92 // Invokes |callback| whenever updates to |path| are detected. This should be | 92 // Invokes |callback| whenever updates to |path| are detected. This should be |
| 93 // called at most once, and from a MessageLoop of TYPE_IO. Set |recursive| to | 93 // called at most once. Set |recursive| to true, to watch |path| and its |
| 94 // true, to watch |path| and its children. The callback will be invoked on | 94 // children. The callback will be invoked on the same thread. Returns true on |
| 95 // the same loop. Returns true on success. | 95 // success. |
| 96 // | |
| 97 // On Mac, this must be called from a thread that supports | |
| 98 // FileDescriptorWatcher when |recursive| is false. | |
|
dcheng
2016/11/23 02:14:25
I don't understand this comment: is there more bac
fdoray
2016/11/23 12:58:37
file_path_watcher_mac.cc:31 -> FilePathWatcherKQue
dcheng
2016/11/23 14:16:11
I'm wondering more about the Mac-specific bits. It
fdoray
2016/11/23 16:21:41
Three potential solutions:
1. Document that this
Mark Mentovai
2016/11/29 19:00:22
FSEvents are more heavyweight than a kqueue()-base
fdoray
2016/11/29 19:09:47
Then I'll do #1 (document that FilePathWatcher::Wa
| |
| 96 // | 99 // |
| 97 // Recursive watch is not supported on all platforms and file systems. | 100 // Recursive watch is not supported on all platforms and file systems. |
| 98 // Watch() will return false in the case of failure. | 101 // Watch() will return false in the case of failure. |
| 99 bool Watch(const FilePath& path, bool recursive, const Callback& callback); | 102 bool Watch(const FilePath& path, bool recursive, const Callback& callback); |
| 100 | 103 |
| 101 private: | 104 private: |
| 102 scoped_refptr<PlatformDelegate> impl_; | 105 scoped_refptr<PlatformDelegate> impl_; |
| 103 | 106 |
| 104 SequenceChecker sequence_checker_; | 107 SequenceChecker sequence_checker_; |
| 105 | 108 |
| 106 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); | 109 DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); |
| 107 }; | 110 }; |
| 108 | 111 |
| 109 } // namespace base | 112 } // namespace base |
| 110 | 113 |
| 111 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ | 114 #endif // BASE_FILES_FILE_PATH_WATCHER_H_ |
| OLD | NEW |