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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 621 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
622 } | 622 } |
623 } | 623 } |
624 | 624 |
625 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { | 625 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { |
626 if (CommandLine::ForCurrentProcess()->HasSwitch( | 626 if (CommandLine::ForCurrentProcess()->HasSwitch( |
627 switches::kDisableHangMonitor)) { | 627 switches::kDisableHangMonitor)) { |
628 return; | 628 return; |
629 } | 629 } |
630 | 630 |
631 // Set time_when_considered_hung_ if it's null. | 631 // Set time_when_considered_hung_ if it's null, or if it is further in the |
Charlie Reis
2012/04/06 22:34:14
nit: Split this into a separate sentence to make i
nasko
2012/04/10 00:16:37
No, there is no unit test for this particular case
| |
632 // future than the current request, update it to the shorter duration. This | |
633 // will have the side effect that the existing timeout will be forgotten. | |
632 Time requested_end_time = Time::Now() + delay; | 634 Time requested_end_time = Time::Now() + delay; |
633 if (time_when_considered_hung_.is_null()) | 635 if (time_when_considered_hung_.is_null() || |
636 time_when_considered_hung_ > requested_end_time) | |
634 time_when_considered_hung_ = requested_end_time; | 637 time_when_considered_hung_ = requested_end_time; |
635 | 638 |
636 // If we already have a timer with the same or shorter duration, then we can | 639 // If we already have a timer with the same or shorter duration, then we can |
637 // wait for it to finish. | 640 // wait for it to finish. |
638 if (hung_renderer_timer_.IsRunning() && | 641 if (hung_renderer_timer_.IsRunning() && |
639 hung_renderer_timer_.GetCurrentDelay() <= delay) { | 642 hung_renderer_timer_.GetCurrentDelay() <= delay) { |
640 // If time_when_considered_hung_ was null, this timer may fire early. | 643 // If time_when_considered_hung_ was null, this timer may fire early. |
641 // CheckRendererIsUnresponsive handles that by calling | 644 // CheckRendererIsUnresponsive handles that by calling |
642 // StartHangMonitorTimeout with the remaining time. | 645 // StartHangMonitorTimeout with the remaining time. |
643 // If time_when_considered_hung_ was non-null, it means we still haven't | 646 // If time_when_considered_hung_ was non-null, it means we still haven't |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 | 841 |
839 // Any non-wheel input event cancels pending wheel events. | 842 // Any non-wheel input event cancels pending wheel events. |
840 if (input_event.type != WebInputEvent::MouseWheel) | 843 if (input_event.type != WebInputEvent::MouseWheel) |
841 coalesced_mouse_wheel_events_.clear(); | 844 coalesced_mouse_wheel_events_.clear(); |
842 | 845 |
843 // Any input event cancels a pending mouse move event. Note that | 846 // Any input event cancels a pending mouse move event. Note that |
844 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| | 847 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| |
845 // after this line. | 848 // after this line. |
846 next_mouse_move_.reset(); | 849 next_mouse_move_.reset(); |
847 | 850 |
848 in_flight_event_count_++; | 851 IncrementInFlightEventCount(); |
849 StartHangMonitorTimeout( | 852 StartHangMonitorTimeout( |
850 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 853 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
851 } | 854 } |
852 | 855 |
853 void RenderWidgetHostImpl::ForwardTouchEvent( | 856 void RenderWidgetHostImpl::ForwardTouchEvent( |
854 const WebKit::WebTouchEvent& touch_event) { | 857 const WebKit::WebTouchEvent& touch_event) { |
855 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); | 858 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); |
856 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 859 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
857 return; | 860 return; |
858 | 861 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1280 | 1283 |
1281 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type, | 1284 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type, |
1282 bool processed) { | 1285 bool processed) { |
1283 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck"); | 1286 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck"); |
1284 | 1287 |
1285 // Log the time delta for processing an input event. | 1288 // Log the time delta for processing an input event. |
1286 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 1289 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
1287 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); | 1290 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); |
1288 | 1291 |
1289 // Cancel pending hung renderer checks since the renderer is responsive. | 1292 // Cancel pending hung renderer checks since the renderer is responsive. |
1290 if (--in_flight_event_count_ == 0) | 1293 if (DecrementInFlightEventCount() == 0) |
1291 StopHangMonitorTimeout(); | 1294 StopHangMonitorTimeout(); |
1292 | 1295 |
1293 int type = static_cast<int>(event_type); | 1296 int type = static_cast<int>(event_type); |
1294 if (type < WebInputEvent::Undefined) { | 1297 if (type < WebInputEvent::Undefined) { |
1295 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); | 1298 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); |
1296 process_->ReceivedBadMessage(); | 1299 process_->ReceivedBadMessage(); |
1297 } else if (type == WebInputEvent::MouseMove) { | 1300 } else if (type == WebInputEvent::MouseMove) { |
1298 mouse_move_pending_ = false; | 1301 mouse_move_pending_ = false; |
1299 | 1302 |
1300 // now, we can send the next mouse move event | 1303 // now, we can send the next mouse move event |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1709 // indicate that no callback is in progress (i.e. without this line | 1712 // indicate that no callback is in progress (i.e. without this line |
1710 // DelayedAutoResized will not get called again). | 1713 // DelayedAutoResized will not get called again). |
1711 new_auto_size_.SetSize(0, 0); | 1714 new_auto_size_.SetSize(0, 0); |
1712 if (!should_auto_resize_) | 1715 if (!should_auto_resize_) |
1713 return; | 1716 return; |
1714 | 1717 |
1715 OnRenderAutoResized(new_size); | 1718 OnRenderAutoResized(new_size); |
1716 } | 1719 } |
1717 | 1720 |
1718 } // namespace content | 1721 } // namespace content |
OLD | NEW |