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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 2159123002: Shutdown renderer main message loop before blink::shutdown() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 4 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
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/test/test_blink_web_unit_test_support.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 830fd3d6b5dbcd012547f6644cd421341f598182..7e3c20c24b83da88343d3797c2c9ad351d12ee01 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -698,7 +698,7 @@ void RenderThreadImpl::Init(
new PeerConnectionDependencyFactory(p2p_socket_dispatcher_.get()));
aec_dump_message_filter_ = new AecDumpMessageFilter(
- GetIOTaskRunner(), message_loop()->task_runner());
+ GetIOTaskRunner(), main_task_runner());
AddFilter(aec_dump_message_filter_.get());
@@ -988,6 +988,14 @@ void RenderThreadImpl::Shutdown() {
// blink::shutdown() must be called after all strong references from
// Chromium to Blink are cleared.
blink::shutdown();
+
+ // Clear the message loop here because pending tasks can hold Persintent
+ // handle to GCed object, which can not outlive Oilpan heap.
+ if (main_message_loop_)
+ base::RunLoop().RunUntilIdle();
+ main_message_loop_ = nullptr;
+
+ blink::Platform::shutdown();
}
// Delay shutting down DiscardableSharedMemoryManager until blink::shutdown
@@ -995,11 +1003,6 @@ void RenderThreadImpl::Shutdown() {
// may try to unlock their underlying discardable memory.
ChildThreadImpl::ShutdownDiscardableSharedMemoryManager();
- // The message loop must be cleared after shutting down
- // the DiscardableSharedMemoryManager, which needs to send messages
- // to the browser process.
- main_message_loop_.reset();
-
lazy_tls.Pointer()->Set(nullptr);
}
@@ -1186,7 +1189,8 @@ void RenderThreadImpl::InitializeWebKit(
blink_platform_impl_.reset(new RendererBlinkPlatformImpl(
renderer_scheduler_.get(),
GetRemoteInterfaces()->GetWeakPtr()));
- blink::initialize(blink_platform_impl_.get());
+ blink::Platform::initialize(blink_platform_impl_.get());
+ blink::initialize();
v8::Isolate* isolate = blink::mainThreadIsolate();
isolate->SetCreateHistogramFunction(CreateHistogram);
@@ -2073,7 +2077,7 @@ void RenderThreadImpl::OnMemoryPressure(
scoped_refptr<base::SingleThreadTaskRunner>
RenderThreadImpl::GetFileThreadTaskRunner() {
- DCHECK(message_loop()->task_runner()->BelongsToCurrentThread());
+ DCHECK(main_task_runner()->BelongsToCurrentThread());
if (!file_thread_) {
file_thread_.reset(new base::Thread("Renderer::FILE"));
file_thread_->Start();
@@ -2083,7 +2087,7 @@ RenderThreadImpl::GetFileThreadTaskRunner() {
scoped_refptr<base::SingleThreadTaskRunner>
RenderThreadImpl::GetMediaThreadTaskRunner() {
- DCHECK(message_loop()->task_runner()->BelongsToCurrentThread());
+ DCHECK(main_task_runner()->BelongsToCurrentThread());
if (!media_thread_) {
media_thread_.reset(new base::Thread("Media"));
media_thread_->Start();
« no previous file with comments | « content/public/test/render_view_test.cc ('k') | content/test/test_blink_web_unit_test_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698