Home | History | Annotate | Download | only in files
      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 
      5 // Cross platform methods for FilePathWatcher. See the various platform
      6 // specific implementation files, too.
      7 
      8 #include "base/files/file_path_watcher.h"
      9 
     10 #include "base/logging.h"
     11 #include "build/build_config.h"
     12 
     13 namespace base {
     14 
     15 FilePathWatcher::~FilePathWatcher() {
     16   DCHECK(sequence_checker_.CalledOnValidSequence());
     17   impl_->Cancel();
     18 }
     19 
     20 // static
     21 bool FilePathWatcher::RecursiveWatchAvailable() {
     22 #if (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) || \
     23     defined(OS_LINUX) || defined(OS_ANDROID)
     24   return true;
     25 #else
     26   // FSEvents isn't available on iOS.
     27   return false;
     28 #endif
     29 }
     30 
     31 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) {
     32 }
     33 
     34 FilePathWatcher::PlatformDelegate::~PlatformDelegate() {
     35   DCHECK(is_cancelled());
     36 }
     37 
     38 bool FilePathWatcher::Watch(const FilePath& path,
     39                             bool recursive,
     40                             const Callback& callback) {
     41   DCHECK(sequence_checker_.CalledOnValidSequence());
     42   DCHECK(path.IsAbsolute());
     43   return impl_->Watch(path, recursive, callback);
     44 }
     45 
     46 }  // namespace base
     47