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

Unified Diff: base/files/file_path_watcher_fsevents.h

Issue 1046353004: Access fields from the appropriate threads in FilePathWatcherFSEvents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check callback_ instead of fsevent_stream_ in destructor. Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/files/file_path_watcher_fsevents.cc » ('j') | base/files/file_path_watcher_fsevents.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path_watcher_fsevents.h
diff --git a/base/files/file_path_watcher_fsevents.h b/base/files/file_path_watcher_fsevents.h
index 800c5b43f6879aa0d5d66eb1164f2f69edb3d5a8..da26a941b33c26eb47ce214deba7ef68f3853d5e 100644
--- a/base/files/file_path_watcher_fsevents.h
+++ b/base/files/file_path_watcher_fsevents.h
@@ -24,9 +24,35 @@ class FilePathWatcherFSEvents : public FilePathWatcher::PlatformDelegate {
public:
FilePathWatcherFSEvents();
- // Called from the FSEvents callback whenever there is a change to the paths.
+ // FilePathWatcher::PlatformDelegate overrides.
+ bool Watch(const FilePath& path,
+ bool recursive,
+ const FilePathWatcher::Callback& callback) override;
+ void Cancel() override;
+
+ private:
+ static void FSEventsCallback(ConstFSEventStreamRef stream,
+ void* event_watcher,
+ size_t num_events,
+ void* event_paths,
+ const FSEventStreamEventFlags flags[],
+ const FSEventStreamEventId event_ids[]);
+
+ ~FilePathWatcherFSEvents() override;
+
+ // Called from FSEventsCallback whenever there is a change to the paths.
void OnFilePathsChanged(const std::vector<FilePath>& paths);
+ // Called on the message_loop() thread to dispatch path events. Can't access
+ // target_ and resolved_target_ directly as those are modified on the
+ // libdispatch thread.
+ void DispatchEvents(const std::vector<FilePath>& paths,
+ const FilePath& target,
+ const FilePath& resolved_target);
+
+ // Cleans up and stops the event stream.
+ void CancelOnMessageLoopThread() override;
+
// (Re-)Initialize the event stream to start reporting events from
// |start_event|.
void UpdateEventStream(FSEventStreamEventId start_event);
@@ -35,23 +61,14 @@ class FilePathWatcherFSEvents : public FilePathWatcher::PlatformDelegate {
// last time it was done.
bool ResolveTargetPath();
- // FilePathWatcher::PlatformDelegate overrides.
- bool Watch(const FilePath& path,
- bool recursive,
- const FilePathWatcher::Callback& callback) override;
- void Cancel() override;
-
- private:
- ~FilePathWatcherFSEvents() override;
+ // Report an error watching the given target.
+ void ReportError(const FilePath& target);
// Destroy the event stream.
void DestroyEventStream();
// Start watching the FSEventStream.
- void StartEventStream(FSEventStreamEventId start_event);
-
- // Cleans up and stops the event stream.
- void CancelOnMessageLoopThread() override;
+ void StartEventStream(FSEventStreamEventId start_event, const FilePath& path);
// Callback to notify upon changes.
Mattias Nissler (ping if slow) 2015/04/10 09:15:51 3rd attempt: Please document in the comments which
Reilly Grant (use Gerrit) 2015/04/10 18:32:47 My mistake. I put in comments but must not have sa
FilePathWatcher::Callback callback_;
« no previous file with comments | « no previous file | base/files/file_path_watcher_fsevents.cc » ('j') | base/files/file_path_watcher_fsevents.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698