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

Unified Diff: mojo/public/cpp/system/watcher.cc

Issue 2608163003: Change single-interface mojo bindings to use SequencedTaskRunner. (Closed)
Patch Set: Created 3 years, 11 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 | « mojo/public/cpp/system/watcher.h ('k') | services/device/device_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/watcher.cc
diff --git a/mojo/public/cpp/system/watcher.cc b/mojo/public/cpp/system/watcher.cc
index 55dcf4023e2b719ea7e9fe28451c5280f05e9654..712d4d1413ea2266e76b5b27bfb0e7abf6bb33f5 100644
--- a/mojo/public/cpp/system/watcher.cc
+++ b/mojo/public/cpp/system/watcher.cc
@@ -7,19 +7,21 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/macros.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/heap_profiler.h"
#include "mojo/public/c/system/functions.h"
namespace mojo {
Watcher::Watcher(const tracked_objects::Location& from_here,
- scoped_refptr<base::SingleThreadTaskRunner> runner)
+ scoped_refptr<base::SequencedTaskRunner> runner)
: task_runner_(std::move(runner)),
- is_default_task_runner_(task_runner_ ==
- base::ThreadTaskRunnerHandle::Get()),
+ is_default_task_runner_(base::ThreadTaskRunnerHandle::IsSet() &&
+ task_runner_ ==
+ base::ThreadTaskRunnerHandle::Get()),
heap_profiler_tag_(from_here.file_name()),
weak_factory_(this) {
- DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(task_runner_->RunsTasksOnCurrentThread());
weak_self_ = weak_factory_.GetWeakPtr();
}
@@ -29,14 +31,14 @@ Watcher::~Watcher() {
}
bool Watcher::IsWatching() const {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
return handle_.is_valid();
}
MojoResult Watcher::Start(Handle handle,
MojoHandleSignals signals,
const ReadyCallback& callback) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
DCHECK(!IsWatching());
DCHECK(!callback.is_null());
@@ -57,7 +59,7 @@ MojoResult Watcher::Start(Handle handle,
}
void Watcher::Cancel() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
// The watch may have already been cancelled if the handle was closed.
if (!handle_.is_valid())
@@ -73,7 +75,7 @@ void Watcher::Cancel() {
}
void Watcher::OnHandleReady(MojoResult result) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
ReadyCallback callback = callback_;
if (result == MOJO_RESULT_CANCELLED) {
« no previous file with comments | « mojo/public/cpp/system/watcher.h ('k') | services/device/device_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698