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

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

Issue 283423003: Use FSEvents for recursive file watch on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another 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 (c) 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 !defined(OS_IOS)
25 if (recursive) {
26 // FSEvents is broken on 10.6 and earlier. See http://crbug.com/54822#c31
27 if (mac::IsOSSnowLeopard())
28 return false;
29
30 impl_ = new FilePathWatcherFSEvents();
31 } else
32 #endif // OS_IOS
Mattias Nissler (ping if slow) 2014/05/28 08:08:32 Uh, I'm not so fond of intermixing preprocessor an
vandebo (ex-Chrome) 2014/05/28 18:54:52 Thanks, made it even a bit cleaner.
33 impl_ = new FilePathWatcherKQueue();
34 return impl_->Watch(path, recursive, callback);
35 }
36
37 virtual void Cancel() OVERRIDE {
38 if (impl_)
39 impl_->Cancel();
40 }
41
42 virtual void CancelOnMessageLoopThread() OVERRIDE {
43 if (impl_)
44 impl_->Cancel();
45 }
46
47 protected:
48 virtual ~FilePathWatcherImpl() {}
49
50 scoped_refptr<PlatformDelegate> impl_;
51 };
52
53 } // namespace
54
55 FilePathWatcher::FilePathWatcher() {
56 impl_ = new FilePathWatcherImpl();
57 }
58
59 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698