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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // On Mac and Android, the select popups are rendered by the browser. | 482 // On Mac and Android, the select popups are rendered by the browser. |
483 blink::WebView::setUseExternalPopupMenus(true); | 483 blink::WebView::setUseExternalPopupMenus(true); |
484 #endif | 484 #endif |
485 | 485 |
486 lazy_tls.Pointer()->Set(this); | 486 lazy_tls.Pointer()->Set(this); |
487 | 487 |
488 // Register this object as the main thread. | 488 // Register this object as the main thread. |
489 ChildProcess::current()->set_main_thread(this); | 489 ChildProcess::current()->set_main_thread(this); |
490 | 490 |
491 // In single process the single process is all there is. | 491 // In single process the single process is all there is. |
492 suspend_webkit_shared_timer_ = true; | |
493 notify_webkit_of_modal_loop_ = true; | 492 notify_webkit_of_modal_loop_ = true; |
494 webkit_shared_timer_suspended_ = false; | 493 webkit_shared_timer_suspended_ = false; |
495 widget_count_ = 0; | 494 widget_count_ = 0; |
496 hidden_widget_count_ = 0; | 495 hidden_widget_count_ = 0; |
497 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 496 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
498 idle_notifications_to_skip_ = 0; | 497 idle_notifications_to_skip_ = 0; |
499 layout_test_mode_ = false; | 498 layout_test_mode_ = false; |
500 | 499 |
501 appcache_dispatcher_.reset( | 500 appcache_dispatcher_.reset( |
502 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); | 501 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 // is processing this request. This creates an opportunity for re-entrancy | 823 // is processing this request. This creates an opportunity for re-entrancy |
825 // into WebKit, so we need to take care to disable callbacks, timers, and | 824 // into WebKit, so we need to take care to disable callbacks, timers, and |
826 // pending network loads that could trigger such callbacks. | 825 // pending network loads that could trigger such callbacks. |
827 bool pumping_events = false; | 826 bool pumping_events = false; |
828 if (msg->is_sync()) { | 827 if (msg->is_sync()) { |
829 if (msg->is_caller_pumping_messages()) { | 828 if (msg->is_caller_pumping_messages()) { |
830 pumping_events = true; | 829 pumping_events = true; |
831 } | 830 } |
832 } | 831 } |
833 | 832 |
834 bool suspend_webkit_shared_timer = true; // default value | |
835 std::swap(suspend_webkit_shared_timer, suspend_webkit_shared_timer_); | |
836 | |
837 bool notify_webkit_of_modal_loop = true; // default value | 833 bool notify_webkit_of_modal_loop = true; // default value |
838 std::swap(notify_webkit_of_modal_loop, notify_webkit_of_modal_loop_); | 834 std::swap(notify_webkit_of_modal_loop, notify_webkit_of_modal_loop_); |
839 | 835 |
840 #if defined(ENABLE_PLUGINS) | 836 #if defined(ENABLE_PLUGINS) |
841 int render_view_id = MSG_ROUTING_NONE; | 837 int render_view_id = MSG_ROUTING_NONE; |
842 #endif | 838 #endif |
843 | 839 |
844 if (pumping_events) { | 840 if (pumping_events) { |
845 if (suspend_webkit_shared_timer) { | 841 // TODO(alexclarke): Remove the shared timer. |
846 // TODO(alexclarke): Remove the shared timer. | 842 blink_platform_impl_->SuspendSharedTimer(); |
847 blink_platform_impl_->SuspendSharedTimer(); | 843 renderer_scheduler_->SuspendTimerQueue(); |
848 renderer_scheduler_->SuspendTimerQueue(); | |
849 } | |
850 | 844 |
851 if (notify_webkit_of_modal_loop) | 845 if (notify_webkit_of_modal_loop) |
852 WebView::willEnterModalLoop(); | 846 WebView::willEnterModalLoop(); |
853 #if defined(ENABLE_PLUGINS) | 847 #if defined(ENABLE_PLUGINS) |
854 RenderViewImpl* render_view = | 848 RenderViewImpl* render_view = |
855 RenderViewImpl::FromRoutingID(msg->routing_id()); | 849 RenderViewImpl::FromRoutingID(msg->routing_id()); |
856 if (render_view) { | 850 if (render_view) { |
857 render_view_id = msg->routing_id(); | 851 render_view_id = msg->routing_id(); |
858 PluginChannelHost::Broadcast( | 852 PluginChannelHost::Broadcast( |
859 new PluginMsg_SignalModalDialogEvent(render_view_id)); | 853 new PluginMsg_SignalModalDialogEvent(render_view_id)); |
860 } | 854 } |
861 #endif | 855 #endif |
862 } | 856 } |
863 | 857 |
864 bool rv = ChildThreadImpl::Send(msg); | 858 bool rv = ChildThreadImpl::Send(msg); |
865 | 859 |
866 if (pumping_events) { | 860 if (pumping_events) { |
867 #if defined(ENABLE_PLUGINS) | 861 #if defined(ENABLE_PLUGINS) |
868 if (render_view_id != MSG_ROUTING_NONE) { | 862 if (render_view_id != MSG_ROUTING_NONE) { |
869 PluginChannelHost::Broadcast( | 863 PluginChannelHost::Broadcast( |
870 new PluginMsg_ResetModalDialogEvent(render_view_id)); | 864 new PluginMsg_ResetModalDialogEvent(render_view_id)); |
871 } | 865 } |
872 #endif | 866 #endif |
873 | 867 |
874 if (notify_webkit_of_modal_loop) | 868 if (notify_webkit_of_modal_loop) |
875 WebView::didExitModalLoop(); | 869 WebView::didExitModalLoop(); |
876 | 870 |
877 if (suspend_webkit_shared_timer) { | 871 // TODO(alexclarke): Remove the shared timer. |
878 // TODO(alexclarke): Remove the shared timer. | 872 blink_platform_impl_->ResumeSharedTimer(); |
879 blink_platform_impl_->ResumeSharedTimer(); | 873 renderer_scheduler_->ResumeTimerQueue(); |
880 renderer_scheduler_->ResumeTimerQueue(); | |
881 } | |
882 } | 874 } |
883 | 875 |
884 return rv; | 876 return rv; |
885 } | 877 } |
886 | 878 |
887 scoped_refptr<base::SingleThreadTaskRunner> RenderThreadImpl::GetTaskRunner() { | 879 scoped_refptr<base::SingleThreadTaskRunner> RenderThreadImpl::GetTaskRunner() { |
888 return GetRendererScheduler()->DefaultTaskRunner(); | 880 return GetRendererScheduler()->DefaultTaskRunner(); |
889 } | 881 } |
890 | 882 |
891 IPC::SyncChannel* RenderThreadImpl::GetChannel() { | 883 IPC::SyncChannel* RenderThreadImpl::GetChannel() { |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 init_params, | 1498 init_params, |
1507 route_id, | 1499 route_id, |
1508 &result); | 1500 &result); |
1509 | 1501 |
1510 // Allow calling this from the compositor thread. | 1502 // Allow calling this from the compositor thread. |
1511 thread_safe_sender()->Send(message); | 1503 thread_safe_sender()->Send(message); |
1512 | 1504 |
1513 return result; | 1505 return result; |
1514 } | 1506 } |
1515 | 1507 |
1516 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | |
1517 suspend_webkit_shared_timer_ = false; | |
1518 } | |
1519 | |
1520 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1508 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
1521 notify_webkit_of_modal_loop_ = false; | 1509 notify_webkit_of_modal_loop_ = false; |
1522 } | 1510 } |
1523 | 1511 |
1524 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 1512 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
1525 ObserverListBase<RenderProcessObserver>::Iterator it(&observers_); | 1513 ObserverListBase<RenderProcessObserver>::Iterator it(&observers_); |
1526 RenderProcessObserver* observer; | 1514 RenderProcessObserver* observer; |
1527 while ((observer = it.GetNext()) != NULL) { | 1515 while ((observer = it.GetNext()) != NULL) { |
1528 if (observer->OnControlMessageReceived(msg)) | 1516 if (observer->OnControlMessageReceived(msg)) |
1529 return true; | 1517 return true; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone( | 1706 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone( |
1719 icu::UnicodeString::fromUTF8(zone_id)); | 1707 icu::UnicodeString::fromUTF8(zone_id)); |
1720 icu::TimeZone::adoptDefault(new_zone); | 1708 icu::TimeZone::adoptDefault(new_zone); |
1721 VLOG(1) << "ICU default timezone is set to " << zone_id; | 1709 VLOG(1) << "ICU default timezone is set to " << zone_id; |
1722 } | 1710 } |
1723 NotifyTimezoneChange(); | 1711 NotifyTimezoneChange(); |
1724 } | 1712 } |
1725 | 1713 |
1726 #if defined(OS_ANDROID) | 1714 #if defined(OS_ANDROID) |
1727 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { | 1715 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { |
1728 if (suspend_webkit_shared_timer_) { | 1716 EnsureWebKitInitialized(); |
1729 EnsureWebKitInitialized(); | 1717 // TODO(alexclarke): Remove the shared timer. |
1730 // TODO(alexclarke): Remove the shared timer. | 1718 if (suspend) { |
1731 if (suspend) { | 1719 blink_platform_impl_->SuspendSharedTimer(); |
1732 blink_platform_impl_->SuspendSharedTimer(); | 1720 renderer_scheduler_->SuspendTimerQueue(); |
1733 renderer_scheduler_->SuspendTimerQueue(); | 1721 } else { |
1734 } else { | 1722 blink_platform_impl_->ResumeSharedTimer(); |
1735 blink_platform_impl_->ResumeSharedTimer(); | 1723 renderer_scheduler_->ResumeTimerQueue(); |
1736 renderer_scheduler_->ResumeTimerQueue(); | |
1737 } | |
1738 webkit_shared_timer_suspended_ = suspend; | |
1739 } | 1724 } |
| 1725 webkit_shared_timer_suspended_ = suspend; |
1740 } | 1726 } |
1741 #endif | 1727 #endif |
1742 | 1728 |
1743 #if defined(OS_MACOSX) | 1729 #if defined(OS_MACOSX) |
1744 void RenderThreadImpl::OnUpdateScrollbarTheme( | 1730 void RenderThreadImpl::OnUpdateScrollbarTheme( |
1745 float initial_button_delay, | 1731 float initial_button_delay, |
1746 float autoscroll_button_delay, | 1732 float autoscroll_button_delay, |
1747 bool jump_on_track_click, | 1733 bool jump_on_track_click, |
1748 blink::ScrollerStyle preferred_scroller_style, | 1734 blink::ScrollerStyle preferred_scroller_style, |
1749 bool redraw) { | 1735 bool redraw) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 } | 1887 } |
1902 | 1888 |
1903 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 1889 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
1904 size_t erased = | 1890 size_t erased = |
1905 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 1891 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
1906 routing_id_); | 1892 routing_id_); |
1907 DCHECK_EQ(1u, erased); | 1893 DCHECK_EQ(1u, erased); |
1908 } | 1894 } |
1909 | 1895 |
1910 } // namespace content | 1896 } // namespace content |
OLD | NEW |