file_path_watcher.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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
  3. // found in the LICENSE file.
  4. // Cross platform methods for FilePathWatcher. See the various platform
  5. // specific implementation files, too.
  6. #include "base/files/file_path_watcher.h"
  7. #include "base/check.h"
  8. #include "base/files/file_path.h"
  9. #include "build/build_config.h"
  10. namespace base {
  11. FilePathWatcher::~FilePathWatcher() {
  12. DCHECK(sequence_checker_.CalledOnValidSequence());
  13. impl_->Cancel();
  14. }
  15. // static
  16. bool FilePathWatcher::RecursiveWatchAvailable() {
  17. #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || \
  18. BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_AIX)
  19. return true;
  20. #else
  21. // FSEvents isn't available on iOS.
  22. return false;
  23. #endif
  24. }
  25. FilePathWatcher::PlatformDelegate::PlatformDelegate() = default;
  26. FilePathWatcher::PlatformDelegate::~PlatformDelegate() {
  27. DCHECK(is_cancelled());
  28. }
  29. bool FilePathWatcher::Watch(const FilePath& path,
  30. Type type,
  31. const Callback& callback) {
  32. DCHECK(sequence_checker_.CalledOnValidSequence());
  33. DCHECK(path.IsAbsolute());
  34. return impl_->Watch(path, type, callback);
  35. }
  36. } // namespace base