| 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 #include "base/files/file_path_watcher.h" | 5 #include "base/files/file_path_watcher.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <sys/inotify.h> | 9 #include <sys/inotify.h> |
| 10 #include <sys/ioctl.h> | 10 #include <sys/ioctl.h> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 FilePathWatcher::Delegate* delegate) OVERRIDE; | 103 FilePathWatcher::Delegate* delegate) OVERRIDE; |
| 104 | 104 |
| 105 // Cancel the watch. This unregisters the instance with InotifyReader. | 105 // Cancel the watch. This unregisters the instance with InotifyReader. |
| 106 virtual void Cancel() OVERRIDE; | 106 virtual void Cancel() OVERRIDE; |
| 107 | 107 |
| 108 // Deletion of the FilePathWatcher will call Cancel() to dispose of this | 108 // Deletion of the FilePathWatcher will call Cancel() to dispose of this |
| 109 // object in the right thread. This also observes destruction of the required | 109 // object in the right thread. This also observes destruction of the required |
| 110 // cleanup thread, in case it quits before Cancel() is called. | 110 // cleanup thread, in case it quits before Cancel() is called. |
| 111 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 111 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
| 112 | 112 |
| 113 private: | 113 protected: |
| 114 virtual ~FilePathWatcherImpl() {} | 114 virtual ~FilePathWatcherImpl() {} |
| 115 | 115 |
| 116 private: |
| 116 // Cleans up and stops observing the |message_loop_| thread. | 117 // Cleans up and stops observing the |message_loop_| thread. |
| 117 void CancelOnMessageLoopThread() OVERRIDE; | 118 void CancelOnMessageLoopThread() OVERRIDE; |
| 118 | 119 |
| 119 // Inotify watches are installed for all directory components of |target_|. A | 120 // Inotify watches are installed for all directory components of |target_|. A |
| 120 // WatchEntry instance holds the watch descriptor for a component and the | 121 // WatchEntry instance holds the watch descriptor for a component and the |
| 121 // subdirectory for that identifies the next component. If a symbolic link | 122 // subdirectory for that identifies the next component. If a symbolic link |
| 122 // is being watched, the target of the link is also kept. | 123 // is being watched, the target of the link is also kept. |
| 123 struct WatchEntry { | 124 struct WatchEntry { |
| 124 WatchEntry(InotifyReader::Watch watch, const FilePath::StringType& subdir) | 125 WatchEntry(InotifyReader::Watch watch, const FilePath::StringType& subdir) |
| 125 : watch_(watch), | 126 : watch_(watch), |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 } | 474 } |
| 474 | 475 |
| 475 } // namespace | 476 } // namespace |
| 476 | 477 |
| 477 FilePathWatcher::FilePathWatcher() { | 478 FilePathWatcher::FilePathWatcher() { |
| 478 impl_ = new FilePathWatcherImpl(); | 479 impl_ = new FilePathWatcherImpl(); |
| 479 } | 480 } |
| 480 | 481 |
| 481 } // namespace files | 482 } // namespace files |
| 482 } // namespace base | 483 } // namespace base |
| OLD | NEW |