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

Unified Diff: base/files/file_path_watcher_kqueue.cc

Issue 369703003: Reduce usage of MessageLoopProxy in base/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 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 c38e3448e732b89a23ed002c2c2b6915fd58a173..6650c9059bd7db88aad88db407a9b5b05f4c6fe4 100644
--- a/base/files/file_path_watcher_kqueue.cc
+++ b/base/files/file_path_watcher_kqueue.cc
@@ -10,7 +10,9 @@
#include "base/bind.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/sequenced_task_runner.h"
#include "base/strings/stringprintf.h"
+#include "base/thread_task_runner_handle.h"
// On some platforms these are not defined.
#if !defined(EV_RECEIPT)
@@ -327,7 +329,7 @@ bool FilePathWatcherKQueue::Watch(const FilePath& path,
target_ = path;
MessageLoop::current()->AddDestructionObserver(this);
- io_message_loop_ = base::MessageLoopProxy::current();
+ io_task_runner_ = base::ThreadTaskRunnerHandle::Get();
kqueue_ = kqueue();
if (kqueue_ == -1) {
@@ -356,14 +358,14 @@ bool FilePathWatcherKQueue::Watch(const FilePath& path,
}
void FilePathWatcherKQueue::Cancel() {
- base::MessageLoopProxy* proxy = io_message_loop_.get();
- if (!proxy) {
+ base::SequencedTaskRunner* task_runner = io_task_runner_.get();
+ if (!task_runner) {
set_cancelled();
return;
}
- if (!proxy->BelongsToCurrentThread()) {
- proxy->PostTask(FROM_HERE,
- base::Bind(&FilePathWatcherKQueue::Cancel, this));
+ if (!task_runner->RunsTasksOnCurrentThread()) {
+ task_runner->PostTask(FROM_HERE,
+ base::Bind(&FilePathWatcherKQueue::Cancel, this));
return;
}
CancelOnMessageLoopThread();
@@ -380,7 +382,7 @@ void FilePathWatcherKQueue::CancelOnMessageLoopThread() {
kqueue_ = -1;
std::for_each(events_.begin(), events_.end(), ReleaseEvent);
events_.clear();
- io_message_loop_ = NULL;
+ io_task_runner_ = NULL;
MessageLoop::current()->RemoveDestructionObserver(this);
callback_.Reset();
}

Powered by Google App Engine
This is Rietveld 408576698