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) | |
15 #include "base/mac/mac_util.h" | |
16 #endif | |
17 | |
18 namespace base { | 14 namespace base { |
19 | 15 |
20 FilePathWatcher::~FilePathWatcher() { | 16 FilePathWatcher::~FilePathWatcher() { |
21 impl_->Cancel(); | 17 impl_->Cancel(); |
22 } | 18 } |
23 | 19 |
24 // static | 20 // static |
25 void FilePathWatcher::CancelWatch( | 21 void FilePathWatcher::CancelWatch( |
26 const scoped_refptr<PlatformDelegate>& delegate) { | 22 const scoped_refptr<PlatformDelegate>& delegate) { |
27 delegate->CancelOnMessageLoopThread(); | 23 delegate->CancelOnMessageLoopThread(); |
28 } | 24 } |
29 | 25 |
30 // static | 26 // static |
31 bool FilePathWatcher::RecursiveWatchAvailable() { | 27 bool FilePathWatcher::RecursiveWatchAvailable() { |
32 #if defined(OS_MACOSX) && !defined(OS_IOS) | 28 #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. | 29 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; | 30 return true; |
38 #else | 31 #else |
| 32 // FSEvents isn't available on iOS. |
39 return false; | 33 return false; |
40 #endif | 34 #endif |
41 } | 35 } |
42 | 36 |
43 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { | 37 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { |
44 } | 38 } |
45 | 39 |
46 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { | 40 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
47 DCHECK(is_cancelled()); | 41 DCHECK(is_cancelled()); |
48 } | 42 } |
49 | 43 |
50 bool FilePathWatcher::Watch(const FilePath& path, | 44 bool FilePathWatcher::Watch(const FilePath& path, |
51 bool recursive, | 45 bool recursive, |
52 const Callback& callback) { | 46 const Callback& callback) { |
53 DCHECK(path.IsAbsolute()); | 47 DCHECK(path.IsAbsolute()); |
54 return impl_->Watch(path, recursive, callback); | 48 return impl_->Watch(path, recursive, callback); |
55 } | 49 } |
56 | 50 |
57 } // namespace base | 51 } // namespace base |
OLD | NEW |