Chromium Code Reviews| 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; |
| } |