| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Cross platform methods for FilePathWatcher. See the various platform | 5 // Cross platform methods for FilePathWatcher. See the various platform |
| 6 // specific implementation files, too. | 6 // specific implementation files, too. |
| 7 | 7 |
| 8 #include "base/files/file_path_watcher.h" | 8 #include "base/files/file_path_watcher.h" |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 | 12 |
| 13 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 14 #include "base/mac/mac_util.h" |
| 15 #endif |
| 16 |
| 13 namespace base { | 17 namespace base { |
| 14 | 18 |
| 15 FilePathWatcher::~FilePathWatcher() { | 19 FilePathWatcher::~FilePathWatcher() { |
| 16 impl_->Cancel(); | 20 impl_->Cancel(); |
| 17 } | 21 } |
| 18 | 22 |
| 19 // static | 23 // static |
| 20 void FilePathWatcher::CancelWatch( | 24 void FilePathWatcher::CancelWatch( |
| 21 const scoped_refptr<PlatformDelegate>& delegate) { | 25 const scoped_refptr<PlatformDelegate>& delegate) { |
| 22 delegate->CancelOnMessageLoopThread(); | 26 delegate->CancelOnMessageLoopThread(); |
| 23 } | 27 } |
| 24 | 28 |
| 29 // static |
| 30 bool FilePathWatcher::RecursiveWatchAvailable() { |
| 31 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 32 // FSEvents isn't available on iOS and is broken on OSX 10.6 and earlier. |
| 33 // See http://crbug.com/54822#c31 |
| 34 return mac::IsOSLionOrLater(); |
| 35 #elif defined(OS_WIN) || defined(OS_LINUX) |
| 36 return true; |
| 37 #else |
| 38 return false; |
| 39 #endif |
| 40 } |
| 41 |
| 25 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { | 42 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { |
| 26 } | 43 } |
| 27 | 44 |
| 28 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { | 45 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
| 29 DCHECK(is_cancelled()); | 46 DCHECK(is_cancelled()); |
| 30 } | 47 } |
| 31 | 48 |
| 32 bool FilePathWatcher::Watch(const FilePath& path, | 49 bool FilePathWatcher::Watch(const FilePath& path, |
| 33 bool recursive, | 50 bool recursive, |
| 34 const Callback& callback) { | 51 const Callback& callback) { |
| 35 DCHECK(path.IsAbsolute()); | 52 DCHECK(path.IsAbsolute()); |
| 36 return impl_->Watch(path, recursive, callback); | 53 return impl_->Watch(path, recursive, callback); |
| 37 } | 54 } |
| 38 | 55 |
| 39 } // namespace base | 56 } // namespace base |
| OLD | NEW |