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

Unified Diff: base/message_loop/message_loop.cc

Issue 2818533003: Make nesting/running states a RunLoop rather than a MessageLoop concept. (Closed)
Patch Set: fix compile Created 3 years, 8 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/message_loop/message_loop.cc
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 2899f976b37298eb4d97fca40c747c1f9ea64955..5744fa73c58c5f7bfd13462b738a5485262b62c5 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -75,8 +75,6 @@ MessageLoop::TaskObserver::~TaskObserver() {
MessageLoop::DestructionObserver::~DestructionObserver() {
}
-MessageLoop::NestingObserver::~NestingObserver() {}
-
//------------------------------------------------------------------------------
MessageLoop::MessageLoop(Type type)
@@ -214,18 +212,6 @@ void MessageLoop::RemoveDestructionObserver(
destruction_observers_.RemoveObserver(destruction_observer);
}
-void MessageLoop::AddNestingObserver(NestingObserver* observer) {
- DCHECK_EQ(this, current());
- CHECK(allow_nesting_);
- nesting_observers_.AddObserver(observer);
-}
-
-void MessageLoop::RemoveNestingObserver(NestingObserver* observer) {
- DCHECK_EQ(this, current());
- CHECK(allow_nesting_);
- nesting_observers_.RemoveObserver(observer);
-}
-
void MessageLoop::QuitWhenIdle() {
DCHECK_EQ(this, current());
if (run_loop_) {
@@ -259,7 +245,7 @@ Closure MessageLoop::QuitWhenIdleClosure() {
void MessageLoop::SetNestableTasksAllowed(bool allowed) {
if (allowed) {
- CHECK(allow_nesting_);
+ CHECK(base::RunLoop::IsNestingAllowedOnCurrentThread());
// Kick the native pump just in case we enter a OS-driven nested message
// loop.
@@ -272,10 +258,9 @@ bool MessageLoop::NestableTasksAllowed() const {
return nestable_tasks_allowed_;
}
-bool MessageLoop::IsNested() {
- return run_loop_->run_depth_ > 1;
-}
-
+// TODO(gab): Migrate TaskObservers to RunLoop as part of separating concerns
+// between MessageLoop and RunLoop and making MessageLoop a swappable
+// implementation detail. http://crbug.com/703346
void MessageLoop::AddTaskObserver(TaskObserver* task_observer) {
DCHECK_EQ(this, current());
CHECK(allow_task_observers_);
@@ -288,11 +273,6 @@ void MessageLoop::RemoveTaskObserver(TaskObserver* task_observer) {
task_observers_.RemoveObserver(task_observer);
}
-bool MessageLoop::is_running() const {
- DCHECK_EQ(this, current());
- return run_loop_ != NULL;
-}
-
bool MessageLoop::HasHighResolutionTasks() {
return incoming_task_queue_->HasHighResolutionTasks();
}
@@ -383,12 +363,11 @@ void MessageLoop::SetThreadTaskRunnerHandle() {
void MessageLoop::RunHandler() {
DCHECK_EQ(this, current());
DCHECK(run_loop_);
- CHECK(allow_nesting_ || run_loop_->run_depth_ == 1);
pump_->Run(this);
}
bool MessageLoop::ProcessNextDelayedNonNestableTask() {
- if (run_loop_->run_depth_ != 1)
+ if (is_nested_)
return false;
if (deferred_non_nestable_work_queue_.empty())
@@ -430,7 +409,7 @@ void MessageLoop::RunTask(PendingTask* pending_task) {
}
bool MessageLoop::DeferOrRunPendingTask(PendingTask pending_task) {
- if (pending_task.nestable || run_loop_->run_depth_ == 1) {
+ if (pending_task.nestable || !is_nested_) {
RunTask(&pending_task);
// Show that we ran a task (Note: a new one might arrive as a
// consequence!).
@@ -496,11 +475,6 @@ void MessageLoop::ScheduleWork() {
pump_->ScheduleWork();
}
-void MessageLoop::NotifyBeginNestedLoop() {
- for (auto& observer : nesting_observers_)
- observer.OnBeginNestedMessageLoop();
-}
-
bool MessageLoop::DoWork() {
if (!nestable_tasks_allowed_) {
// Task can't be executed right now.

Powered by Google App Engine
This is Rietveld 408576698