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

Unified Diff: content/renderer/render_thread_impl.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, 1 month 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
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 8566532a3d7fbe72e48ec3e7d24f447388531539..ffa82bd09b7809a8c51f3169e0c66599541dc0ec 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -408,6 +408,13 @@ RenderThreadImpl::RenderThreadImpl(const std::string& channel_name)
Init();
}
+RenderThreadImpl::RenderThreadImpl(
+ scoped_ptr<base::MessageLoop> main_message_loop)
+ : ChildThread(Options(ShouldUseMojoChannel())),
+ main_message_loop_(main_message_loop.Pass()) {
+ Init();
+}
+
void RenderThreadImpl::Init() {
TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, "");
@@ -665,16 +672,25 @@ void RenderThreadImpl::Shutdown() {
main_thread_compositor_task_runner_ = NULL;
- if (blink_platform_impl_)
- blink::shutdown();
-
- lazy_tls.Pointer()->Set(NULL);
+ if (gpu_channel_.get())
+ gpu_channel_->DestroyChannel();
// TODO(port)
#if defined(OS_WIN)
// Clean up plugin channels before this thread goes away.
NPChannelBase::CleanupChannels();
#endif
+
+ // Shut down the message loop before shutting down Blink.
+ // This prevents a scenario where a pending task in the message loop accesses
+ // Blink objects after Blink shuts down.
+ // This must be at the very end of the shutdown sequence. You must not touch
+ // the message loop after this.
+ main_message_loop_.reset();
+ if (blink_platform_impl_)
+ blink::shutdown();
+
+ lazy_tls.Pointer()->Set(NULL);
}
bool RenderThreadImpl::Send(IPC::Message* msg) {
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698