OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/file_watcher.h" | 5 #include "chrome/browser/file_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> |
11 #include <sys/select.h> | 11 #include <sys/select.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <set> | 15 #include <set> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/eintr_wrapper.h" | 19 #include "base/eintr_wrapper.h" |
20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
22 #include "base/hash_tables.h" | 22 #include "base/hash_tables.h" |
23 #include "base/lock.h" | 23 #include "base/lock.h" |
24 #include "base/logging.h" | 24 #include "base/logging.h" |
25 #include "base/message_loop.h" | 25 #include "base/message_loop.h" |
26 #include "base/scoped_ptr.h" | 26 #include "base/scoped_ptr.h" |
27 #include "base/singleton.h" | 27 #include "base/singleton.h" |
28 #include "base/task.h" | 28 #include "base/task.h" |
29 #include "base/thread.h" | 29 #include "base/thread.h" |
30 #include "base/waitable_event.h" | |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 class FileWatcherImpl; | 33 class FileWatcherImpl; |
35 | 34 |
36 // Singleton to manage all inotify watches. | 35 // Singleton to manage all inotify watches. |
37 // TODO(tony): It would be nice if this wasn't a singleton. | 36 // TODO(tony): It would be nice if this wasn't a singleton. |
38 // http://crbug.com/38174 | 37 // http://crbug.com/38174 |
39 class InotifyReader { | 38 class InotifyReader { |
40 public: | 39 public: |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 path_ = path; | 310 path_ = path; |
312 watch_ = Singleton<InotifyReader>::get()->AddWatch(path.DirName(), this); | 311 watch_ = Singleton<InotifyReader>::get()->AddWatch(path.DirName(), this); |
313 return watch_ != InotifyReader::kInvalidWatch; | 312 return watch_ != InotifyReader::kInvalidWatch; |
314 } | 313 } |
315 | 314 |
316 } // namespace | 315 } // namespace |
317 | 316 |
318 FileWatcher::FileWatcher() { | 317 FileWatcher::FileWatcher() { |
319 impl_ = new FileWatcherImpl(); | 318 impl_ = new FileWatcherImpl(); |
320 } | 319 } |
OLD | NEW |