OLD | NEW |
---|---|
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 Loading... | |
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 | |
404 void RenderThreadImpl::Init() { | 411 void RenderThreadImpl::Init() { |
405 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); | 412 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); |
406 | 413 |
407 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( | 414 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( |
408 base::PlatformThread::CurrentId(), | 415 base::PlatformThread::CurrentId(), |
409 kTraceEventRendererMainThreadSortIndex); | 416 kTraceEventRendererMainThreadSortIndex); |
410 | 417 |
411 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 418 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
412 // On Mac and Android, the select popups are rendered by the browser. | 419 // On Mac and Android, the select popups are rendered by the browser. |
413 blink::WebView::setUseExternalPopupMenus(true); | 420 blink::WebView::setUseExternalPopupMenus(true); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 // EmbeddedWorkerDispatcher. So it must be deleted before deleting | 657 // EmbeddedWorkerDispatcher. So it must be deleted before deleting |
651 // RenderThreadImpl. | 658 // RenderThreadImpl. |
652 embedded_worker_dispatcher_.reset(); | 659 embedded_worker_dispatcher_.reset(); |
653 | 660 |
654 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might | 661 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might |
655 // hold pointers to V8 objects (e.g., via pending requests). | 662 // hold pointers to V8 objects (e.g., via pending requests). |
656 main_thread_indexed_db_dispatcher_.reset(); | 663 main_thread_indexed_db_dispatcher_.reset(); |
657 | 664 |
658 main_thread_compositor_task_runner_ = NULL; | 665 main_thread_compositor_task_runner_ = NULL; |
659 | 666 |
660 if (webkit_platform_support_) | 667 if (gpu_channel_.get()) |
661 blink::shutdown(); | 668 gpu_channel_->DestroyChannel(); |
haraken
2014/10/03 04:28:13
Just doing 'gpu_channel_ = NULL' was not enough, b
| |
662 | |
663 lazy_tls.Pointer()->Set(NULL); | |
664 | 669 |
665 // TODO(port) | 670 // TODO(port) |
666 #if defined(OS_WIN) | 671 #if defined(OS_WIN) |
667 // Clean up plugin channels before this thread goes away. | 672 // Clean up plugin channels before this thread goes away. |
668 NPChannelBase::CleanupChannels(); | 673 NPChannelBase::CleanupChannels(); |
669 #endif | 674 #endif |
675 | |
676 // Shut down the message loop before shutting down Blink. | |
677 // This prevents a scenario where a pending task in the message loop accesses | |
678 // Blink objects after Blink shuts down. | |
679 // This must be at the very end of the shutdown sequence. You must not touch | |
680 // the message loop after this. | |
681 main_message_loop_.reset(); | |
682 if (webkit_platform_support_) | |
683 blink::shutdown(); | |
684 | |
685 lazy_tls.Pointer()->Set(NULL); | |
670 } | 686 } |
671 | 687 |
672 bool RenderThreadImpl::Send(IPC::Message* msg) { | 688 bool RenderThreadImpl::Send(IPC::Message* msg) { |
673 // Certain synchronous messages cannot always be processed synchronously by | 689 // Certain synchronous messages cannot always be processed synchronously by |
674 // the browser, e.g., putting up UI and waiting for the user. This could cause | 690 // the browser, e.g., putting up UI and waiting for the user. This could cause |
675 // a complete hang of Chrome if a windowed plug-in is trying to communicate | 691 // a complete hang of Chrome if a windowed plug-in is trying to communicate |
676 // with the renderer thread since the browser's UI thread could be stuck | 692 // with the renderer thread since the browser's UI thread could be stuck |
677 // (within a Windows API call) trying to synchronously communicate with the | 693 // (within a Windows API call) trying to synchronously communicate with the |
678 // plug-in. The remedy is to pump messages on this thread while the browser | 694 // plug-in. The remedy is to pump messages on this thread while the browser |
679 // is processing this request. This creates an opportunity for re-entrancy | 695 // is processing this request. This creates an opportunity for re-entrancy |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1620 hidden_widget_count_--; | 1636 hidden_widget_count_--; |
1621 | 1637 |
1622 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1638 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1623 return; | 1639 return; |
1624 } | 1640 } |
1625 | 1641 |
1626 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1642 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1627 } | 1643 } |
1628 | 1644 |
1629 } // namespace content | 1645 } // namespace content |
OLD | NEW |