Use FSEvents for recursive file watch on Mac

Brings back the old FSEvents code, changing it to support recursive watches only, and use dispatch queues instead of using the CFRunLoop from the UI thread.

BUG=144491

Review URL: https://codereview.chromium.org/313083007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276289 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: 6d2d92a83fbc0a79d3172a692142677f9fd44206
diff --git a/base/files/file_path_watcher.cc b/base/files/file_path_watcher.cc
index 49e0a23..b173541 100644
--- a/base/files/file_path_watcher.cc
+++ b/base/files/file_path_watcher.cc
@@ -10,6 +10,10 @@
 #include "base/logging.h"
 #include "base/message_loop/message_loop.h"
 
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+#include "base/mac/mac_util.h"
+#endif
+
 namespace base {
 
 FilePathWatcher::~FilePathWatcher() {
@@ -22,6 +26,19 @@
   delegate->CancelOnMessageLoopThread();
 }
 
+// static
+bool FilePathWatcher::RecursiveWatchAvailable() {
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+  // FSEvents isn't available on iOS and is broken on OSX 10.6 and earlier.
+  // See http://crbug.com/54822#c31
+  return mac::IsOSLionOrLater();
+#elif defined(OS_WIN) || defined(OS_LINUX)
+  return true;
+#else
+  return false;
+#endif
+}
+
 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) {
 }