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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 }; | 193 }; |
194 | 194 |
195 void InotifyReaderCallback(InotifyReader* reader, int inotify_fd, | 195 void InotifyReaderCallback(InotifyReader* reader, int inotify_fd, |
196 int shutdown_fd) { | 196 int shutdown_fd) { |
197 // Make sure the file descriptors are good for use with select(). | 197 // Make sure the file descriptors are good for use with select(). |
198 CHECK_LE(0, inotify_fd); | 198 CHECK_LE(0, inotify_fd); |
199 CHECK_GT(FD_SETSIZE, inotify_fd); | 199 CHECK_GT(FD_SETSIZE, inotify_fd); |
200 CHECK_LE(0, shutdown_fd); | 200 CHECK_LE(0, shutdown_fd); |
201 CHECK_GT(FD_SETSIZE, shutdown_fd); | 201 CHECK_GT(FD_SETSIZE, shutdown_fd); |
202 | 202 |
203 debug::TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop(); | 203 trace_event::TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop(); |
204 | 204 |
205 while (true) { | 205 while (true) { |
206 fd_set rfds; | 206 fd_set rfds; |
207 FD_ZERO(&rfds); | 207 FD_ZERO(&rfds); |
208 FD_SET(inotify_fd, &rfds); | 208 FD_SET(inotify_fd, &rfds); |
209 FD_SET(shutdown_fd, &rfds); | 209 FD_SET(shutdown_fd, &rfds); |
210 | 210 |
211 // Wait until some inotify events are available. | 211 // Wait until some inotify events are available. |
212 int select_result = | 212 int select_result = |
213 HANDLE_EINTR(select(std::max(inotify_fd, shutdown_fd) + 1, | 213 HANDLE_EINTR(select(std::max(inotify_fd, shutdown_fd) + 1, |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 return watches_[watches_.size() - 1].subdir.empty(); | 683 return watches_[watches_.size() - 1].subdir.empty(); |
684 } | 684 } |
685 | 685 |
686 } // namespace | 686 } // namespace |
687 | 687 |
688 FilePathWatcher::FilePathWatcher() { | 688 FilePathWatcher::FilePathWatcher() { |
689 impl_ = new FilePathWatcherImpl(); | 689 impl_ = new FilePathWatcherImpl(); |
690 } | 690 } |
691 | 691 |
692 } // namespace base | 692 } // namespace base |
OLD | NEW |