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/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "content/browser/renderer_host/input/input_router_config_helper.h" | 40 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
41 #include "content/browser/renderer_host/input/input_router_impl.h" | 41 #include "content/browser/renderer_host/input/input_router_impl.h" |
42 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 42 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
43 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 43 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
44 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 44 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
45 #include "content/browser/renderer_host/input/timeout_monitor.h" | 45 #include "content/browser/renderer_host/input/timeout_monitor.h" |
46 #include "content/browser/renderer_host/input/touch_emulator.h" | 46 #include "content/browser/renderer_host/input/touch_emulator.h" |
47 #include "content/browser/renderer_host/render_process_host_impl.h" | 47 #include "content/browser/renderer_host/render_process_host_impl.h" |
48 #include "content/browser/renderer_host/render_view_host_impl.h" | 48 #include "content/browser/renderer_host/render_view_host_impl.h" |
49 #include "content/browser/renderer_host/render_widget_helper.h" | 49 #include "content/browser/renderer_host/render_widget_helper.h" |
50 #include "content/browser/renderer_host/render_widget_host_delegate.h" | |
51 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 50 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
52 #include "content/browser/renderer_host/render_widget_host_owner_delegate.h" | 51 #include "content/browser/renderer_host/render_widget_host_owner_delegate.h" |
53 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 52 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
54 #include "content/common/content_constants_internal.h" | 53 #include "content/common/content_constants_internal.h" |
55 #include "content/common/content_switches_internal.h" | 54 #include "content/common/content_switches_internal.h" |
56 #include "content/common/cursors/webcursor.h" | 55 #include "content/common/cursors/webcursor.h" |
57 #include "content/common/frame_messages.h" | 56 #include "content/common/frame_messages.h" |
58 #include "content/common/host_shared_bitmap_manager.h" | 57 #include "content/common/host_shared_bitmap_manager.h" |
59 #include "content/common/input_messages.h" | 58 #include "content/common/input_messages.h" |
60 #include "content/common/resize_params.h" | 59 #include "content/common/resize_params.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 allow_privileged_mouse_lock_(false), | 204 allow_privileged_mouse_lock_(false), |
206 has_touch_handler_(false), | 205 has_touch_handler_(false), |
207 is_in_touchpad_gesture_scroll_(false), | 206 is_in_touchpad_gesture_scroll_(false), |
208 is_in_touchscreen_gesture_scroll_(false), | 207 is_in_touchscreen_gesture_scroll_(false), |
209 received_paint_after_load_(false), | 208 received_paint_after_load_(false), |
210 next_browser_snapshot_id_(1), | 209 next_browser_snapshot_id_(1), |
211 owned_by_render_frame_host_(false), | 210 owned_by_render_frame_host_(false), |
212 is_focused_(false), | 211 is_focused_(false), |
213 hung_renderer_delay_( | 212 hung_renderer_delay_( |
214 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 213 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
| 214 hang_type_(RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN), |
215 new_content_rendering_delay_( | 215 new_content_rendering_delay_( |
216 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), | 216 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), |
217 weak_factory_(this) { | 217 weak_factory_(this) { |
218 CHECK(delegate_); | 218 CHECK(delegate_); |
219 CHECK_NE(MSG_ROUTING_NONE, routing_id_); | 219 CHECK_NE(MSG_ROUTING_NONE, routing_id_); |
220 | 220 |
221 #if defined(OS_WIN) | 221 #if defined(OS_WIN) |
222 // Update the display color profile cache so that it is likely to be up to | 222 // Update the display color profile cache so that it is likely to be up to |
223 // date when the renderer process requests the color profile. | 223 // date when the renderer process requests the color profile. |
224 if (gfx::ColorSpace::CachedProfilesNeedUpdate()) { | 224 if (gfx::ColorSpace::CachedProfilesNeedUpdate()) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 if (!is_hidden_) | 531 if (!is_hidden_) |
532 return; | 532 return; |
533 | 533 |
534 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::WasShown"); | 534 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::WasShown"); |
535 is_hidden_ = false; | 535 is_hidden_ = false; |
536 | 536 |
537 SendScreenRects(); | 537 SendScreenRects(); |
538 | 538 |
539 // When hidden, timeout monitoring for input events is disabled. Restore it | 539 // When hidden, timeout monitoring for input events is disabled. Restore it |
540 // now to ensure consistent hang detection. | 540 // now to ensure consistent hang detection. |
541 if (in_flight_event_count_) | 541 if (in_flight_event_count_) { |
542 RestartHangMonitorTimeout(); | 542 RestartHangMonitorTimeout(); |
| 543 hang_type_ = |
| 544 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS; |
| 545 } |
543 | 546 |
544 // Always repaint on restore. | 547 // Always repaint on restore. |
545 bool needs_repainting = true; | 548 bool needs_repainting = true; |
546 needs_repainting_on_restore_ = false; | 549 needs_repainting_on_restore_ = false; |
547 Send(new ViewMsg_WasShown(routing_id_, needs_repainting, latency_info)); | 550 Send(new ViewMsg_WasShown(routing_id_, needs_repainting, latency_info)); |
548 | 551 |
549 process_->WidgetRestored(); | 552 process_->WidgetRestored(); |
550 | 553 |
551 bool is_visible = true; | 554 bool is_visible = true; |
552 NotificationService::current()->Notify( | 555 NotificationService::current()->Notify( |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 873 |
871 // Send out a request to the renderer to paint the view if required. | 874 // Send out a request to the renderer to paint the view if required. |
872 repaint_start_time_ = TimeTicks::Now(); | 875 repaint_start_time_ = TimeTicks::Now(); |
873 repaint_ack_pending_ = true; | 876 repaint_ack_pending_ = true; |
874 TRACE_EVENT_ASYNC_BEGIN0( | 877 TRACE_EVENT_ASYNC_BEGIN0( |
875 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 878 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
876 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 879 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
877 return true; | 880 return true; |
878 } | 881 } |
879 | 882 |
880 void RenderWidgetHostImpl::StartHangMonitorTimeout(base::TimeDelta delay) { | 883 void RenderWidgetHostImpl::StartHangMonitorTimeout( |
881 if (hang_monitor_timeout_) | 884 base::TimeDelta delay, |
882 hang_monitor_timeout_->Start(delay); | 885 RenderWidgetHostDelegate::RendererUnresponsiveType type) { |
| 886 if (!hang_monitor_timeout_) |
| 887 return; |
| 888 hang_monitor_timeout_->Start(delay); |
| 889 hang_type_ = type; |
883 } | 890 } |
884 | 891 |
885 void RenderWidgetHostImpl::RestartHangMonitorTimeout() { | 892 void RenderWidgetHostImpl::RestartHangMonitorTimeout() { |
886 if (hang_monitor_timeout_) | 893 if (hang_monitor_timeout_) |
887 hang_monitor_timeout_->Restart(hung_renderer_delay_); | 894 hang_monitor_timeout_->Restart(hung_renderer_delay_); |
888 } | 895 } |
889 | 896 |
890 void RenderWidgetHostImpl::DisableHangMonitorForTesting() { | 897 void RenderWidgetHostImpl::DisableHangMonitorForTesting() { |
891 StopHangMonitorTimeout(); | 898 StopHangMonitorTimeout(); |
892 hang_monitor_timeout_.reset(); | 899 hang_monitor_timeout_.reset(); |
893 } | 900 } |
894 | 901 |
895 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 902 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
896 if (hang_monitor_timeout_) | 903 if (hang_monitor_timeout_) { |
897 hang_monitor_timeout_->Stop(); | 904 hang_monitor_timeout_->Stop(); |
| 905 hang_type_ = RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN; |
| 906 } |
898 RendererIsResponsive(); | 907 RendererIsResponsive(); |
899 } | 908 } |
900 | 909 |
901 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { | 910 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { |
902 // It is possible for a compositor frame to arrive before the browser is | 911 // It is possible for a compositor frame to arrive before the browser is |
903 // notified about the page being committed, in which case no timer is | 912 // notified about the page being committed, in which case no timer is |
904 // necessary. | 913 // necessary. |
905 if (received_paint_after_load_) { | 914 if (received_paint_after_load_) { |
906 received_paint_after_load_ = false; | 915 received_paint_after_load_ = false; |
907 return; | 916 return; |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 } | 1447 } |
1439 } | 1448 } |
1440 | 1449 |
1441 void RenderWidgetHostImpl::RendererIsUnresponsive() { | 1450 void RenderWidgetHostImpl::RendererIsUnresponsive() { |
1442 NotificationService::current()->Notify( | 1451 NotificationService::current()->Notify( |
1443 NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 1452 NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
1444 Source<RenderWidgetHost>(this), | 1453 Source<RenderWidgetHost>(this), |
1445 NotificationService::NoDetails()); | 1454 NotificationService::NoDetails()); |
1446 is_unresponsive_ = true; | 1455 is_unresponsive_ = true; |
1447 if (delegate_) | 1456 if (delegate_) |
1448 delegate_->RendererUnresponsive(this); | 1457 delegate_->RendererUnresponsive(this, hang_type_); |
| 1458 hang_type_ = RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN; |
1449 } | 1459 } |
1450 | 1460 |
1451 void RenderWidgetHostImpl::RendererIsResponsive() { | 1461 void RenderWidgetHostImpl::RendererIsResponsive() { |
1452 if (is_unresponsive_) { | 1462 if (is_unresponsive_) { |
1453 is_unresponsive_ = false; | 1463 is_unresponsive_ = false; |
1454 if (delegate_) | 1464 if (delegate_) |
1455 delegate_->RendererResponsive(this); | 1465 delegate_->RendererResponsive(this); |
1456 } | 1466 } |
1457 } | 1467 } |
1458 | 1468 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 event.type == WebInputEvent::RawKeyDown)) { | 1836 event.type == WebInputEvent::RawKeyDown)) { |
1827 delegate_->OnUserInteraction(this, event.type); | 1837 delegate_->OnUserInteraction(this, event.type); |
1828 } | 1838 } |
1829 | 1839 |
1830 return view_ ? view_->FilterInputEvent(event) | 1840 return view_ ? view_->FilterInputEvent(event) |
1831 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1841 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
1832 } | 1842 } |
1833 | 1843 |
1834 void RenderWidgetHostImpl::IncrementInFlightEventCount() { | 1844 void RenderWidgetHostImpl::IncrementInFlightEventCount() { |
1835 increment_in_flight_event_count(); | 1845 increment_in_flight_event_count(); |
1836 if (!is_hidden_) | 1846 if (!is_hidden_) { |
1837 StartHangMonitorTimeout(hung_renderer_delay_); | 1847 StartHangMonitorTimeout( |
| 1848 hung_renderer_delay_, |
| 1849 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS); |
| 1850 } |
1838 } | 1851 } |
1839 | 1852 |
1840 void RenderWidgetHostImpl::DecrementInFlightEventCount() { | 1853 void RenderWidgetHostImpl::DecrementInFlightEventCount() { |
1841 if (decrement_in_flight_event_count() <= 0) { | 1854 if (decrement_in_flight_event_count() <= 0) { |
1842 // Cancel pending hung renderer checks since the renderer is responsive. | 1855 // Cancel pending hung renderer checks since the renderer is responsive. |
1843 StopHangMonitorTimeout(); | 1856 StopHangMonitorTimeout(); |
1844 } else { | 1857 } else { |
1845 // The renderer is responsive, but there are in-flight events to wait for. | 1858 // The renderer is responsive, but there are in-flight events to wait for. |
1846 if (!is_hidden_) | 1859 if (!is_hidden_) { |
1847 RestartHangMonitorTimeout(); | 1860 RestartHangMonitorTimeout(); |
| 1861 hang_type_ = |
| 1862 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS; |
| 1863 } |
1848 } | 1864 } |
1849 } | 1865 } |
1850 | 1866 |
1851 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { | 1867 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { |
1852 has_touch_handler_ = has_handlers; | 1868 has_touch_handler_ = has_handlers; |
1853 } | 1869 } |
1854 | 1870 |
1855 void RenderWidgetHostImpl::DidFlush() { | 1871 void RenderWidgetHostImpl::DidFlush() { |
1856 if (synthetic_gesture_controller_) | 1872 if (synthetic_gesture_controller_) |
1857 synthetic_gesture_controller_->OnDidFlushInput(); | 1873 synthetic_gesture_controller_->OnDidFlushInput(); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2170 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2155 } | 2171 } |
2156 | 2172 |
2157 BrowserAccessibilityManager* | 2173 BrowserAccessibilityManager* |
2158 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2174 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2159 return delegate_ ? | 2175 return delegate_ ? |
2160 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2176 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2161 } | 2177 } |
2162 | 2178 |
2163 } // namespace content | 2179 } // namespace content |
OLD | NEW |