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_monitor_reason_( |
| 215 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN), |
215 new_content_rendering_delay_( | 216 new_content_rendering_delay_( |
216 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), | 217 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), |
217 weak_factory_(this) { | 218 weak_factory_(this) { |
218 CHECK(delegate_); | 219 CHECK(delegate_); |
219 CHECK_NE(MSG_ROUTING_NONE, routing_id_); | 220 CHECK_NE(MSG_ROUTING_NONE, routing_id_); |
220 | 221 |
221 #if defined(OS_WIN) | 222 #if defined(OS_WIN) |
222 // Update the display color profile cache so that it is likely to be up to | 223 // 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. | 224 // date when the renderer process requests the color profile. |
224 if (gfx::ColorSpace::CachedProfilesNeedUpdate()) { | 225 if (gfx::ColorSpace::CachedProfilesNeedUpdate()) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 if (!is_hidden_) | 532 if (!is_hidden_) |
532 return; | 533 return; |
533 | 534 |
534 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::WasShown"); | 535 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::WasShown"); |
535 is_hidden_ = false; | 536 is_hidden_ = false; |
536 | 537 |
537 SendScreenRects(); | 538 SendScreenRects(); |
538 | 539 |
539 // When hidden, timeout monitoring for input events is disabled. Restore it | 540 // When hidden, timeout monitoring for input events is disabled. Restore it |
540 // now to ensure consistent hang detection. | 541 // now to ensure consistent hang detection. |
541 if (in_flight_event_count_) | 542 if (in_flight_event_count_) { |
542 RestartHangMonitorTimeout(); | 543 RestartHangMonitorTimeout(); |
| 544 hang_monitor_reason_ = |
| 545 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS; |
| 546 } |
543 | 547 |
544 // Always repaint on restore. | 548 // Always repaint on restore. |
545 bool needs_repainting = true; | 549 bool needs_repainting = true; |
546 needs_repainting_on_restore_ = false; | 550 needs_repainting_on_restore_ = false; |
547 Send(new ViewMsg_WasShown(routing_id_, needs_repainting, latency_info)); | 551 Send(new ViewMsg_WasShown(routing_id_, needs_repainting, latency_info)); |
548 | 552 |
549 process_->WidgetRestored(); | 553 process_->WidgetRestored(); |
550 | 554 |
551 bool is_visible = true; | 555 bool is_visible = true; |
552 NotificationService::current()->Notify( | 556 NotificationService::current()->Notify( |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 874 |
871 // Send out a request to the renderer to paint the view if required. | 875 // Send out a request to the renderer to paint the view if required. |
872 repaint_start_time_ = TimeTicks::Now(); | 876 repaint_start_time_ = TimeTicks::Now(); |
873 repaint_ack_pending_ = true; | 877 repaint_ack_pending_ = true; |
874 TRACE_EVENT_ASYNC_BEGIN0( | 878 TRACE_EVENT_ASYNC_BEGIN0( |
875 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 879 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
876 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 880 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
877 return true; | 881 return true; |
878 } | 882 } |
879 | 883 |
880 void RenderWidgetHostImpl::StartHangMonitorTimeout(base::TimeDelta delay) { | 884 void RenderWidgetHostImpl::StartHangMonitorTimeout( |
881 if (hang_monitor_timeout_) | 885 base::TimeDelta delay, |
882 hang_monitor_timeout_->Start(delay); | 886 RenderWidgetHostDelegate::RendererUnresponsiveType hang_monitor_reason) { |
| 887 if (!hang_monitor_timeout_) |
| 888 return; |
| 889 hang_monitor_timeout_->Start(delay); |
| 890 hang_monitor_reason_ = hang_monitor_reason; |
883 } | 891 } |
884 | 892 |
885 void RenderWidgetHostImpl::RestartHangMonitorTimeout() { | 893 void RenderWidgetHostImpl::RestartHangMonitorTimeout() { |
886 if (hang_monitor_timeout_) | 894 if (hang_monitor_timeout_) |
887 hang_monitor_timeout_->Restart(hung_renderer_delay_); | 895 hang_monitor_timeout_->Restart(hung_renderer_delay_); |
888 } | 896 } |
889 | 897 |
890 void RenderWidgetHostImpl::DisableHangMonitorForTesting() { | 898 void RenderWidgetHostImpl::DisableHangMonitorForTesting() { |
891 StopHangMonitorTimeout(); | 899 StopHangMonitorTimeout(); |
892 hang_monitor_timeout_.reset(); | 900 hang_monitor_timeout_.reset(); |
893 } | 901 } |
894 | 902 |
895 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 903 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
896 if (hang_monitor_timeout_) | 904 if (hang_monitor_timeout_) { |
897 hang_monitor_timeout_->Stop(); | 905 hang_monitor_timeout_->Stop(); |
| 906 hang_monitor_reason_ = |
| 907 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN; |
| 908 } |
898 RendererIsResponsive(); | 909 RendererIsResponsive(); |
899 } | 910 } |
900 | 911 |
901 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { | 912 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { |
902 // It is possible for a compositor frame to arrive before the browser is | 913 // 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 | 914 // notified about the page being committed, in which case no timer is |
904 // necessary. | 915 // necessary. |
905 if (received_paint_after_load_) { | 916 if (received_paint_after_load_) { |
906 received_paint_after_load_ = false; | 917 received_paint_after_load_ = false; |
907 return; | 918 return; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 delete this; | 1448 delete this; |
1438 } | 1449 } |
1439 } | 1450 } |
1440 | 1451 |
1441 void RenderWidgetHostImpl::RendererIsUnresponsive() { | 1452 void RenderWidgetHostImpl::RendererIsUnresponsive() { |
1442 NotificationService::current()->Notify( | 1453 NotificationService::current()->Notify( |
1443 NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 1454 NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
1444 Source<RenderWidgetHost>(this), | 1455 Source<RenderWidgetHost>(this), |
1445 NotificationService::NoDetails()); | 1456 NotificationService::NoDetails()); |
1446 is_unresponsive_ = true; | 1457 is_unresponsive_ = true; |
| 1458 RenderWidgetHostDelegate::RendererUnresponsiveType reason = |
| 1459 hang_monitor_reason_; |
| 1460 hang_monitor_reason_ = |
| 1461 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_UNKNOWN; |
| 1462 |
1447 if (delegate_) | 1463 if (delegate_) |
1448 delegate_->RendererUnresponsive(this); | 1464 delegate_->RendererUnresponsive(this, reason); |
| 1465 |
| 1466 // Do not add code after this since the Delegate may delete this |
| 1467 // RenderWidgetHostImpl in RendererUnresponsive. |
1449 } | 1468 } |
1450 | 1469 |
1451 void RenderWidgetHostImpl::RendererIsResponsive() { | 1470 void RenderWidgetHostImpl::RendererIsResponsive() { |
1452 if (is_unresponsive_) { | 1471 if (is_unresponsive_) { |
1453 is_unresponsive_ = false; | 1472 is_unresponsive_ = false; |
1454 if (delegate_) | 1473 if (delegate_) |
1455 delegate_->RendererResponsive(this); | 1474 delegate_->RendererResponsive(this); |
1456 } | 1475 } |
1457 } | 1476 } |
1458 | 1477 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1827 event.type == WebInputEvent::RawKeyDown)) { | 1846 event.type == WebInputEvent::RawKeyDown)) { |
1828 delegate_->OnUserInteraction(this, event.type); | 1847 delegate_->OnUserInteraction(this, event.type); |
1829 } | 1848 } |
1830 | 1849 |
1831 return view_ ? view_->FilterInputEvent(event) | 1850 return view_ ? view_->FilterInputEvent(event) |
1832 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1851 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
1833 } | 1852 } |
1834 | 1853 |
1835 void RenderWidgetHostImpl::IncrementInFlightEventCount() { | 1854 void RenderWidgetHostImpl::IncrementInFlightEventCount() { |
1836 increment_in_flight_event_count(); | 1855 increment_in_flight_event_count(); |
1837 if (!is_hidden_) | 1856 if (!is_hidden_) { |
1838 StartHangMonitorTimeout(hung_renderer_delay_); | 1857 StartHangMonitorTimeout( |
| 1858 hung_renderer_delay_, |
| 1859 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS); |
| 1860 } |
1839 } | 1861 } |
1840 | 1862 |
1841 void RenderWidgetHostImpl::DecrementInFlightEventCount() { | 1863 void RenderWidgetHostImpl::DecrementInFlightEventCount() { |
1842 if (decrement_in_flight_event_count() <= 0) { | 1864 if (decrement_in_flight_event_count() <= 0) { |
1843 // Cancel pending hung renderer checks since the renderer is responsive. | 1865 // Cancel pending hung renderer checks since the renderer is responsive. |
1844 StopHangMonitorTimeout(); | 1866 StopHangMonitorTimeout(); |
1845 } else { | 1867 } else { |
1846 // The renderer is responsive, but there are in-flight events to wait for. | 1868 // The renderer is responsive, but there are in-flight events to wait for. |
1847 if (!is_hidden_) | 1869 if (!is_hidden_) { |
1848 RestartHangMonitorTimeout(); | 1870 RestartHangMonitorTimeout(); |
| 1871 hang_monitor_reason_ = |
| 1872 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS; |
| 1873 } |
1849 } | 1874 } |
1850 } | 1875 } |
1851 | 1876 |
1852 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { | 1877 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { |
1853 has_touch_handler_ = has_handlers; | 1878 has_touch_handler_ = has_handlers; |
1854 } | 1879 } |
1855 | 1880 |
1856 void RenderWidgetHostImpl::DidFlush() { | 1881 void RenderWidgetHostImpl::DidFlush() { |
1857 if (synthetic_gesture_controller_) | 1882 if (synthetic_gesture_controller_) |
1858 synthetic_gesture_controller_->OnDidFlushInput(); | 1883 synthetic_gesture_controller_->OnDidFlushInput(); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2180 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2156 } | 2181 } |
2157 | 2182 |
2158 BrowserAccessibilityManager* | 2183 BrowserAccessibilityManager* |
2159 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2184 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2160 return delegate_ ? | 2185 return delegate_ ? |
2161 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2186 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2162 } | 2187 } |
2163 | 2188 |
2164 } // namespace content | 2189 } // namespace content |
OLD | NEW |