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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 has_touch_handler_(false), | 281 has_touch_handler_(false), |
282 is_in_touchpad_gesture_scroll_(false), | 282 is_in_touchpad_gesture_scroll_(false), |
283 is_in_touchscreen_gesture_scroll_(false), | 283 is_in_touchscreen_gesture_scroll_(false), |
284 received_paint_after_load_(false), | 284 received_paint_after_load_(false), |
285 latency_tracker_(), | 285 latency_tracker_(), |
286 next_browser_snapshot_id_(1), | 286 next_browser_snapshot_id_(1), |
287 owned_by_render_frame_host_(false), | 287 owned_by_render_frame_host_(false), |
288 is_focused_(false), | 288 is_focused_(false), |
289 hung_renderer_delay_( | 289 hung_renderer_delay_( |
290 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 290 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
291 hang_monitor_reason_( | |
292 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN), | |
293 hang_monitor_event_type_(blink::WebInputEvent::Undefined), | 291 hang_monitor_event_type_(blink::WebInputEvent::Undefined), |
294 last_event_type_(blink::WebInputEvent::Undefined), | 292 last_event_type_(blink::WebInputEvent::Undefined), |
295 new_content_rendering_delay_( | 293 new_content_rendering_delay_( |
296 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), | 294 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), |
297 current_content_source_id_(0), | 295 current_content_source_id_(0), |
298 weak_factory_(this) { | 296 weak_factory_(this) { |
299 CHECK(delegate_); | 297 CHECK(delegate_); |
300 CHECK_NE(MSG_ROUTING_NONE, routing_id_); | 298 CHECK_NE(MSG_ROUTING_NONE, routing_id_); |
301 latency_tracker_.SetDelegate(delegate_); | 299 latency_tracker_.SetDelegate(delegate_); |
302 | 300 |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 repaint_start_time_ = TimeTicks::Now(); | 939 repaint_start_time_ = TimeTicks::Now(); |
942 repaint_ack_pending_ = true; | 940 repaint_ack_pending_ = true; |
943 TRACE_EVENT_ASYNC_BEGIN0( | 941 TRACE_EVENT_ASYNC_BEGIN0( |
944 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 942 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
945 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 943 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
946 return true; | 944 return true; |
947 } | 945 } |
948 | 946 |
949 void RenderWidgetHostImpl::StartHangMonitorTimeout( | 947 void RenderWidgetHostImpl::StartHangMonitorTimeout( |
950 base::TimeDelta delay, | 948 base::TimeDelta delay, |
951 blink::WebInputEvent::Type event_type, | 949 blink::WebInputEvent::Type event_type) { |
952 RendererUnresponsiveType hang_monitor_reason) { | |
953 if (!hang_monitor_timeout_) | 950 if (!hang_monitor_timeout_) |
954 return; | 951 return; |
955 if (!hang_monitor_timeout_->IsRunning()) | 952 if (!hang_monitor_timeout_->IsRunning()) |
956 hang_monitor_event_type_ = event_type; | 953 hang_monitor_event_type_ = event_type; |
957 last_event_type_ = event_type; | 954 last_event_type_ = event_type; |
958 hang_monitor_timeout_->Start(delay); | 955 hang_monitor_timeout_->Start(delay); |
959 hang_monitor_reason_ = hang_monitor_reason; | |
960 } | 956 } |
961 | 957 |
962 void RenderWidgetHostImpl::RestartHangMonitorTimeoutIfNecessary() { | 958 void RenderWidgetHostImpl::RestartHangMonitorTimeoutIfNecessary() { |
963 if (!hang_monitor_timeout_) | 959 if (!hang_monitor_timeout_) |
964 return; | 960 return; |
965 if (in_flight_event_count_ > 0 && !is_hidden_) { | 961 if (in_flight_event_count_ > 0 && !is_hidden_) { |
clamy
2017/03/09 13:40:40
nit: no longer need for braces.
Avi (use Gerrit)
2017/03/09 15:31:21
Done.
| |
966 if (hang_monitor_reason_ == | |
967 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN) { | |
968 hang_monitor_reason_ = | |
969 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS; | |
970 } | |
971 hang_monitor_timeout_->Restart(hung_renderer_delay_); | 962 hang_monitor_timeout_->Restart(hung_renderer_delay_); |
972 } | 963 } |
973 } | 964 } |
974 | 965 |
975 void RenderWidgetHostImpl::DisableHangMonitorForTesting() { | 966 void RenderWidgetHostImpl::DisableHangMonitorForTesting() { |
976 StopHangMonitorTimeout(); | 967 StopHangMonitorTimeout(); |
977 hang_monitor_timeout_.reset(); | 968 hang_monitor_timeout_.reset(); |
978 } | 969 } |
979 | 970 |
980 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 971 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
981 if (hang_monitor_timeout_) { | 972 if (hang_monitor_timeout_) { |
clamy
2017/03/09 13:40:40
Same here.
Avi (use Gerrit)
2017/03/09 15:31:21
Done.
| |
982 hang_monitor_timeout_->Stop(); | 973 hang_monitor_timeout_->Stop(); |
983 hang_monitor_reason_ = | |
984 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN; | |
985 } | 974 } |
986 RendererIsResponsive(); | 975 RendererIsResponsive(); |
987 } | 976 } |
988 | 977 |
989 void RenderWidgetHostImpl::StartNewContentRenderingTimeout( | 978 void RenderWidgetHostImpl::StartNewContentRenderingTimeout( |
990 uint32_t next_source_id) { | 979 uint32_t next_source_id) { |
991 current_content_source_id_ = next_source_id; | 980 current_content_source_id_ = next_source_id; |
992 // It is possible for a compositor frame to arrive before the browser is | 981 // It is possible for a compositor frame to arrive before the browser is |
993 // notified about the page being committed, in which case no timer is | 982 // notified about the page being committed, in which case no timer is |
994 // necessary. | 983 // necessary. |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1697 delete this; | 1686 delete this; |
1698 } | 1687 } |
1699 } | 1688 } |
1700 | 1689 |
1701 void RenderWidgetHostImpl::RendererIsUnresponsive() { | 1690 void RenderWidgetHostImpl::RendererIsUnresponsive() { |
1702 NotificationService::current()->Notify( | 1691 NotificationService::current()->Notify( |
1703 NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 1692 NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
1704 Source<RenderWidgetHost>(this), | 1693 Source<RenderWidgetHost>(this), |
1705 NotificationService::NoDetails()); | 1694 NotificationService::NoDetails()); |
1706 is_unresponsive_ = true; | 1695 is_unresponsive_ = true; |
1707 RendererUnresponsiveType reason = hang_monitor_reason_; | |
1708 hang_monitor_reason_ = | |
1709 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNKNOWN; | |
1710 | 1696 |
1711 if (delegate_) | 1697 if (delegate_) |
1712 delegate_->RendererUnresponsive(this, reason); | 1698 delegate_->RendererUnresponsive(this); |
1713 | 1699 |
1714 // Do not add code after this since the Delegate may delete this | 1700 // Do not add code after this since the Delegate may delete this |
1715 // RenderWidgetHostImpl in RendererUnresponsive. | 1701 // RenderWidgetHostImpl in RendererUnresponsive. |
1716 } | 1702 } |
1717 | 1703 |
1718 void RenderWidgetHostImpl::RendererIsResponsive() { | 1704 void RenderWidgetHostImpl::RendererIsResponsive() { |
1719 if (is_unresponsive_) { | 1705 if (is_unresponsive_) { |
1720 is_unresponsive_ = false; | 1706 is_unresponsive_ = false; |
1721 if (delegate_) | 1707 if (delegate_) |
1722 delegate_->RendererResponsive(this); | 1708 delegate_->RendererResponsive(this); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2105 } | 2091 } |
2106 } | 2092 } |
2107 | 2093 |
2108 return view_ ? view_->FilterInputEvent(event) | 2094 return view_ ? view_->FilterInputEvent(event) |
2109 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 2095 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
2110 } | 2096 } |
2111 | 2097 |
2112 void RenderWidgetHostImpl::IncrementInFlightEventCount( | 2098 void RenderWidgetHostImpl::IncrementInFlightEventCount( |
2113 blink::WebInputEvent::Type event_type) { | 2099 blink::WebInputEvent::Type event_type) { |
2114 ++in_flight_event_count_; | 2100 ++in_flight_event_count_; |
2115 if (!is_hidden_) { | 2101 if (!is_hidden_) { |
clamy
2017/03/09 13:40:41
Same here.
Avi (use Gerrit)
2017/03/09 15:31:21
Done.
| |
2116 StartHangMonitorTimeout( | 2102 StartHangMonitorTimeout(hung_renderer_delay_, event_type); |
2117 hung_renderer_delay_, event_type, | |
2118 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_IN_FLIGHT_EVENTS); | |
2119 } | 2103 } |
2120 } | 2104 } |
2121 | 2105 |
2122 void RenderWidgetHostImpl::DecrementInFlightEventCount( | 2106 void RenderWidgetHostImpl::DecrementInFlightEventCount( |
2123 InputEventAckSource ack_source) { | 2107 InputEventAckSource ack_source) { |
2124 --in_flight_event_count_; | 2108 --in_flight_event_count_; |
2125 if (in_flight_event_count_ <= 0) { | 2109 if (in_flight_event_count_ <= 0) { |
2126 // Cancel pending hung renderer checks since the renderer is responsive. | 2110 // Cancel pending hung renderer checks since the renderer is responsive. |
2127 StopHangMonitorTimeout(); | 2111 StopHangMonitorTimeout(); |
2128 } else { | 2112 } else { |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2515 // different from the receiver's. | 2499 // different from the receiver's. |
2516 file_system_file.url = | 2500 file_system_file.url = |
2517 GURL(storage::GetIsolatedFileSystemRootURIString( | 2501 GURL(storage::GetIsolatedFileSystemRootURIString( |
2518 file_system_url.origin(), filesystem_id, std::string()) | 2502 file_system_url.origin(), filesystem_id, std::string()) |
2519 .append(register_name)); | 2503 .append(register_name)); |
2520 file_system_file.filesystem_id = filesystem_id; | 2504 file_system_file.filesystem_id = filesystem_id; |
2521 } | 2505 } |
2522 } | 2506 } |
2523 | 2507 |
2524 } // namespace content | 2508 } // namespace content |
OLD | NEW |