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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 614233002: Revert of 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, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 RenderThreadImpl::RenderThreadImpl() 394 RenderThreadImpl::RenderThreadImpl()
395 : ChildThread(Options(ShouldUseMojoChannel())) { 395 : ChildThread(Options(ShouldUseMojoChannel())) {
396 Init(); 396 Init();
397 } 397 }
398 398
399 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) 399 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name)
400 : ChildThread(Options(channel_name, ShouldUseMojoChannel())) { 400 : ChildThread(Options(channel_name, ShouldUseMojoChannel())) {
401 Init(); 401 Init();
402 } 402 }
403 403
404 RenderThreadImpl::RenderThreadImpl(
405 scoped_ptr<base::MessageLoop> main_message_loop)
406 : ChildThread(Options(ShouldUseMojoChannel())),
407 main_message_loop_(main_message_loop.Pass()) {
408 Init();
409 }
410
411 void RenderThreadImpl::Init() { 404 void RenderThreadImpl::Init() {
412 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); 405 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, "");
413 406
414 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( 407 base::debug::TraceLog::GetInstance()->SetThreadSortIndex(
415 base::PlatformThread::CurrentId(), 408 base::PlatformThread::CurrentId(),
416 kTraceEventRendererMainThreadSortIndex); 409 kTraceEventRendererMainThreadSortIndex);
417 410
418 #if defined(OS_MACOSX) || defined(OS_ANDROID) 411 #if defined(OS_MACOSX) || defined(OS_ANDROID)
419 // On Mac and Android, the select popups are rendered by the browser. 412 // On Mac and Android, the select popups are rendered by the browser.
420 blink::WebView::setUseExternalPopupMenus(true); 413 blink::WebView::setUseExternalPopupMenus(true);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // EmbeddedWorkerDispatcher. So it must be deleted before deleting 650 // EmbeddedWorkerDispatcher. So it must be deleted before deleting
658 // RenderThreadImpl. 651 // RenderThreadImpl.
659 embedded_worker_dispatcher_.reset(); 652 embedded_worker_dispatcher_.reset();
660 653
661 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might 654 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might
662 // hold pointers to V8 objects (e.g., via pending requests). 655 // hold pointers to V8 objects (e.g., via pending requests).
663 main_thread_indexed_db_dispatcher_.reset(); 656 main_thread_indexed_db_dispatcher_.reset();
664 657
665 main_thread_compositor_task_runner_ = NULL; 658 main_thread_compositor_task_runner_ = NULL;
666 659
667 gpu_channel_ = NULL; 660 if (webkit_platform_support_)
661 blink::shutdown();
662
663 lazy_tls.Pointer()->Set(NULL);
668 664
669 // TODO(port) 665 // TODO(port)
670 #if defined(OS_WIN) 666 #if defined(OS_WIN)
671 // Clean up plugin channels before this thread goes away. 667 // Clean up plugin channels before this thread goes away.
672 NPChannelBase::CleanupChannels(); 668 NPChannelBase::CleanupChannels();
673 #endif 669 #endif
674
675 // Shut down the message loop before shutting down Blink.
676 // This prevents a scenario where a pending task in the message loop accesses
677 // Blink objects after Blink shuts down.
678 // This must be at the very end of the shutdown sequence. You must not touch
679 // the message loop after this.
680 main_message_loop_.reset();
681 if (webkit_platform_support_)
682 blink::shutdown();
683
684 lazy_tls.Pointer()->Set(NULL);
685 } 670 }
686 671
687 bool RenderThreadImpl::Send(IPC::Message* msg) { 672 bool RenderThreadImpl::Send(IPC::Message* msg) {
688 // Certain synchronous messages cannot always be processed synchronously by 673 // Certain synchronous messages cannot always be processed synchronously by
689 // the browser, e.g., putting up UI and waiting for the user. This could cause 674 // the browser, e.g., putting up UI and waiting for the user. This could cause
690 // a complete hang of Chrome if a windowed plug-in is trying to communicate 675 // a complete hang of Chrome if a windowed plug-in is trying to communicate
691 // with the renderer thread since the browser's UI thread could be stuck 676 // with the renderer thread since the browser's UI thread could be stuck
692 // (within a Windows API call) trying to synchronously communicate with the 677 // (within a Windows API call) trying to synchronously communicate with the
693 // plug-in. The remedy is to pump messages on this thread while the browser 678 // plug-in. The remedy is to pump messages on this thread while the browser
694 // is processing this request. This creates an opportunity for re-entrancy 679 // is processing this request. This creates an opportunity for re-entrancy
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 hidden_widget_count_--; 1620 hidden_widget_count_--;
1636 1621
1637 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { 1622 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) {
1638 return; 1623 return;
1639 } 1624 }
1640 1625
1641 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 1626 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
1642 } 1627 }
1643 1628
1644 } // namespace content 1629 } // namespace content
OLDNEW
« 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