Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: trunk/src/base/files/file_path_watcher_mac.cc

Issue 316853003: Revert 274735 "Use FSEvents for recursive file watch on Mac" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/files/file_path_watcher.h"
6 #include "base/files/file_path_watcher_kqueue.h"
7
8 #if !defined(OS_IOS)
9 #include "base/files/file_path_watcher_fsevents.h"
10 #include "base/mac/mac_util.h"
11 #endif
12
13 namespace base {
14
15 namespace {
16
17 class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
18 public:
19 virtual bool Watch(const FilePath& path,
20 bool recursive,
21 const FilePathWatcher::Callback& callback) OVERRIDE {
22 // Use kqueue for non-recursive watches and FSEvents for recursive ones.
23 DCHECK(!impl_.get());
24 if (recursive) {
25 // FSEvents isn't available on iOS and is broken on OSX 10.6 and earlier.
26 // See http://crbug.com/54822#c31
27 #if !defined(OS_IOS)
28 if (mac::IsOSLionOrLater())
29 impl_ = new FilePathWatcherFSEvents();
30 #endif // OS_IOS
31
32 if (!impl_)
33 return false;
34 } else {
35 impl_ = new FilePathWatcherKQueue();
36 }
37 return impl_->Watch(path, recursive, callback);
38 }
39
40 virtual void Cancel() OVERRIDE {
41 if (impl_)
42 impl_->Cancel();
43 set_cancelled();
44 }
45
46 virtual void CancelOnMessageLoopThread() OVERRIDE {
47 if (impl_)
48 impl_->Cancel();
49 set_cancelled();
50 }
51
52 protected:
53 virtual ~FilePathWatcherImpl() {}
54
55 scoped_refptr<PlatformDelegate> impl_;
56 };
57
58 } // namespace
59
60 FilePathWatcher::FilePathWatcher() {
61 impl_ = new FilePathWatcherImpl();
62 }
63
64 } // namespace base
OLDNEW
« no previous file with comments | « trunk/src/base/files/file_path_watcher_linux.cc ('k') | trunk/src/base/files/file_path_watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698