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

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: Add comments about thread usage. 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') | no next file with comments »
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..300aa761dfa05e6b7b907453119c6ac0fbf281f3 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,34 +61,29 @@ 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.
+ // (Only accessed from the message_loop() thread.)
FilePathWatcher::Callback callback_;
// Target path to watch (passed to callback).
+ // (Only accessed from the libdispatch thread.)
FilePath target_;
// Target path with all symbolic links resolved.
+ // (Only accessed from the libdispatch thread.)
FilePath resolved_target_;
// Backend stream we receive event callbacks from (strong reference).
+ // (Only accessed from the libdispatch thread.)
FSEventStreamRef fsevent_stream_;
DISALLOW_COPY_AND_ASSIGN(FilePathWatcherFSEvents);
« no previous file with comments | « no previous file | base/files/file_path_watcher_fsevents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698