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