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

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: nits Created 6 years, 7 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_fsevents.h"
7 #include "base/files/file_path_watcher_kqueue.h"
8 #include "base/mac/mac_util.h"
9
10 namespace base {
11
12 namespace {
13
14 class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
15 public:
16 virtual bool Watch(const FilePath& path,
17 bool recursive,
18 const FilePathWatcher::Callback& callback) OVERRIDE {
19 DCHECK(!impl_.get());
20 if (recursive) {
21 // FSEvents is broken on 10.6 and earlier. See http://crbug.com/54822#c31
22 if (mac::IsOSSnowLeopard())
23 return false;
24
25 impl_ = new FilePathWatcherFSEvents();
26 } else {
27 impl_ = new FilePathWatcherKQueue();
28 }
29 return impl_->Watch(path, recursive, callback);
30 }
31
32 virtual void Cancel() OVERRIDE {
33 if (impl_)
34 impl_->Cancel();
35 }
36
37 virtual void CancelOnMessageLoopThread() OVERRIDE {
38 if (impl_)
39 impl_->Cancel();
40 }
41
42 protected:
43 virtual ~FilePathWatcherImpl() {}
44
45 scoped_refptr<PlatformDelegate> impl_;
46 };
47
48 } // namespace
49
50 FilePathWatcher::FilePathWatcher() {
51 impl_ = new FilePathWatcherImpl();
52 }
53
54 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698