| 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // detect the creation and deletion of files, just not the modification of | 26 // detect the creation and deletion of files, just not the modification of |
| 27 // files. It does however detect the attribute changes that the FSEvents impl | 27 // files. It does however detect the attribute changes that the FSEvents impl |
| 28 // would miss. | 28 // would miss. |
| 29 class FilePathWatcherKQueue : public FilePathWatcher::PlatformDelegate, | 29 class FilePathWatcherKQueue : public FilePathWatcher::PlatformDelegate, |
| 30 public MessageLoopForIO::Watcher, | 30 public MessageLoopForIO::Watcher, |
| 31 public MessageLoop::DestructionObserver { | 31 public MessageLoop::DestructionObserver { |
| 32 public: | 32 public: |
| 33 FilePathWatcherKQueue(); | 33 FilePathWatcherKQueue(); |
| 34 | 34 |
| 35 // MessageLoopForIO::Watcher overrides. | 35 // MessageLoopForIO::Watcher overrides. |
| 36 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 36 void OnFileCanReadWithoutBlocking(int fd) override; |
| 37 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 37 void OnFileCanWriteWithoutBlocking(int fd) override; |
| 38 | 38 |
| 39 // MessageLoop::DestructionObserver overrides. | 39 // MessageLoop::DestructionObserver overrides. |
| 40 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 40 void WillDestroyCurrentMessageLoop() override; |
| 41 | 41 |
| 42 // FilePathWatcher::PlatformDelegate overrides. | 42 // FilePathWatcher::PlatformDelegate overrides. |
| 43 virtual bool Watch(const FilePath& path, | 43 bool Watch(const FilePath& path, |
| 44 bool recursive, | 44 bool recursive, |
| 45 const FilePathWatcher::Callback& callback) OVERRIDE; | 45 const FilePathWatcher::Callback& callback) override; |
| 46 virtual void Cancel() OVERRIDE; | 46 void Cancel() override; |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 virtual ~FilePathWatcherKQueue(); | 49 virtual ~FilePathWatcherKQueue(); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 class EventData { | 52 class EventData { |
| 53 public: | 53 public: |
| 54 EventData(const FilePath& path, const FilePath::StringType& subdir) | 54 EventData(const FilePath& path, const FilePath::StringType& subdir) |
| 55 : path_(path), subdir_(subdir) { } | 55 : path_(path), subdir_(subdir) { } |
| 56 FilePath path_; // Full path to this item. | 56 FilePath path_; // Full path to this item. |
| 57 FilePath::StringType subdir_; // Path to any sub item. | 57 FilePath::StringType subdir_; // Path to any sub item. |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 typedef std::vector<struct kevent> EventVector; | 60 typedef std::vector<struct kevent> EventVector; |
| 61 | 61 |
| 62 // Can only be called on |io_message_loop_|'s thread. | 62 // Can only be called on |io_message_loop_|'s thread. |
| 63 virtual void CancelOnMessageLoopThread() OVERRIDE; | 63 void CancelOnMessageLoopThread() override; |
| 64 | 64 |
| 65 // Returns true if the kevent values are error free. | 65 // Returns true if the kevent values are error free. |
| 66 bool AreKeventValuesValid(struct kevent* kevents, int count); | 66 bool AreKeventValuesValid(struct kevent* kevents, int count); |
| 67 | 67 |
| 68 // Respond to a change of attributes of the path component represented by | 68 // Respond to a change of attributes of the path component represented by |
| 69 // |event|. Sets |target_file_affected| to true if |target_| is affected. | 69 // |event|. Sets |target_file_affected| to true if |target_| is affected. |
| 70 // Sets |update_watches| to true if |events_| need to be updated. | 70 // Sets |update_watches| to true if |events_| need to be updated. |
| 71 void HandleAttributesChange(const EventVector::iterator& event, | 71 void HandleAttributesChange(const EventVector::iterator& event, |
| 72 bool* target_file_affected, | 72 bool* target_file_affected, |
| 73 bool* update_watches); | 73 bool* update_watches); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 FilePathWatcher::Callback callback_; | 123 FilePathWatcher::Callback callback_; |
| 124 FilePath target_; | 124 FilePath target_; |
| 125 int kqueue_; | 125 int kqueue_; |
| 126 | 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherKQueue); | 127 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherKQueue); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace base | 130 } // namespace base |
| 131 | 131 |
| 132 #endif // BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ | 132 #endif // BASE_FILES_FILE_PATH_WATCHER_KQUEUE_H_ |
| OLD | NEW |