Chromium Code Reviews| 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 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 | 13 |
| 14 #if defined(OS_MACOSX) && !defined(OS_IOS) | 14 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 15 #include "base/mac/mac_util.h" | 15 #include "base/mac/mac_util.h" |
|
tapted
2016/04/25 21:25:46
remove?
Nico
2016/04/26 14:30:44
Done.
| |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 | 19 |
| 20 FilePathWatcher::~FilePathWatcher() { | 20 FilePathWatcher::~FilePathWatcher() { |
| 21 impl_->Cancel(); | 21 impl_->Cancel(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 // static | 24 // static |
| 25 void FilePathWatcher::CancelWatch( | 25 void FilePathWatcher::CancelWatch( |
| 26 const scoped_refptr<PlatformDelegate>& delegate) { | 26 const scoped_refptr<PlatformDelegate>& delegate) { |
| 27 delegate->CancelOnMessageLoopThread(); | 27 delegate->CancelOnMessageLoopThread(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 bool FilePathWatcher::RecursiveWatchAvailable() { | 31 bool FilePathWatcher::RecursiveWatchAvailable() { |
| 32 #if defined(OS_MACOSX) && !defined(OS_IOS) | 32 #if (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_WIN) || \ |
| 33 // FSEvents isn't available on iOS and is broken on OSX 10.6 and earlier. | 33 defined(OS_LINUX) || defined(OS_ANDROID) |
| 34 // See http://crbug.com/54822#c31 | |
| 35 return mac::IsOSLionOrLater(); | |
| 36 #elif defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID) | |
| 37 return true; | 34 return true; |
| 38 #else | 35 #else |
| 36 // FSEvents isn't available on iOS. | |
| 39 return false; | 37 return false; |
| 40 #endif | 38 #endif |
| 41 } | 39 } |
| 42 | 40 |
| 43 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { | 41 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { |
| 44 } | 42 } |
| 45 | 43 |
| 46 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { | 44 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
| 47 DCHECK(is_cancelled()); | 45 DCHECK(is_cancelled()); |
| 48 } | 46 } |
| 49 | 47 |
| 50 bool FilePathWatcher::Watch(const FilePath& path, | 48 bool FilePathWatcher::Watch(const FilePath& path, |
| 51 bool recursive, | 49 bool recursive, |
| 52 const Callback& callback) { | 50 const Callback& callback) { |
| 53 DCHECK(path.IsAbsolute()); | 51 DCHECK(path.IsAbsolute()); |
| 54 return impl_->Watch(path, recursive, callback); | 52 return impl_->Watch(path, recursive, callback); |
| 55 } | 53 } |
| 56 | 54 |
| 57 } // namespace base | 55 } // namespace base |
| OLD | NEW |