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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 bool ignore_input_events) { | 960 bool ignore_input_events) { |
961 if (ignore_input_events) | 961 if (ignore_input_events) |
962 StopHangMonitorTimeout(); | 962 StopHangMonitorTimeout(); |
963 else | 963 else |
964 RestartHangMonitorTimeoutIfNecessary(); | 964 RestartHangMonitorTimeoutIfNecessary(); |
965 } | 965 } |
966 | 966 |
967 void RenderWidgetHostImpl::StartHangMonitorTimeout( | 967 void RenderWidgetHostImpl::StartHangMonitorTimeout( |
968 base::TimeDelta delay, | 968 base::TimeDelta delay, |
969 blink::WebInputEvent::Type event_type) { | 969 blink::WebInputEvent::Type event_type) { |
| 970 if (hang_start_time_.is_null()) |
| 971 hang_start_time_ = TimeTicks::Now(); |
970 if (!hang_monitor_timeout_) | 972 if (!hang_monitor_timeout_) |
971 return; | 973 return; |
972 if (!hang_monitor_timeout_->IsRunning()) | 974 if (!hang_monitor_timeout_->IsRunning()) |
973 hang_monitor_event_type_ = event_type; | 975 hang_monitor_event_type_ = event_type; |
974 last_event_type_ = event_type; | 976 last_event_type_ = event_type; |
975 hang_monitor_timeout_->Start(delay); | 977 hang_monitor_timeout_->Start(delay); |
976 } | 978 } |
977 | 979 |
978 void RenderWidgetHostImpl::RestartHangMonitorTimeoutIfNecessary() { | 980 void RenderWidgetHostImpl::RestartHangMonitorTimeoutIfNecessary() { |
979 if (!hang_monitor_timeout_) | 981 if (in_flight_event_count_ > 0 && !is_hidden_) { |
980 return; | 982 LogHangMonitorUnresponsive(); |
981 if (in_flight_event_count_ > 0 && !is_hidden_) | 983 hang_start_time_ = TimeTicks::Now(); |
982 hang_monitor_timeout_->Restart(hung_renderer_delay_); | 984 if (hang_monitor_timeout_) |
| 985 hang_monitor_timeout_->Restart(hung_renderer_delay_); |
| 986 } |
983 } | 987 } |
984 | 988 |
985 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 989 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
| 990 LogHangMonitorUnresponsive(); |
| 991 hang_start_time_ = TimeTicks(); |
986 if (hang_monitor_timeout_) | 992 if (hang_monitor_timeout_) |
987 hang_monitor_timeout_->Stop(); | 993 hang_monitor_timeout_->Stop(); |
988 RendererIsResponsive(); | 994 RendererIsResponsive(); |
989 } | 995 } |
990 | 996 |
| 997 void RenderWidgetHostImpl::LogHangMonitorUnresponsive() { |
| 998 if (!hang_start_time_.is_null()) { |
| 999 UMA_HISTOGRAM_TIMES("MPArch.RWH_HangMonitorUnresponsive", |
| 1000 TimeTicks::Now() - hang_start_time_); |
| 1001 } |
| 1002 } |
| 1003 |
991 void RenderWidgetHostImpl::StartNewContentRenderingTimeout( | 1004 void RenderWidgetHostImpl::StartNewContentRenderingTimeout( |
992 uint32_t next_source_id) { | 1005 uint32_t next_source_id) { |
993 current_content_source_id_ = next_source_id; | 1006 current_content_source_id_ = next_source_id; |
994 // It is possible for a compositor frame to arrive before the browser is | 1007 // It is possible for a compositor frame to arrive before the browser is |
995 // notified about the page being committed, in which case no timer is | 1008 // notified about the page being committed, in which case no timer is |
996 // necessary. | 1009 // necessary. |
997 if (last_received_content_source_id_ >= current_content_source_id_) | 1010 if (last_received_content_source_id_ >= current_content_source_id_) |
998 return; | 1011 return; |
999 | 1012 |
1000 new_content_rendering_timeout_->Start(new_content_rendering_delay_); | 1013 new_content_rendering_timeout_->Start(new_content_rendering_delay_); |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 | 2653 |
2641 // After navigation, if a frame belonging to the new page is received, stop | 2654 // After navigation, if a frame belonging to the new page is received, stop |
2642 // the timer that triggers clearing the graphics of the last page. | 2655 // the timer that triggers clearing the graphics of the last page. |
2643 if (last_received_content_source_id_ >= current_content_source_id_ && | 2656 if (last_received_content_source_id_ >= current_content_source_id_ && |
2644 new_content_rendering_timeout_->IsRunning()) { | 2657 new_content_rendering_timeout_->IsRunning()) { |
2645 new_content_rendering_timeout_->Stop(); | 2658 new_content_rendering_timeout_->Stop(); |
2646 } | 2659 } |
2647 } | 2660 } |
2648 | 2661 |
2649 } // namespace content | 2662 } // namespace content |
OLD | NEW |