| 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 <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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 private: | 213 private: |
| 214 InotifyReader* reader_; | 214 InotifyReader* reader_; |
| 215 int inotify_fd_; | 215 int inotify_fd_; |
| 216 int shutdown_fd_; | 216 int shutdown_fd_; |
| 217 | 217 |
| 218 DISALLOW_COPY_AND_ASSIGN(InotifyReaderTask); | 218 DISALLOW_COPY_AND_ASSIGN(InotifyReaderTask); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 static base::LazyInstance<InotifyReader> g_inotify_reader( | 221 static base::LazyInstance<InotifyReader> g_inotify_reader = |
| 222 base::LINKER_INITIALIZED); | 222 LINKER_ZERO_INITIALIZED; |
| 223 | 223 |
| 224 InotifyReader::InotifyReader() | 224 InotifyReader::InotifyReader() |
| 225 : thread_("inotify_reader"), | 225 : thread_("inotify_reader"), |
| 226 inotify_fd_(inotify_init()), | 226 inotify_fd_(inotify_init()), |
| 227 valid_(false) { | 227 valid_(false) { |
| 228 shutdown_pipe_[0] = -1; | 228 shutdown_pipe_[0] = -1; |
| 229 shutdown_pipe_[1] = -1; | 229 shutdown_pipe_[1] = -1; |
| 230 if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) { | 230 if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) { |
| 231 thread_.message_loop()->PostTask( | 231 thread_.message_loop()->PostTask( |
| 232 FROM_HERE, new InotifyReaderTask(this, inotify_fd_, shutdown_pipe_[0])); | 232 FROM_HERE, new InotifyReaderTask(this, inotify_fd_, shutdown_pipe_[0])); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace | 489 } // namespace |
| 490 | 490 |
| 491 FilePathWatcher::FilePathWatcher() { | 491 FilePathWatcher::FilePathWatcher() { |
| 492 impl_ = new FilePathWatcherImpl(); | 492 impl_ = new FilePathWatcherImpl(); |
| 493 } | 493 } |
| 494 | 494 |
| 495 } // namespace files | 495 } // namespace files |
| 496 } // namespace base | 496 } // namespace base |
| OLD | NEW |