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

Unified Diff: base/files/file_path_watcher_kqueue.cc

Issue 2596273003: Remove ref-counting from FilePathWatcher. (Closed)
Patch Set: self-review Created 4 years 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
Index: base/files/file_path_watcher_kqueue.cc
diff --git a/base/files/file_path_watcher_kqueue.cc b/base/files/file_path_watcher_kqueue.cc
index 7f4ef033f4ee84b3a7ec884af034c2b89496ba24..b4febfb63abe9668e13c26f230fce7633d11b7df 100644
--- a/base/files/file_path_watcher_kqueue.cc
+++ b/base/files/file_path_watcher_kqueue.cc
@@ -26,7 +26,9 @@ namespace base {
FilePathWatcherKQueue::FilePathWatcherKQueue() : kqueue_(-1) {}
-FilePathWatcherKQueue::~FilePathWatcherKQueue() {}
+FilePathWatcherKQueue::~FilePathWatcherKQueue() {
+ DCHECK(!task_runner() || task_runner()->RunsTasksOnCurrentThread());
+}
void FilePathWatcherKQueue::ReleaseEvent(struct kevent& event) {
CloseFileDescriptor(&event.ident);
@@ -265,11 +267,10 @@ bool FilePathWatcherKQueue::Watch(const FilePath& path,
return false;
}
- // This creates an ownership cycle (|this| owns |kqueue_watch_controller_|
- // which owns a callback which owns |this|). The cycle is broken when
- // |kqueue_watch_controller_| is reset in Cancel().
kqueue_watch_controller_ = FileDescriptorWatcher::WatchReadable(
- kqueue_, Bind(&FilePathWatcherKQueue::OnKQueueReadable, this));
+ kqueue_,
+ Bind(&FilePathWatcherKQueue::OnKQueueReadable, Unretained(this)));
gab 2017/01/05 21:22:53 Can you add a comment explaining why it's okay to
fdoray 2017/01/05 23:04:11 Done.
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698