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

Unified Diff: base/files/file_path_watcher_linux.cc

Issue 2598193002: Allow FilePathWatcher to be used from sequenced tasks. (Closed)
Patch Set: thread -> sequence in comment 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
« no previous file with comments | « base/files/file_path_watcher_kqueue.cc ('k') | base/files/file_path_watcher_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path_watcher_linux.cc
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc
index bf17cde45f7036aea326d33190b478eb3d1df8d2..d060e49136cbc88dc095b5872d148607af501d39 100644
--- a/base/files/file_path_watcher_linux.cc
+++ b/base/files/file_path_watcher_linux.cc
@@ -32,8 +32,8 @@
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/synchronization/lock.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
namespace base {
@@ -320,7 +320,7 @@ void FilePathWatcherImpl::OnFilePathChanged(InotifyReader::Watch fired_watch,
bool created,
bool deleted,
bool is_dir) {
- if (!task_runner()->BelongsToCurrentThread()) {
+ if (!task_runner()->RunsTasksOnCurrentThread()) {
// Switch to task_runner() to access |watches_| safely.
task_runner()->PostTask(FROM_HERE,
Bind(&FilePathWatcherImpl::OnFilePathChanged, this,
@@ -335,7 +335,7 @@ void FilePathWatcherImpl::OnFilePathChanged(InotifyReader::Watch fired_watch,
return;
}
- DCHECK(task_runner()->BelongsToCurrentThread());
+ DCHECK(task_runner()->RunsTasksOnCurrentThread());
DCHECK(HasValidWatchVector());
// Used below to avoid multiple recursive updates.
@@ -421,7 +421,7 @@ bool FilePathWatcherImpl::Watch(const FilePath& path,
const FilePathWatcher::Callback& callback) {
DCHECK(target_.empty());
- set_task_runner(ThreadTaskRunnerHandle::Get());
+ set_task_runner(SequencedTaskRunnerHandle::Get());
callback_ = callback;
target_ = path;
recursive_ = recursive;
@@ -444,7 +444,7 @@ void FilePathWatcherImpl::Cancel() {
}
// Switch to the task_runner() if necessary so we can access |watches_|.
- if (!task_runner()->BelongsToCurrentThread()) {
+ if (!task_runner()->RunsTasksOnCurrentThread()) {
task_runner()->PostTask(
FROM_HERE,
Bind(&FilePathWatcherImpl::CancelOnMessageLoopThreadOrInDestructor,
@@ -455,7 +455,7 @@ void FilePathWatcherImpl::Cancel() {
}
void FilePathWatcherImpl::CancelOnMessageLoopThreadOrInDestructor() {
- DCHECK(in_destructor_ || task_runner()->BelongsToCurrentThread());
+ DCHECK(in_destructor_ || task_runner()->RunsTasksOnCurrentThread());
if (is_cancelled())
return;
@@ -477,7 +477,7 @@ void FilePathWatcherImpl::CancelOnMessageLoopThreadOrInDestructor() {
void FilePathWatcherImpl::UpdateWatches() {
// Ensure this runs on the task_runner() exclusively in order to avoid
// concurrency issues.
- DCHECK(task_runner()->BelongsToCurrentThread());
+ DCHECK(task_runner()->RunsTasksOnCurrentThread());
DCHECK(HasValidWatchVector());
// Walk the list of watches and update them as we go.
« no previous file with comments | « base/files/file_path_watcher_kqueue.cc ('k') | base/files/file_path_watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698