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

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: fix win compile 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
« no previous file with comments | « base/files/file_path_watcher_browsertest.cc ('k') | base/files/file_path_watcher_fsevents.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
brettw 2014/05/28 20:55:27 Can this start like the kqueue one ("Mac-specific.
vandebo (ex-Chrome) 2014/05/28 21:14:55 Done.
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 // Returns true if resolving the target path got a different result than
34 // last time it was done.
35 bool ResolveTargetPath();
36
37 // FilePathWatcher::PlatformDelegate overrides.
38 virtual bool Watch(const FilePath& path,
39 bool recursive,
40 const FilePathWatcher::Callback& callback) OVERRIDE;
41 virtual void Cancel() OVERRIDE;
42
43 private:
44 virtual ~FilePathWatcherFSEvents();
45
46 // Destroy the event stream.
47 void DestroyEventStream();
48
49 // Start watching the FSEventStream.
50 void StartEventStream(FSEventStreamEventId start_event);
51
52 // Cleans up and stops the event stream.
53 virtual void CancelOnMessageLoopThread() OVERRIDE;
54
55 // Callback to notify upon changes.
56 FilePathWatcher::Callback callback_;
57
58 // Target path to watch (passed to callback).
59 FilePath target_;
60
61 // Target path with all symbolic links resolved.
62 FilePath resolved_target_;
63
64 // Backend stream we receive event callbacks from (strong reference).
65 FSEventStreamRef fsevent_stream_;
66
67 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherFSEvents);
68 };
69
70 } // namespace
brettw 2014/05/28 20:55:27 } // namespace base
vandebo (ex-Chrome) 2014/05/28 21:14:55 Done.
71
72 #endif // BASE_FILES_FILE_PATH_WATCHER_FSEVENTS_H_
OLDNEW
« no previous file with comments | « base/files/file_path_watcher_browsertest.cc ('k') | base/files/file_path_watcher_fsevents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698