Enterprise policy: Ignore the deprecated ForceSafeSearch if ForceGoogleSafeSearch...
[chromium-blink-merge.git] / base / files / file_path_watcher_linux.cc
blob06c517ae7dfba43342de7b888bd1b8790367b87e
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
3 // found in the LICENSE file.
5 #include "base/files/file_path_watcher.h"
7 #include <errno.h>
8 #include <string.h>
9 #include <sys/inotify.h>
10 #include <sys/ioctl.h>
11 #include <sys/select.h>
12 #include <unistd.h>
14 #include <algorithm>
15 #include <map>
16 #include <set>
17 #include <utility>
18 #include <vector>
20 #include "base/bind.h"
21 #include "base/containers/hash_tables.h"
22 #include "base/files/file_enumerator.h"
23 #include "base/files/file_path.h"
24 #include "base/files/file_util.h"
25 #include "base/lazy_instance.h"
26 #include "base/location.h"
27 #include "base/logging.h"
28 #include "base/memory/scoped_ptr.h"
29 #include "base/message_loop/message_loop.h"
30 #include "base/message_loop/message_loop_proxy.h"
31 #include "base/posix/eintr_wrapper.h"
32 #include "base/synchronization/lock.h"
33 #include "base/threading/thread.h"
34 #include "base/trace_event/trace_event.h"
36 namespace base {
38 namespace {
40 class FilePathWatcherImpl;
42 // Singleton to manage all inotify watches.
43 // TODO(tony): It would be nice if this wasn't a singleton.
44 // http://crbug.com/38174
45 class InotifyReader {
46 public:
47 typedef int Watch; // Watch descriptor used by AddWatch and RemoveWatch.
48 static const Watch kInvalidWatch = -1;
50 // Watch directory |path| for changes. |watcher| will be notified on each
51 // change. Returns kInvalidWatch on failure.
52 Watch AddWatch(const FilePath& path, FilePathWatcherImpl* watcher);
54 // Remove |watch| if it's valid.
55 void RemoveWatch(Watch watch, FilePathWatcherImpl* watcher);
57 // Callback for InotifyReaderTask.
58 void OnInotifyEvent(const inotify_event* event);
60 private:
61 friend struct DefaultLazyInstanceTraits<InotifyReader>;
63 typedef std::set<FilePathWatcherImpl*> WatcherSet;
65 InotifyReader();
66 ~InotifyReader();
68 // We keep track of which delegates want to be notified on which watches.
69 hash_map<Watch, WatcherSet> watchers_;
71 // Lock to protect watchers_.
72 Lock lock_;
74 // Separate thread on which we run blocking read for inotify events.
75 Thread thread_;
77 // File descriptor returned by inotify_init.
78 const int inotify_fd_;
80 // Use self-pipe trick to unblock select during shutdown.
81 int shutdown_pipe_[2];
83 // Flag set to true when startup was successful.
84 bool valid_;
86 DISALLOW_COPY_AND_ASSIGN(InotifyReader);
89 class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate,
90 public MessageLoop::DestructionObserver {
91 public:
92 FilePathWatcherImpl();
94 // Called for each event coming from the watch. |fired_watch| identifies the
95 // watch that fired, |child| indicates what has changed, and is relative to
96 // the currently watched path for |fired_watch|.
98 // |created| is true if the object appears.
99 // |deleted| is true if the object disappears.
100 // |is_dir| is true if the object is a directory.
101 void OnFilePathChanged(InotifyReader::Watch fired_watch,
102 const FilePath::StringType& child,
103 bool created,
104 bool deleted,
105 bool is_dir);
107 protected:
108 ~FilePathWatcherImpl() override {}
110 private:
111 // Start watching |path| for changes and notify |delegate| on each change.
112 // Returns true if watch for |path| has been added successfully.
113 bool Watch(const FilePath& path,
114 bool recursive,
115 const FilePathWatcher::Callback& callback) override;
117 // Cancel the watch. This unregisters the instance with InotifyReader.
118 void Cancel() override;
120 // Cleans up and stops observing the message_loop() thread.
121 void CancelOnMessageLoopThread() override;
123 // Deletion of the FilePathWatcher will call Cancel() to dispose of this
124 // object in the right thread. This also observes destruction of the required
125 // cleanup thread, in case it quits before Cancel() is called.
126 void WillDestroyCurrentMessageLoop() override;
128 // Inotify watches are installed for all directory components of |target_|.
129 // A WatchEntry instance holds:
130 // - |watch|: the watch descriptor for a component.
131 // - |subdir|: the subdirectory that identifies the next component.
132 // - For the last component, there is no next component, so it is empty.
133 // - |linkname|: the target of the symlink.
134 // - Only if the target being watched is a symbolic link.
135 struct WatchEntry {
136 explicit WatchEntry(const FilePath::StringType& dirname)
137 : watch(InotifyReader::kInvalidWatch),
138 subdir(dirname) {}
140 InotifyReader::Watch watch;
141 FilePath::StringType subdir;
142 FilePath::StringType linkname;
144 typedef std::vector<WatchEntry> WatchVector;
146 // Reconfigure to watch for the most specific parent directory of |target_|
147 // that exists. Also calls UpdateRecursiveWatches() below.
148 void UpdateWatches();
150 // Reconfigure to recursively watch |target_| and all its sub-directories.
151 // - This is a no-op if the watch is not recursive.
152 // - If |target_| does not exist, then clear all the recursive watches.
153 // - Assuming |target_| exists, passing kInvalidWatch as |fired_watch| forces
154 // addition of recursive watches for |target_|.
155 // - Otherwise, only the directory associated with |fired_watch| and its
156 // sub-directories will be reconfigured.
157 void UpdateRecursiveWatches(InotifyReader::Watch fired_watch, bool is_dir);
159 // Enumerate recursively through |path| and add / update watches.
160 void UpdateRecursiveWatchesForPath(const FilePath& path);
162 // Do internal bookkeeping to update mappings between |watch| and its
163 // associated full path |path|.
164 void TrackWatchForRecursion(InotifyReader::Watch watch, const FilePath& path);
166 // Remove all the recursive watches.
167 void RemoveRecursiveWatches();
169 // |path| is a symlink to a non-existent target. Attempt to add a watch to
170 // the link target's parent directory. Returns true and update |watch_entry|
171 // on success.
172 bool AddWatchForBrokenSymlink(const FilePath& path, WatchEntry* watch_entry);
174 bool HasValidWatchVector() const;
176 // Callback to notify upon changes.
177 FilePathWatcher::Callback callback_;
179 // The file or directory we're supposed to watch.
180 FilePath target_;
182 bool recursive_;
184 // The vector of watches and next component names for all path components,
185 // starting at the root directory. The last entry corresponds to the watch for
186 // |target_| and always stores an empty next component name in |subdir|.
187 WatchVector watches_;
189 hash_map<InotifyReader::Watch, FilePath> recursive_paths_by_watch_;
190 std::map<FilePath, InotifyReader::Watch> recursive_watches_by_path_;
192 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherImpl);
195 void InotifyReaderCallback(InotifyReader* reader, int inotify_fd,
196 int shutdown_fd) {
197 // Make sure the file descriptors are good for use with select().
198 CHECK_LE(0, inotify_fd);
199 CHECK_GT(FD_SETSIZE, inotify_fd);
200 CHECK_LE(0, shutdown_fd);
201 CHECK_GT(FD_SETSIZE, shutdown_fd);
203 trace_event::TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop();
205 while (true) {
206 fd_set rfds;
207 FD_ZERO(&rfds);
208 FD_SET(inotify_fd, &rfds);
209 FD_SET(shutdown_fd, &rfds);
211 // Wait until some inotify events are available.
212 int select_result =
213 HANDLE_EINTR(select(std::max(inotify_fd, shutdown_fd) + 1,
214 &rfds, NULL, NULL, NULL));
215 if (select_result < 0) {
216 DPLOG(WARNING) << "select failed";
217 return;
220 if (FD_ISSET(shutdown_fd, &rfds))
221 return;
223 // Adjust buffer size to current event queue size.
224 int buffer_size;
225 int ioctl_result = HANDLE_EINTR(ioctl(inotify_fd, FIONREAD,
226 &buffer_size));
228 if (ioctl_result != 0) {
229 DPLOG(WARNING) << "ioctl failed";
230 return;
233 std::vector<char> buffer(buffer_size);
235 ssize_t bytes_read = HANDLE_EINTR(read(inotify_fd, &buffer[0],
236 buffer_size));
238 if (bytes_read < 0) {
239 DPLOG(WARNING) << "read from inotify fd failed";
240 return;
243 ssize_t i = 0;
244 while (i < bytes_read) {
245 inotify_event* event = reinterpret_cast<inotify_event*>(&buffer[i]);
246 size_t event_size = sizeof(inotify_event) + event->len;
247 DCHECK(i + event_size <= static_cast<size_t>(bytes_read));
248 reader->OnInotifyEvent(event);
249 i += event_size;
254 static LazyInstance<InotifyReader>::Leaky g_inotify_reader =
255 LAZY_INSTANCE_INITIALIZER;
257 InotifyReader::InotifyReader()
258 : thread_("inotify_reader"),
259 inotify_fd_(inotify_init()),
260 valid_(false) {
261 if (inotify_fd_ < 0)
262 PLOG(ERROR) << "inotify_init() failed";
264 shutdown_pipe_[0] = -1;
265 shutdown_pipe_[1] = -1;
266 if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) {
267 thread_.message_loop()->PostTask(
268 FROM_HERE,
269 Bind(&InotifyReaderCallback, this, inotify_fd_, shutdown_pipe_[0]));
270 valid_ = true;
274 InotifyReader::~InotifyReader() {
275 if (valid_) {
276 // Write to the self-pipe so that the select call in InotifyReaderTask
277 // returns.
278 ssize_t ret = HANDLE_EINTR(write(shutdown_pipe_[1], "", 1));
279 DPCHECK(ret > 0);
280 DCHECK_EQ(ret, 1);
281 thread_.Stop();
283 if (inotify_fd_ >= 0)
284 close(inotify_fd_);
285 if (shutdown_pipe_[0] >= 0)
286 close(shutdown_pipe_[0]);
287 if (shutdown_pipe_[1] >= 0)
288 close(shutdown_pipe_[1]);
291 InotifyReader::Watch InotifyReader::AddWatch(
292 const FilePath& path, FilePathWatcherImpl* watcher) {
293 if (!valid_)
294 return kInvalidWatch;
296 AutoLock auto_lock(lock_);
298 Watch watch = inotify_add_watch(inotify_fd_, path.value().c_str(),
299 IN_ATTRIB | IN_CREATE | IN_DELETE |
300 IN_CLOSE_WRITE | IN_MOVE |
301 IN_ONLYDIR);
303 if (watch == kInvalidWatch)
304 return kInvalidWatch;
306 watchers_[watch].insert(watcher);
308 return watch;
311 void InotifyReader::RemoveWatch(Watch watch, FilePathWatcherImpl* watcher) {
312 if (!valid_ || (watch == kInvalidWatch))
313 return;
315 AutoLock auto_lock(lock_);
317 watchers_[watch].erase(watcher);
319 if (watchers_[watch].empty()) {
320 watchers_.erase(watch);
321 inotify_rm_watch(inotify_fd_, watch);
325 void InotifyReader::OnInotifyEvent(const inotify_event* event) {
326 if (event->mask & IN_IGNORED)
327 return;
329 FilePath::StringType child(event->len ? event->name : FILE_PATH_LITERAL(""));
330 AutoLock auto_lock(lock_);
332 for (WatcherSet::iterator watcher = watchers_[event->wd].begin();
333 watcher != watchers_[event->wd].end();
334 ++watcher) {
335 (*watcher)->OnFilePathChanged(event->wd,
336 child,
337 event->mask & (IN_CREATE | IN_MOVED_TO),
338 event->mask & (IN_DELETE | IN_MOVED_FROM),
339 event->mask & IN_ISDIR);
343 FilePathWatcherImpl::FilePathWatcherImpl()
344 : recursive_(false) {
347 void FilePathWatcherImpl::OnFilePathChanged(InotifyReader::Watch fired_watch,
348 const FilePath::StringType& child,
349 bool created,
350 bool deleted,
351 bool is_dir) {
352 if (!message_loop()->BelongsToCurrentThread()) {
353 // Switch to message_loop() to access |watches_| safely.
354 message_loop()->PostTask(
355 FROM_HERE,
356 Bind(&FilePathWatcherImpl::OnFilePathChanged, this,
357 fired_watch, child, created, deleted, is_dir));
358 return;
361 // Check to see if CancelOnMessageLoopThread() has already been called.
362 // May happen when code flow reaches here from the PostTask() above.
363 if (watches_.empty()) {
364 DCHECK(target_.empty());
365 return;
368 DCHECK(MessageLoopForIO::current());
369 DCHECK(HasValidWatchVector());
371 // Used below to avoid multiple recursive updates.
372 bool did_update = false;
374 // Find the entry in |watches_| that corresponds to |fired_watch|.
375 for (size_t i = 0; i < watches_.size(); ++i) {
376 const WatchEntry& watch_entry = watches_[i];
377 if (fired_watch != watch_entry.watch)
378 continue;
380 // Check whether a path component of |target_| changed.
381 bool change_on_target_path =
382 child.empty() ||
383 (child == watch_entry.linkname) ||
384 (child == watch_entry.subdir);
386 // Check if the change references |target_| or a direct child of |target_|.
387 bool target_changed;
388 if (watch_entry.subdir.empty()) {
389 // The fired watch is for a WatchEntry without a subdir. Thus for a given
390 // |target_| = "/path/to/foo", this is for "foo". Here, check either:
391 // - the target has no symlink: it is the target and it changed.
392 // - the target has a symlink, and it matches |child|.
393 target_changed = (watch_entry.linkname.empty() ||
394 child == watch_entry.linkname);
395 } else {
396 // The fired watch is for a WatchEntry with a subdir. Thus for a given
397 // |target_| = "/path/to/foo", this is for {"/", "/path", "/path/to"}.
398 // So we can safely access the next WatchEntry since we have not reached
399 // the end yet. Check |watch_entry| is for "/path/to", i.e. the next
400 // element is "foo".
401 bool next_watch_may_be_for_target = watches_[i + 1].subdir.empty();
402 if (next_watch_may_be_for_target) {
403 // The current |watch_entry| is for "/path/to", so check if the |child|
404 // that changed is "foo".
405 target_changed = watch_entry.subdir == child;
406 } else {
407 // The current |watch_entry| is not for "/path/to", so the next entry
408 // cannot be "foo". Thus |target_| has not changed.
409 target_changed = false;
413 // Update watches if a directory component of the |target_| path
414 // (dis)appears. Note that we don't add the additional restriction of
415 // checking the event mask to see if it is for a directory here as changes
416 // to symlinks on the target path will not have IN_ISDIR set in the event
417 // masks. As a result we may sometimes call UpdateWatches() unnecessarily.
418 if (change_on_target_path && (created || deleted) && !did_update) {
419 UpdateWatches();
420 did_update = true;
423 // Report the following events:
424 // - The target or a direct child of the target got changed (in case the
425 // watched path refers to a directory).
426 // - One of the parent directories got moved or deleted, since the target
427 // disappears in this case.
428 // - One of the parent directories appears. The event corresponding to
429 // the target appearing might have been missed in this case, so recheck.
430 if (target_changed ||
431 (change_on_target_path && deleted) ||
432 (change_on_target_path && created && PathExists(target_))) {
433 if (!did_update) {
434 UpdateRecursiveWatches(fired_watch, is_dir);
435 did_update = true;
437 callback_.Run(target_, false /* error */);
438 return;
442 if (ContainsKey(recursive_paths_by_watch_, fired_watch)) {
443 if (!did_update)
444 UpdateRecursiveWatches(fired_watch, is_dir);
445 callback_.Run(target_, false /* error */);
449 bool FilePathWatcherImpl::Watch(const FilePath& path,
450 bool recursive,
451 const FilePathWatcher::Callback& callback) {
452 DCHECK(target_.empty());
453 DCHECK(MessageLoopForIO::current());
455 set_message_loop(MessageLoopProxy::current());
456 callback_ = callback;
457 target_ = path;
458 recursive_ = recursive;
459 MessageLoop::current()->AddDestructionObserver(this);
461 std::vector<FilePath::StringType> comps;
462 target_.GetComponents(&comps);
463 DCHECK(!comps.empty());
464 for (size_t i = 1; i < comps.size(); ++i)
465 watches_.push_back(WatchEntry(comps[i]));
466 watches_.push_back(WatchEntry(FilePath::StringType()));
467 UpdateWatches();
468 return true;
471 void FilePathWatcherImpl::Cancel() {
472 if (callback_.is_null()) {
473 // Watch was never called, or the message_loop() thread is already gone.
474 set_cancelled();
475 return;
478 // Switch to the message_loop() if necessary so we can access |watches_|.
479 if (!message_loop()->BelongsToCurrentThread()) {
480 message_loop()->PostTask(FROM_HERE,
481 Bind(&FilePathWatcher::CancelWatch,
482 make_scoped_refptr(this)));
483 } else {
484 CancelOnMessageLoopThread();
488 void FilePathWatcherImpl::CancelOnMessageLoopThread() {
489 DCHECK(message_loop()->BelongsToCurrentThread());
490 set_cancelled();
492 if (!callback_.is_null()) {
493 MessageLoop::current()->RemoveDestructionObserver(this);
494 callback_.Reset();
497 for (size_t i = 0; i < watches_.size(); ++i)
498 g_inotify_reader.Get().RemoveWatch(watches_[i].watch, this);
499 watches_.clear();
500 target_.clear();
502 if (recursive_)
503 RemoveRecursiveWatches();
506 void FilePathWatcherImpl::WillDestroyCurrentMessageLoop() {
507 CancelOnMessageLoopThread();
510 void FilePathWatcherImpl::UpdateWatches() {
511 // Ensure this runs on the message_loop() exclusively in order to avoid
512 // concurrency issues.
513 DCHECK(message_loop()->BelongsToCurrentThread());
514 DCHECK(HasValidWatchVector());
516 // Walk the list of watches and update them as we go.
517 FilePath path(FILE_PATH_LITERAL("/"));
518 bool path_valid = true;
519 for (size_t i = 0; i < watches_.size(); ++i) {
520 WatchEntry& watch_entry = watches_[i];
521 InotifyReader::Watch old_watch = watch_entry.watch;
522 watch_entry.watch = InotifyReader::kInvalidWatch;
523 watch_entry.linkname.clear();
524 if (path_valid) {
525 watch_entry.watch = g_inotify_reader.Get().AddWatch(path, this);
526 if (watch_entry.watch == InotifyReader::kInvalidWatch) {
527 if (IsLink(path)) {
528 path_valid = AddWatchForBrokenSymlink(path, &watch_entry);
529 } else {
530 path_valid = false;
534 if (old_watch != watch_entry.watch)
535 g_inotify_reader.Get().RemoveWatch(old_watch, this);
536 path = path.Append(watch_entry.subdir);
539 UpdateRecursiveWatches(InotifyReader::kInvalidWatch,
540 false /* is directory? */);
543 void FilePathWatcherImpl::UpdateRecursiveWatches(
544 InotifyReader::Watch fired_watch,
545 bool is_dir) {
546 if (!recursive_)
547 return;
549 if (!DirectoryExists(target_)) {
550 RemoveRecursiveWatches();
551 return;
554 // Check to see if this is a forced update or if some component of |target_|
555 // has changed. For these cases, redo the watches for |target_| and below.
556 if (!ContainsKey(recursive_paths_by_watch_, fired_watch)) {
557 UpdateRecursiveWatchesForPath(target_);
558 return;
561 // Underneath |target_|, only directory changes trigger watch updates.
562 if (!is_dir)
563 return;
565 const FilePath& changed_dir = recursive_paths_by_watch_[fired_watch];
567 std::map<FilePath, InotifyReader::Watch>::iterator start_it =
568 recursive_watches_by_path_.lower_bound(changed_dir);
569 std::map<FilePath, InotifyReader::Watch>::iterator end_it = start_it;
570 for (; end_it != recursive_watches_by_path_.end(); ++end_it) {
571 const FilePath& cur_path = end_it->first;
572 if (!changed_dir.IsParent(cur_path))
573 break;
574 if (!DirectoryExists(cur_path))
575 g_inotify_reader.Get().RemoveWatch(end_it->second, this);
577 recursive_watches_by_path_.erase(start_it, end_it);
578 UpdateRecursiveWatchesForPath(changed_dir);
581 void FilePathWatcherImpl::UpdateRecursiveWatchesForPath(const FilePath& path) {
582 DCHECK(recursive_);
583 DCHECK(!path.empty());
584 DCHECK(DirectoryExists(path));
586 // Note: SHOW_SYM_LINKS exposes symlinks as symlinks, so they are ignored
587 // rather than followed. Following symlinks can easily lead to the undesirable
588 // situation where the entire file system is being watched.
589 FileEnumerator enumerator(
590 path,
591 true /* recursive enumeration */,
592 FileEnumerator::DIRECTORIES | FileEnumerator::SHOW_SYM_LINKS);
593 for (FilePath current = enumerator.Next();
594 !current.empty();
595 current = enumerator.Next()) {
596 DCHECK(enumerator.GetInfo().IsDirectory());
598 if (!ContainsKey(recursive_watches_by_path_, current)) {
599 // Add new watches.
600 InotifyReader::Watch watch =
601 g_inotify_reader.Get().AddWatch(current, this);
602 TrackWatchForRecursion(watch, current);
603 } else {
604 // Update existing watches.
605 InotifyReader::Watch old_watch = recursive_watches_by_path_[current];
606 DCHECK_NE(InotifyReader::kInvalidWatch, old_watch);
607 InotifyReader::Watch watch =
608 g_inotify_reader.Get().AddWatch(current, this);
609 if (watch != old_watch) {
610 g_inotify_reader.Get().RemoveWatch(old_watch, this);
611 recursive_paths_by_watch_.erase(old_watch);
612 recursive_watches_by_path_.erase(current);
613 TrackWatchForRecursion(watch, current);
619 void FilePathWatcherImpl::TrackWatchForRecursion(InotifyReader::Watch watch,
620 const FilePath& path) {
621 DCHECK(recursive_);
622 DCHECK(!path.empty());
623 DCHECK(target_.IsParent(path));
625 if (watch == InotifyReader::kInvalidWatch)
626 return;
628 DCHECK(!ContainsKey(recursive_paths_by_watch_, watch));
629 DCHECK(!ContainsKey(recursive_watches_by_path_, path));
630 recursive_paths_by_watch_[watch] = path;
631 recursive_watches_by_path_[path] = watch;
634 void FilePathWatcherImpl::RemoveRecursiveWatches() {
635 if (!recursive_)
636 return;
638 for (hash_map<InotifyReader::Watch, FilePath>::const_iterator it =
639 recursive_paths_by_watch_.begin();
640 it != recursive_paths_by_watch_.end();
641 ++it) {
642 g_inotify_reader.Get().RemoveWatch(it->first, this);
644 recursive_paths_by_watch_.clear();
645 recursive_watches_by_path_.clear();
648 bool FilePathWatcherImpl::AddWatchForBrokenSymlink(const FilePath& path,
649 WatchEntry* watch_entry) {
650 DCHECK_EQ(InotifyReader::kInvalidWatch, watch_entry->watch);
651 FilePath link;
652 if (!ReadSymbolicLink(path, &link))
653 return false;
655 if (!link.IsAbsolute())
656 link = path.DirName().Append(link);
658 // Try watching symlink target directory. If the link target is "/", then we
659 // shouldn't get here in normal situations and if we do, we'd watch "/" for
660 // changes to a component "/" which is harmless so no special treatment of
661 // this case is required.
662 InotifyReader::Watch watch =
663 g_inotify_reader.Get().AddWatch(link.DirName(), this);
664 if (watch == InotifyReader::kInvalidWatch) {
665 // TODO(craig) Symlinks only work if the parent directory for the target
666 // exist. Ideally we should make sure we've watched all the components of
667 // the symlink path for changes. See crbug.com/91561 for details.
668 DPLOG(WARNING) << "Watch failed for " << link.DirName().value();
669 return false;
671 watch_entry->watch = watch;
672 watch_entry->linkname = link.BaseName().value();
673 return true;
676 bool FilePathWatcherImpl::HasValidWatchVector() const {
677 if (watches_.empty())
678 return false;
679 for (size_t i = 0; i < watches_.size() - 1; ++i) {
680 if (watches_[i].subdir.empty())
681 return false;
683 return watches_[watches_.size() - 1].subdir.empty();
686 } // namespace
688 FilePathWatcher::FilePathWatcher() {
689 impl_ = new FilePathWatcherImpl();
692 } // namespace base