Bug 797239 - Fix message loop to allow idle tasks to work in child content processes. r=cjones

This commit is contained in:
Dave Hylands 2012-10-08 22:46:18 -06:00
parent 14aa4979b0
commit d883cb7a0c
2 changed files with 10 additions and 2 deletions

View File

@ -90,6 +90,7 @@ MessageLoop::MessageLoop(Type type)
nestable_tasks_allowed_(true),
exception_restoration_(false),
state_(NULL),
run_depth_base_(1),
#ifdef OS_WIN
os_modal_loop_(false),
#endif // OS_WIN
@ -102,6 +103,12 @@ MessageLoop::MessageLoop(Type type)
}
if (type_ == TYPE_MOZILLA_CHILD) {
pump_ = new mozilla::ipc::MessagePumpForChildProcess();
// There is a MessageLoop Run call from XRE_InitChildProcess
// and another one from MessagePumpForChildProcess. The one
// from MessagePumpForChildProcess becomes the base, so we need
// to set run_depth_base_ to 2 or we'll never be able to process
// Idle tasks.
run_depth_base_ = 2;
return;
}
@ -212,7 +219,7 @@ void MessageLoop::RunInternal() {
// Wrapper functions for use in above message loop framework.
bool MessageLoop::ProcessNextDelayedNonNestableTask() {
if (state_->run_depth != 1)
if (state_->run_depth > run_depth_base_)
return false;
if (deferred_non_nestable_work_queue_.empty())
@ -330,7 +337,7 @@ void MessageLoop::RunTask(Task* task) {
}
bool MessageLoop::DeferOrRunPendingTask(const PendingTask& pending_task) {
if (pending_task.nestable || state_->run_depth == 1) {
if (pending_task.nestable || state_->run_depth >= run_depth_base_) {
RunTask(pending_task.task);
// Show that we ran a task (Note: a new one might arrive as a
// consequence!).

View File

@ -408,6 +408,7 @@ public:
Lock incoming_queue_lock_;
RunState* state_;
int run_depth_base_;
#if defined(OS_WIN)
// Should be set to true before calling Windows APIs like TrackPopupMenu, etc