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

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

Issue 1931793002: Stop using nested message loop for alert() and other JS dialogs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use infinite loop instead of 10 secs Created 4 years, 7 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
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 <utility> 10 #include <utility>
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 #endif 655 #endif
656 656
657 lazy_tls.Pointer()->Set(this); 657 lazy_tls.Pointer()->Set(this);
658 658
659 // Register this object as the main thread. 659 // Register this object as the main thread.
660 ChildProcess::current()->set_main_thread(this); 660 ChildProcess::current()->set_main_thread(this);
661 661
662 InitializeWebKit(resource_task_queue); 662 InitializeWebKit(resource_task_queue);
663 663
664 // In single process the single process is all there is. 664 // In single process the single process is all there is.
665 notify_webkit_of_modal_loop_ = true;
666 webkit_shared_timer_suspended_ = false; 665 webkit_shared_timer_suspended_ = false;
667 widget_count_ = 0; 666 widget_count_ = 0;
668 hidden_widget_count_ = 0; 667 hidden_widget_count_ = 0;
669 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; 668 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs;
670 idle_notifications_to_skip_ = 0; 669 idle_notifications_to_skip_ = 0;
671 layout_test_mode_ = false; 670 layout_test_mode_ = false;
672 671
673 appcache_dispatcher_.reset( 672 appcache_dispatcher_.reset(
674 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); 673 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl()));
675 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); 674 dom_storage_dispatcher_.reset(new DomStorageDispatcher());
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 // is processing this request. This creates an opportunity for re-entrancy 999 // is processing this request. This creates an opportunity for re-entrancy
1001 // into WebKit, so we need to take care to disable callbacks, timers, and 1000 // into WebKit, so we need to take care to disable callbacks, timers, and
1002 // pending network loads that could trigger such callbacks. 1001 // pending network loads that could trigger such callbacks.
1003 bool pumping_events = false; 1002 bool pumping_events = false;
1004 if (msg->is_sync()) { 1003 if (msg->is_sync()) {
1005 if (msg->is_caller_pumping_messages()) { 1004 if (msg->is_caller_pumping_messages()) {
1006 pumping_events = true; 1005 pumping_events = true;
1007 } 1006 }
1008 } 1007 }
1009 1008
1010 bool notify_webkit_of_modal_loop = true; // default value
1011 std::swap(notify_webkit_of_modal_loop, notify_webkit_of_modal_loop_);
1012
1013 if (pumping_events) { 1009 if (pumping_events) {
1014 renderer_scheduler_->SuspendTimerQueue(); 1010 renderer_scheduler_->SuspendTimerQueue();
1015 1011 WebView::willEnterModalLoop();
1016 if (notify_webkit_of_modal_loop)
1017 WebView::willEnterModalLoop();
1018 } 1012 }
1019 1013
1020 bool rv = ChildThreadImpl::Send(msg); 1014 bool rv = ChildThreadImpl::Send(msg);
1021 1015
1022 if (pumping_events) { 1016 if (pumping_events) {
1023 if (notify_webkit_of_modal_loop) 1017 WebView::didExitModalLoop();
1024 WebView::didExitModalLoop();
1025
1026 renderer_scheduler_->ResumeTimerQueue(); 1018 renderer_scheduler_->ResumeTimerQueue();
1027 } 1019 }
1028 1020
1029 return rv; 1021 return rv;
1030 } 1022 }
1031 1023
1032 IPC::SyncChannel* RenderThreadImpl::GetChannel() { 1024 IPC::SyncChannel* RenderThreadImpl::GetChannel() {
1033 return channel(); 1025 return channel();
1034 } 1026 }
1035 1027
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 scoped_refptr<base::SingleThreadTaskRunner> 1662 scoped_refptr<base::SingleThreadTaskRunner>
1671 RenderThreadImpl::GetIOThreadTaskRunner() { 1663 RenderThreadImpl::GetIOThreadTaskRunner() {
1672 return io_thread_task_runner_; 1664 return io_thread_task_runner_;
1673 } 1665 }
1674 1666
1675 std::unique_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( 1667 std::unique_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory(
1676 size_t size) { 1668 size_t size) {
1677 return HostAllocateSharedMemoryBuffer(size); 1669 return HostAllocateSharedMemoryBuffer(size);
1678 } 1670 }
1679 1671
1680 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1681 notify_webkit_of_modal_loop_ = false;
1682 }
1683
1684 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { 1672 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
1685 base::ObserverListBase<RenderThreadObserver>::Iterator it(&observers_); 1673 base::ObserverListBase<RenderThreadObserver>::Iterator it(&observers_);
1686 RenderThreadObserver* observer; 1674 RenderThreadObserver* observer;
1687 while ((observer = it.GetNext()) != NULL) { 1675 while ((observer = it.GetNext()) != NULL) {
1688 if (observer->OnControlMessageReceived(msg)) 1676 if (observer->OnControlMessageReceived(msg))
1689 return true; 1677 return true;
1690 } 1678 }
1691 1679
1692 // Some messages are handled by delegates. 1680 // Some messages are handled by delegates.
1693 if (appcache_dispatcher_->OnMessageReceived(msg) || 1681 if (appcache_dispatcher_->OnMessageReceived(msg) ||
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 } 2093 }
2106 2094
2107 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2095 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2108 size_t erased = 2096 size_t erased =
2109 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2097 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2110 routing_id_); 2098 routing_id_);
2111 DCHECK_EQ(1u, erased); 2099 DCHECK_EQ(1u, erased);
2112 } 2100 }
2113 2101
2114 } // namespace content 2102 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.h ('K') | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698