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

Side by Side Diff: base/files/file_path_watcher_fsevents.h

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 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 #ifndef BASE_FILES_FILE_PATH_WATCHER_FSEVENTS_H_
6 #define BASE_FILES_FILE_PATH_WATCHER_FSEVENTS_H_
7
8 #include <CoreServices/CoreServices.h>
9
10 #include <vector>
11
12 #include "base/files/file_path.h"
13 #include "base/files/file_path_watcher.h"
14
15 namespace base {
16
17 // There are trade-offs between the FSEvents implementation and a kqueue
18 // implementation. The biggest issues are that FSEvents on 10.6 sometimes drops
19 // events and kqueue does not trigger for modifications to a file in a watched
20 // directory. See file_path_watcher_mac.cc for the code that decides when to
21 // use which one.
22 class FilePathWatcherFSEvents : public FilePathWatcher::PlatformDelegate {
23 public:
24 FilePathWatcherFSEvents();
25
26 // Called from the FSEvents callback whenever there is a change to the paths.
27 void OnFilePathsChanged(const std::vector<FilePath>& paths);
28
29 // (Re-)Initialize the event stream to start reporting events from
30 // |start_event|.
31 void UpdateEventStream(FSEventStreamEventId start_event);
32
33 // FilePathWatcher::PlatformDelegate overrides.
34 virtual bool Watch(const FilePath& path,
35 bool recursive,
36 const FilePathWatcher::Callback& callback) OVERRIDE;
37 virtual void Cancel() OVERRIDE;
38
39 private:
40 virtual ~FilePathWatcherFSEvents();
41
42 // Destroy the event stream.
43 void DestroyEventStream();
44
45 // Start watching the FSEventStream.
46 void StartEventStream(FSEventStreamEventId start_event);
47
48 // Cleans up and stops the event stream.
49 virtual void CancelOnMessageLoopThread() OVERRIDE;
50
51 // Callback to notify upon changes.
52 FilePathWatcher::Callback callback_;
53
54 // Target path to watch (passed to callback).
55 FilePath target_;
56
57 // Target path with all symbolic links resolved.
58 FilePath resolved_target_;
59
60 // Backend stream we receive event callbacks from (strong reference).
61 FSEventStreamRef fsevent_stream_;
62
63 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherFSEvents);
64 };
65
66 } // namespace
67
68 #endif // BASE_FILES_FILE_PATH_WATCHER_FSEVENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698