Index: base/message_loop/message_loop.cc |
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc |
index 2315fd14b127de472eddd37b2df348481648170f..6291d060013fde0483ed08be91527c0cabf514d4 100644 |
--- a/base/message_loop/message_loop.cc |
+++ b/base/message_loop/message_loop.cc |
@@ -525,6 +525,18 @@ void MessageLoop::ScheduleWork(bool was_empty) { |
pump_->ScheduleWork(); |
} |
+void MessageLoop::ReloadAllWorkQueues() { |
+ ReloadWorkQueue(); |
+} |
+ |
+TaskQueue& MessageLoop::GetNextWorkQueue() { |
+ return work_queue_; |
+} |
+ |
+bool MessageLoop::HasWorkAvailable() const { |
+ return !work_queue_.empty(); |
+} |
+ |
//------------------------------------------------------------------------------ |
// Method and data for histogramming events and actions taken by each instance |
// on each thread. |
@@ -558,14 +570,17 @@ bool MessageLoop::DoWork() { |
} |
for (;;) { |
- ReloadWorkQueue(); |
- if (work_queue_.empty()) |
+ ReloadAllWorkQueues(); |
+ |
+ if (!HasWorkAvailable()) |
break; |
+ TaskQueue& current_work_queue = GetNextWorkQueue(); |
+ |
// Execute oldest task. |
do { |
- PendingTask pending_task = work_queue_.front(); |
- work_queue_.pop(); |
+ PendingTask pending_task = current_work_queue.front(); |
+ current_work_queue.pop(); |
if (!pending_task.delayed_run_time.is_null()) { |
AddToDelayedWorkQueue(pending_task); |
// If we changed the topmost task, then it is time to reschedule. |
@@ -575,7 +590,7 @@ bool MessageLoop::DoWork() { |
if (DeferOrRunPendingTask(pending_task)) |
return true; |
} |
- } while (!work_queue_.empty()); |
+ } while (!current_work_queue.empty()); |
} |
// Nothing happened. |