OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/files/file_path_watcher.h" | 5 #include "base/files/file_path_watcher.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <sys/event.h> | 8 #include <sys/event.h> |
9 #include <sys/param.h> | 9 #include <sys/param.h> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // The kqueue implementation will handle all of the items in the list above | 47 // The kqueue implementation will handle all of the items in the list above |
48 // except for detecting modifications to files in a watched directory. It will | 48 // except for detecting modifications to files in a watched directory. It will |
49 // detect the creation and deletion of files, just not the modification of | 49 // detect the creation and deletion of files, just not the modification of |
50 // files. It does however detect the attribute changes that the FSEvents impl | 50 // files. It does however detect the attribute changes that the FSEvents impl |
51 // would miss. | 51 // would miss. |
52 class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, | 52 class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, |
53 public MessageLoopForIO::Watcher, | 53 public MessageLoopForIO::Watcher, |
54 public MessageLoop::DestructionObserver { | 54 public MessageLoop::DestructionObserver { |
55 public: | 55 public: |
56 FilePathWatcherImpl() : kqueue_(-1) {} | 56 FilePathWatcherImpl() : kqueue_(-1) {} |
57 virtual ~FilePathWatcherImpl() {} | |
58 | 57 |
59 // MessageLoopForIO::Watcher overrides. | 58 // MessageLoopForIO::Watcher overrides. |
60 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 59 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
61 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 60 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
62 | 61 |
63 // MessageLoop::DestructionObserver overrides. | 62 // MessageLoop::DestructionObserver overrides. |
64 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 63 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
65 | 64 |
66 // FilePathWatcher::PlatformDelegate overrides. | 65 // FilePathWatcher::PlatformDelegate overrides. |
67 virtual bool Watch(const FilePath& path, | 66 virtual bool Watch(const FilePath& path, |
68 FilePathWatcher::Delegate* delegate) OVERRIDE; | 67 FilePathWatcher::Delegate* delegate) OVERRIDE; |
69 virtual void Cancel() OVERRIDE; | 68 virtual void Cancel() OVERRIDE; |
70 | 69 |
| 70 protected: |
| 71 virtual ~FilePathWatcherImpl() {} |
| 72 |
71 private: | 73 private: |
72 class EventData { | 74 class EventData { |
73 public: | 75 public: |
74 EventData(const FilePath& path, const FilePath::StringType& subdir) | 76 EventData(const FilePath& path, const FilePath::StringType& subdir) |
75 : path_(path), subdir_(subdir) { } | 77 : path_(path), subdir_(subdir) { } |
76 FilePath path_; // Full path to this item. | 78 FilePath path_; // Full path to this item. |
77 FilePath::StringType subdir_; // Path to any sub item. | 79 FilePath::StringType subdir_; // Path to any sub item. |
78 }; | 80 }; |
79 typedef std::vector<struct kevent> EventVector; | 81 typedef std::vector<struct kevent> EventVector; |
80 | 82 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 495 } |
494 | 496 |
495 } // namespace | 497 } // namespace |
496 | 498 |
497 FilePathWatcher::FilePathWatcher() { | 499 FilePathWatcher::FilePathWatcher() { |
498 impl_ = new FilePathWatcherImpl(); | 500 impl_ = new FilePathWatcherImpl(); |
499 } | 501 } |
500 | 502 |
501 } // namespace files | 503 } // namespace files |
502 } // namespace base | 504 } // namespace base |
OLD | NEW |