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

Unified Diff: tools/gn/scheduler.cc

Issue 2130443002: Remove calls to MessageLoop::current() in tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR brettw (add comment) Created 4 years, 5 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 | « tools/gn/scheduler.h ('k') | tools/gn/setup.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/scheduler.cc
diff --git a/tools/gn/scheduler.cc b/tools/gn/scheduler.cc
index b5f3dd07a277ecaef22de100fa8d226afc0603b5..7364a02d93ff5c3f70b8d0c34d81af9ebe39f4ad 100644
--- a/tools/gn/scheduler.cc
+++ b/tools/gn/scheduler.cc
@@ -97,14 +97,14 @@ bool Scheduler::Run() {
}
void Scheduler::Log(const std::string& verb, const std::string& msg) {
- if (base::MessageLoop::current() == &main_loop_) {
+ if (task_runner()->BelongsToCurrentThread()) {
LogOnMainThread(verb, msg);
} else {
// The run loop always joins on the sub threads, so the lifetime of this
// object outlives the invocations of this function, hence "unretained".
- main_loop_.task_runner()->PostTask(
- FROM_HERE, base::Bind(&Scheduler::LogOnMainThread,
- base::Unretained(this), verb, msg));
+ task_runner()->PostTask(FROM_HERE,
+ base::Bind(&Scheduler::LogOnMainThread,
+ base::Unretained(this), verb, msg));
}
}
@@ -118,14 +118,14 @@ void Scheduler::FailWithError(const Err& err) {
is_failed_ = true;
}
- if (base::MessageLoop::current() == &main_loop_) {
+ if (task_runner()->BelongsToCurrentThread()) {
FailWithErrorOnMainThread(err);
} else {
// The run loop always joins on the sub threads, so the lifetime of this
// object outlives the invocations of this function, hence "unretained".
- main_loop_.task_runner()->PostTask(
- FROM_HERE, base::Bind(&Scheduler::FailWithErrorOnMainThread,
- base::Unretained(this), err));
+ task_runner()->PostTask(FROM_HERE,
+ base::Bind(&Scheduler::FailWithErrorOnMainThread,
+ base::Unretained(this), err));
}
}
@@ -208,12 +208,11 @@ void Scheduler::IncrementWorkCount() {
void Scheduler::DecrementWorkCount() {
if (!base::AtomicRefCountDec(&work_count_)) {
- if (base::MessageLoop::current() == &main_loop_) {
+ if (task_runner()->BelongsToCurrentThread()) {
OnComplete();
} else {
- main_loop_.task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&Scheduler::OnComplete, base::Unretained(this)));
+ task_runner()->PostTask(FROM_HERE, base::Bind(&Scheduler::OnComplete,
+ base::Unretained(this)));
}
}
}
@@ -236,6 +235,6 @@ void Scheduler::DoWork(const base::Closure& closure) {
void Scheduler::OnComplete() {
// Should be called on the main thread.
- DCHECK(base::MessageLoop::current() == main_loop());
+ DCHECK(task_runner()->BelongsToCurrentThread());
runner_.Quit();
}
« no previous file with comments | « tools/gn/scheduler.h ('k') | tools/gn/setup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698