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 BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ | 5 #ifndef BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ |
6 #define BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ | 6 #define BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ |
7 | 7 |
8 #include <sys/event.h> | 8 #include <sys/event.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 13 matching lines...) Expand all Loading... |
24 // - modifications to the paths to a watched object that would affect the | 24 // - modifications to the paths to a watched object that would affect the |
25 // object such as renaming/attibute changes etc. | 25 // object such as renaming/attibute changes etc. |
26 // The kqueue implementation will handle all of the items in the list above | 26 // The kqueue implementation will handle all of the items in the list above |
27 // except for detecting modifications to files in a watched directory. It will | 27 // except for detecting modifications to files in a watched directory. It will |
28 // detect the creation and deletion of files, just not the modification of | 28 // detect the creation and deletion of files, just not the modification of |
29 // files. It does however detect the attribute changes that the FSEvents impl | 29 // files. It does however detect the attribute changes that the FSEvents impl |
30 // would miss. | 30 // would miss. |
31 class FilePathWatcherKQueue : public FilePathWatcher::PlatformDelegate { | 31 class FilePathWatcherKQueue : public FilePathWatcher::PlatformDelegate { |
32 public: | 32 public: |
33 FilePathWatcherKQueue(); | 33 FilePathWatcherKQueue(); |
| 34 ~FilePathWatcherKQueue() override; |
34 | 35 |
35 // FilePathWatcher::PlatformDelegate overrides. | 36 // FilePathWatcher::PlatformDelegate overrides. |
36 bool Watch(const FilePath& path, | 37 bool Watch(const FilePath& path, |
37 bool recursive, | 38 bool recursive, |
38 const FilePathWatcher::Callback& callback) override; | 39 const FilePathWatcher::Callback& callback) override; |
39 void Cancel() override; | 40 void Cancel() override; |
40 | 41 |
41 protected: | |
42 ~FilePathWatcherKQueue() override; | |
43 | |
44 private: | 42 private: |
45 class EventData { | 43 class EventData { |
46 public: | 44 public: |
47 EventData(const FilePath& path, const FilePath::StringType& subdir) | 45 EventData(const FilePath& path, const FilePath::StringType& subdir) |
48 : path_(path), subdir_(subdir) { } | 46 : path_(path), subdir_(subdir) { } |
49 FilePath path_; // Full path to this item. | 47 FilePath path_; // Full path to this item. |
50 FilePath::StringType subdir_; // Path to any sub item. | 48 FilePath::StringType subdir_; // Path to any sub item. |
51 }; | 49 }; |
52 | 50 |
53 typedef std::vector<struct kevent> EventVector; | 51 typedef std::vector<struct kevent> EventVector; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Throughout the lifetime of this, OnKQueueReadable() will be called when | 116 // Throughout the lifetime of this, OnKQueueReadable() will be called when |
119 // data is available in |kqueue_|. | 117 // data is available in |kqueue_|. |
120 std::unique_ptr<FileDescriptorWatcher::Controller> kqueue_watch_controller_; | 118 std::unique_ptr<FileDescriptorWatcher::Controller> kqueue_watch_controller_; |
121 | 119 |
122 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherKQueue); | 120 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherKQueue); |
123 }; | 121 }; |
124 | 122 |
125 } // namespace base | 123 } // namespace base |
126 | 124 |
127 #endif // BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ | 125 #endif // BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ |
OLD | NEW |