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

Unified Diff: base/message_loop/message_loop.cc

Issue 583043005: Pending tasks in a message loop should be deleted before shutting down Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 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

Powered by Google App Engine
This is Rietveld 408576698