Make RunLoop 100% standalone.
MessageLoop is no longer a friend of RunLoop :)!
The only minor dependency remaining shows up in tests as allowing
nestable tasks in a scope (different from allowing nested loops on a
thread in general) is still a MessageLoop concept. I plan to move that
to RunLoop as well in a follow-up.
[email protected]
Bug: 703346
Change-Id: I0a6269c94de179d97c14855499edd70be9e1d1af
Reviewed-on: https://chromium-review.googlesource.com/594352
Reviewed-by: danakj <[email protected]>
Commit-Queue: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/master@{#491258}
diff --git a/base/run_loop.cc b/base/run_loop.cc
index 41171bd..072684f6 100644
--- a/base/run_loop.cc
+++ b/base/run_loop.cc
@@ -48,11 +48,10 @@
tls_delegate.Get().Set(nullptr);
}
-RunLoop* RunLoop::Delegate::Client::GetTopMostRunLoop() const {
+bool RunLoop::Delegate::Client::ShouldQuitWhenIdle() const {
DCHECK_CALLED_ON_VALID_THREAD(outer_->bound_thread_checker_);
DCHECK(outer_->bound_);
- return outer_->active_run_loops_.empty() ? nullptr
- : outer_->active_run_loops_.top();
+ return outer_->active_run_loops_.top()->quit_when_idle_received_;
}
bool RunLoop::Delegate::Client::IsNested() const {
@@ -82,8 +81,8 @@
: delegate_(tls_delegate.Get().Get()),
origin_task_runner_(ThreadTaskRunnerHandle::Get()),
weak_factory_(this) {
- // A RunLoop::Delegate must be bound to this thread prior to using RunLoop.
- DCHECK(delegate_);
+ DCHECK(delegate_) << "A RunLoop::Delegate must be bound to this thread prior "
+ "to using RunLoop.";
DCHECK(origin_task_runner_);
}
@@ -272,7 +271,7 @@
RunLoop* previous_run_loop =
active_run_loops_.empty() ? nullptr : active_run_loops_.top();
- // Execute deferred QuitNow, if any:
+ // Execute deferred Quit, if any:
if (previous_run_loop && previous_run_loop->quit_called_)
delegate_->Quit();
}