1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker // Cross platform methods for FilePathWatcher. See the various platform 6*635a8641SAndroid Build Coastguard Worker // specific implementation files, too. 7*635a8641SAndroid Build Coastguard Worker 8*635a8641SAndroid Build Coastguard Worker #include "base/files/file_path_watcher.h" 9*635a8641SAndroid Build Coastguard Worker 10*635a8641SAndroid Build Coastguard Worker #include "base/logging.h" 11*635a8641SAndroid Build Coastguard Worker #include "build/build_config.h" 12*635a8641SAndroid Build Coastguard Worker 13*635a8641SAndroid Build Coastguard Worker namespace base { 14*635a8641SAndroid Build Coastguard Worker ~FilePathWatcher()15*635a8641SAndroid Build Coastguard WorkerFilePathWatcher::~FilePathWatcher() { 16*635a8641SAndroid Build Coastguard Worker DCHECK(sequence_checker_.CalledOnValidSequence()); 17*635a8641SAndroid Build Coastguard Worker impl_->Cancel(); 18*635a8641SAndroid Build Coastguard Worker } 19*635a8641SAndroid Build Coastguard Worker 20*635a8641SAndroid Build Coastguard Worker // static RecursiveWatchAvailable()21*635a8641SAndroid Build Coastguard Workerbool FilePathWatcher::RecursiveWatchAvailable() { 22*635a8641SAndroid Build Coastguard Worker #if (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) || \ 23*635a8641SAndroid Build Coastguard Worker defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_AIX) 24*635a8641SAndroid Build Coastguard Worker return true; 25*635a8641SAndroid Build Coastguard Worker #else 26*635a8641SAndroid Build Coastguard Worker // FSEvents isn't available on iOS. 27*635a8641SAndroid Build Coastguard Worker return false; 28*635a8641SAndroid Build Coastguard Worker #endif 29*635a8641SAndroid Build Coastguard Worker } 30*635a8641SAndroid Build Coastguard Worker PlatformDelegate()31*635a8641SAndroid Build Coastguard WorkerFilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { 32*635a8641SAndroid Build Coastguard Worker } 33*635a8641SAndroid Build Coastguard Worker ~PlatformDelegate()34*635a8641SAndroid Build Coastguard WorkerFilePathWatcher::PlatformDelegate::~PlatformDelegate() { 35*635a8641SAndroid Build Coastguard Worker DCHECK(is_cancelled()); 36*635a8641SAndroid Build Coastguard Worker } 37*635a8641SAndroid Build Coastguard Worker Watch(const FilePath & path,bool recursive,const Callback & callback)38*635a8641SAndroid Build Coastguard Workerbool FilePathWatcher::Watch(const FilePath& path, 39*635a8641SAndroid Build Coastguard Worker bool recursive, 40*635a8641SAndroid Build Coastguard Worker const Callback& callback) { 41*635a8641SAndroid Build Coastguard Worker DCHECK(sequence_checker_.CalledOnValidSequence()); 42*635a8641SAndroid Build Coastguard Worker DCHECK(path.IsAbsolute()); 43*635a8641SAndroid Build Coastguard Worker return impl_->Watch(path, recursive, callback); 44*635a8641SAndroid Build Coastguard Worker } 45*635a8641SAndroid Build Coastguard Worker 46*635a8641SAndroid Build Coastguard Worker } // namespace base 47