Chromium Code Reviews| 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 <utility> | 10 #include <utility> |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 #endif | 607 #endif |
| 608 | 608 |
| 609 lazy_tls.Pointer()->Set(this); | 609 lazy_tls.Pointer()->Set(this); |
| 610 | 610 |
| 611 // Register this object as the main thread. | 611 // Register this object as the main thread. |
| 612 ChildProcess::current()->set_main_thread(this); | 612 ChildProcess::current()->set_main_thread(this); |
| 613 | 613 |
| 614 InitializeWebKit(resource_task_queue); | 614 InitializeWebKit(resource_task_queue); |
| 615 | 615 |
| 616 // In single process the single process is all there is. | 616 // In single process the single process is all there is. |
| 617 notify_webkit_of_modal_loop_ = true; | |
| 618 webkit_shared_timer_suspended_ = false; | 617 webkit_shared_timer_suspended_ = false; |
| 619 widget_count_ = 0; | 618 widget_count_ = 0; |
| 620 hidden_widget_count_ = 0; | 619 hidden_widget_count_ = 0; |
| 621 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 620 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
| 622 idle_notifications_to_skip_ = 0; | 621 idle_notifications_to_skip_ = 0; |
| 623 layout_test_mode_ = false; | 622 layout_test_mode_ = false; |
| 624 | 623 |
| 625 appcache_dispatcher_.reset( | 624 appcache_dispatcher_.reset( |
| 626 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); | 625 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); |
| 627 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); | 626 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 | 940 |
| 942 lazy_tls.Pointer()->Set(NULL); | 941 lazy_tls.Pointer()->Set(NULL); |
| 943 } | 942 } |
| 944 | 943 |
| 945 bool RenderThreadImpl::Send(IPC::Message* msg) { | 944 bool RenderThreadImpl::Send(IPC::Message* msg) { |
| 946 // Certain synchronous messages cannot always be processed synchronously by | 945 // Certain synchronous messages cannot always be processed synchronously by |
| 947 // the browser, e.g., putting up UI and waiting for the user. This could cause | 946 // the browser, e.g., putting up UI and waiting for the user. This could cause |
| 948 // a complete hang of Chrome if a windowed plugin is trying to communicate | 947 // a complete hang of Chrome if a windowed plugin is trying to communicate |
| 949 // with the renderer thread since the browser's UI thread could be stuck | 948 // with the renderer thread since the browser's UI thread could be stuck |
| 950 // (within a Windows API call) trying to synchronously communicate with the | 949 // (within a Windows API call) trying to synchronously communicate with the |
| 951 // plugin. The remedy is to pump messages on this thread while the browser | 950 // plugin. The remedy is to pump messages on this thread while the browser |
|
no sievers
2016/05/18 20:11:24
So how does the described scenario not break with
Changwan Ryu
2016/05/19 00:44:56
I'm not entirely removing the remedy in this patch
Changwan Ryu
2016/05/19 01:00:31
Correction: s/PPAPI/NPAPI
| |
| 952 // is processing this request. This creates an opportunity for re-entrancy | 951 // is processing this request. This creates an opportunity for re-entrancy |
|
no sievers
2016/05/18 20:11:24
This comment (or part of it) doesn't apply anymore
Changwan Ryu
2016/05/19 00:44:56
It still holds for some cases such as PrintWebView
| |
| 953 // into WebKit, so we need to take care to disable callbacks, timers, and | 952 // into WebKit, so we need to take care to disable callbacks, timers, and |
| 954 // pending network loads that could trigger such callbacks. | 953 // pending network loads that could trigger such callbacks. |
| 955 bool pumping_events = false; | 954 bool pumping_events = false; |
| 956 if (msg->is_sync()) { | 955 if (msg->is_sync()) { |
| 957 if (msg->is_caller_pumping_messages()) { | 956 if (msg->is_caller_pumping_messages()) { |
| 958 pumping_events = true; | 957 pumping_events = true; |
| 959 } | 958 } |
| 960 } | 959 } |
| 961 | 960 |
| 962 bool notify_webkit_of_modal_loop = true; // default value | |
| 963 std::swap(notify_webkit_of_modal_loop, notify_webkit_of_modal_loop_); | |
| 964 | |
| 965 if (pumping_events) { | 961 if (pumping_events) { |
| 966 renderer_scheduler_->SuspendTimerQueue(); | 962 renderer_scheduler_->SuspendTimerQueue(); |
| 967 | 963 WebView::willEnterModalLoop(); |
|
no sievers
2016/05/18 20:11:24
...and related to that: why do we still need to te
Changwan Ryu
2016/05/19 00:44:56
PrintWebViewHelper and FlashMessageLoop may need t
Lei Zhang
2016/05/19 00:50:28
window.print() is still a thing and it is synchron
Changwan Ryu
2016/05/19 01:00:31
Thanks for the correction. I mean alert(), beforeu
| |
| 968 if (notify_webkit_of_modal_loop) | |
| 969 WebView::willEnterModalLoop(); | |
| 970 } | 964 } |
| 971 | 965 |
| 972 bool rv = ChildThreadImpl::Send(msg); | 966 bool rv = ChildThreadImpl::Send(msg); |
| 973 | 967 |
| 974 if (pumping_events) { | 968 if (pumping_events) { |
| 975 if (notify_webkit_of_modal_loop) | 969 WebView::didExitModalLoop(); |
| 976 WebView::didExitModalLoop(); | |
| 977 | |
| 978 renderer_scheduler_->ResumeTimerQueue(); | 970 renderer_scheduler_->ResumeTimerQueue(); |
| 979 } | 971 } |
| 980 | 972 |
| 981 return rv; | 973 return rv; |
| 982 } | 974 } |
| 983 | 975 |
| 984 IPC::SyncChannel* RenderThreadImpl::GetChannel() { | 976 IPC::SyncChannel* RenderThreadImpl::GetChannel() { |
| 985 return channel(); | 977 return channel(); |
| 986 } | 978 } |
| 987 | 979 |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1613 scoped_refptr<base::SingleThreadTaskRunner> | 1605 scoped_refptr<base::SingleThreadTaskRunner> |
| 1614 RenderThreadImpl::GetIOThreadTaskRunner() { | 1606 RenderThreadImpl::GetIOThreadTaskRunner() { |
| 1615 return io_thread_task_runner_; | 1607 return io_thread_task_runner_; |
| 1616 } | 1608 } |
| 1617 | 1609 |
| 1618 std::unique_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( | 1610 std::unique_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( |
| 1619 size_t size) { | 1611 size_t size) { |
| 1620 return HostAllocateSharedMemoryBuffer(size); | 1612 return HostAllocateSharedMemoryBuffer(size); |
| 1621 } | 1613 } |
| 1622 | 1614 |
| 1623 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | |
| 1624 notify_webkit_of_modal_loop_ = false; | |
| 1625 } | |
| 1626 | |
| 1627 void RenderThreadImpl::OnChannelError() { | 1615 void RenderThreadImpl::OnChannelError() { |
| 1628 // In single-process mode, the renderer can't be restarted after shutdown. | 1616 // In single-process mode, the renderer can't be restarted after shutdown. |
| 1629 // So, if we get a channel error, crash the whole process right now to get a | 1617 // So, if we get a channel error, crash the whole process right now to get a |
| 1630 // more informative stack, since we will otherwise just crash later when we | 1618 // more informative stack, since we will otherwise just crash later when we |
| 1631 // try to restart it. | 1619 // try to restart it. |
| 1632 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1620 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1633 switches::kSingleProcess)); | 1621 switches::kSingleProcess)); |
| 1634 ChildThreadImpl::OnChannelError(); | 1622 ChildThreadImpl::OnChannelError(); |
| 1635 } | 1623 } |
| 1636 | 1624 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2046 } | 2034 } |
| 2047 | 2035 |
| 2048 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2036 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2049 size_t erased = | 2037 size_t erased = |
| 2050 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2038 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2051 routing_id_); | 2039 routing_id_); |
| 2052 DCHECK_EQ(1u, erased); | 2040 DCHECK_EQ(1u, erased); |
| 2053 } | 2041 } |
| 2054 | 2042 |
| 2055 } // namespace content | 2043 } // namespace content |
| OLD | NEW |