| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "base/files/file_path_watcher.h" |
| #include "base/files/file_path_watcher_kqueue.h" |
| #include "build/build_config.h" |
| #include "base/files/file_path_watcher_fsevents.h" |
| class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate { |
| bool Watch(const FilePath& path, |
| const FilePathWatcher::Callback& callback) override { |
| // Use kqueue for non-recursive watches and FSEvents for recursive ones. |
| if (!FilePathWatcher::RecursiveWatchAvailable()) |
| impl_ = new FilePathWatcherFSEvents(); |
| impl_ = new FilePathWatcherKQueue(); |
| return impl_->Watch(path, recursive, callback); |
| ~FilePathWatcherImpl() override {} |
| scoped_refptr<PlatformDelegate> impl_; |
| FilePathWatcher::FilePathWatcher() { |
| sequence_checker_.DetachFromSequence(); |
| impl_ = new FilePathWatcherImpl(); |