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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 protected: | 113 protected: |
114 virtual ~FilePathWatcherImpl() {} | 114 virtual ~FilePathWatcherImpl() {} |
115 | 115 |
116 private: | 116 private: |
117 // Cleans up and stops observing the |message_loop_| thread. | 117 // Cleans up and stops observing the |message_loop_| thread. |
118 void CancelOnMessageLoopThread() OVERRIDE; | 118 virtual void CancelOnMessageLoopThread() OVERRIDE; |
119 | 119 |
120 // Inotify watches are installed for all directory components of |target_|. A | 120 // Inotify watches are installed for all directory components of |target_|. A |
121 // WatchEntry instance holds the watch descriptor for a component and the | 121 // WatchEntry instance holds the watch descriptor for a component and the |
122 // subdirectory for that identifies the next component. If a symbolic link | 122 // subdirectory for that identifies the next component. If a symbolic link |
123 // is being watched, the target of the link is also kept. | 123 // is being watched, the target of the link is also kept. |
124 struct WatchEntry { | 124 struct WatchEntry { |
125 WatchEntry(InotifyReader::Watch watch, const FilePath::StringType& subdir) | 125 WatchEntry(InotifyReader::Watch watch, const FilePath::StringType& subdir) |
126 : watch_(watch), | 126 : watch_(watch), |
127 subdir_(subdir) {} | 127 subdir_(subdir) {} |
128 | 128 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 474 } |
475 | 475 |
476 } // namespace | 476 } // namespace |
477 | 477 |
478 FilePathWatcher::FilePathWatcher() { | 478 FilePathWatcher::FilePathWatcher() { |
479 impl_ = new FilePathWatcherImpl(); | 479 impl_ = new FilePathWatcherImpl(); |
480 } | 480 } |
481 | 481 |
482 } // namespace files | 482 } // namespace files |
483 } // namespace base | 483 } // namespace base |
OLD | NEW |