Index: base/message_loop/message_loop.cc |
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc |
index c01e5421bc3478605c5a0b16ef15d36a6bb9af78..b4977e25bccee510223e895b304b424f3aa81758 100644 |
--- a/base/message_loop/message_loop.cc |
+++ b/base/message_loop/message_loop.cc |
@@ -163,6 +163,25 @@ MessageLoop::~MessageLoop() { |
if (in_high_res_mode_) |
Time::ActivateHighResolutionTimer(false); |
#endif |
+ |
+ FlushPendingTasks(); |
+ |
+ // Let interested parties have one last shot at accessing this. |
+ FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_, |
+ WillDestroyCurrentMessageLoop()); |
+ |
+ thread_task_runner_handle_.reset(); |
+ |
+ // Tell the incoming queue that we are dying. |
+ incoming_task_queue_->WillDestroyCurrentMessageLoop(); |
+ incoming_task_queue_ = NULL; |
+ message_loop_proxy_ = NULL; |
+ |
+ // OK, now make it so that no one can find us. |
+ lazy_tls_ptr.Pointer()->Set(NULL); |
+} |
+ |
+void MessageLoop::FlushPendingTasks() { |
// Clean up any unprocessed tasks, but take care: deleting a task could |
// result in the addition of more tasks (e.g., via DeleteSoon). We set a |
// limit on the number of times we will allow a deleted task to generate more |
@@ -179,20 +198,6 @@ MessageLoop::~MessageLoop() { |
break; |
} |
DCHECK(!did_work); |
- |
- // Let interested parties have one last shot at accessing this. |
- FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_, |
- WillDestroyCurrentMessageLoop()); |
- |
- thread_task_runner_handle_.reset(); |
- |
- // Tell the incoming queue that we are dying. |
- incoming_task_queue_->WillDestroyCurrentMessageLoop(); |
- incoming_task_queue_ = NULL; |
- message_loop_proxy_ = NULL; |
- |
- // OK, now make it so that no one can find us. |
- lazy_tls_ptr.Pointer()->Set(NULL); |
} |
// static |