Index: base/message_loop/message_loop.cc |
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc |
index ef7747ef06998475ede2369c110c8efcb2ba712a..23fd0751c68bf2c43ea435050e2a6f94d57fed9a 100644 |
--- a/base/message_loop/message_loop.cc |
+++ b/base/message_loop/message_loop.cc |
@@ -124,8 +124,10 @@ MessageLoop::~MessageLoop() { |
DCHECK(!did_work); |
// Let interested parties have one last shot at accessing this. |
- FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_, |
- WillDestroyCurrentMessageLoop()); |
+ if (enable_destruction_observers_) { |
+ FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_, |
+ WillDestroyCurrentMessageLoop()); |
+ } |
thread_task_runner_handle_.reset(); |
@@ -205,22 +207,26 @@ std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) { |
void MessageLoop::AddDestructionObserver( |
DestructionObserver* destruction_observer) { |
DCHECK_EQ(this, current()); |
+ //DCHECK(enable_destruction_observers_); |
destruction_observers_.AddObserver(destruction_observer); |
} |
void MessageLoop::RemoveDestructionObserver( |
DestructionObserver* destruction_observer) { |
DCHECK_EQ(this, current()); |
+ //DCHECK(enable_destruction_observers_); |
destruction_observers_.RemoveObserver(destruction_observer); |
} |
void MessageLoop::AddNestingObserver(NestingObserver* observer) { |
DCHECK_EQ(this, current()); |
+ DCHECK(enable_nesting_); |
nesting_observers_.AddObserver(observer); |
} |
void MessageLoop::RemoveNestingObserver(NestingObserver* observer) { |
DCHECK_EQ(this, current()); |
+ DCHECK(enable_nesting_); |
nesting_observers_.RemoveObserver(observer); |
} |
@@ -274,11 +280,13 @@ bool MessageLoop::IsNested() { |
void MessageLoop::AddTaskObserver(TaskObserver* task_observer) { |
DCHECK_EQ(this, current()); |
+ DCHECK(enable_task_observers_); |
task_observers_.AddObserver(task_observer); |
} |
void MessageLoop::RemoveTaskObserver(TaskObserver* task_observer) { |
DCHECK_EQ(this, current()); |
+ DCHECK(enable_task_observers_); |
task_observers_.RemoveObserver(task_observer); |
} |
@@ -367,6 +375,7 @@ void MessageLoop::SetThreadTaskRunnerHandle() { |
void MessageLoop::RunHandler() { |
DCHECK_EQ(this, current()); |
+ DCHECK(enable_nesting_ || run_loop_->run_depth_ == 1); |
pump_->Run(this); |
} |