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 |
667 gpu_channel_ = NULL; | |
668 | |
669 // Shut down the message loop before shutting down Blink. | |
670 // This prevents a scenario where a pending task in the message loop accesses | |
671 // Blink objects after Blink shuts down. | |
672 main_message_loop_.reset(); | |
660 if (webkit_platform_support_) | 673 if (webkit_platform_support_) |
661 blink::shutdown(); | 674 blink::shutdown(); |
662 | 675 |
663 lazy_tls.Pointer()->Set(NULL); | 676 lazy_tls.Pointer()->Set(NULL); |
664 | 677 |
665 // TODO(port) | 678 // TODO(port) |
666 #if defined(OS_WIN) | 679 #if defined(OS_WIN) |
667 // Clean up plugin channels before this thread goes away. | 680 // Clean up plugin channels before this thread goes away. |
668 NPChannelBase::CleanupChannels(); | 681 NPChannelBase::CleanupChannels(); |
jamesr
2014/09/29 19:03:56
could this cause problems? it appears to call into
haraken
2014/09/30 01:08:19
Moved this line up to the main_message_loop_.reset
| |
669 #endif | 682 #endif |
670 } | 683 } |
671 | 684 |
672 bool RenderThreadImpl::Send(IPC::Message* msg) { | 685 bool RenderThreadImpl::Send(IPC::Message* msg) { |
673 // Certain synchronous messages cannot always be processed synchronously by | 686 // 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 | 687 // 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 | 688 // 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 | 689 // 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 | 690 // (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 | 691 // plug-in. The remedy is to pump messages on this thread while the browser |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1620 hidden_widget_count_--; | 1633 hidden_widget_count_--; |
1621 | 1634 |
1622 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1635 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1623 return; | 1636 return; |
1624 } | 1637 } |
1625 | 1638 |
1626 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1639 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1627 } | 1640 } |
1628 | 1641 |
1629 } // namespace content | 1642 } // namespace content |
OLD | NEW |