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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 655 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
656 } | 656 } |
657 } | 657 } |
658 | 658 |
659 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { | 659 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { |
660 if (CommandLine::ForCurrentProcess()->HasSwitch( | 660 if (CommandLine::ForCurrentProcess()->HasSwitch( |
661 switches::kDisableHangMonitor)) { | 661 switches::kDisableHangMonitor)) { |
662 return; | 662 return; |
663 } | 663 } |
664 | 664 |
665 // Set time_when_considered_hung_ if it's null. | 665 // Set time_when_considered_hung_ if it's null. Otherwise, update |
| 666 // time_when_considered_hung_ if the caller's request is sooner than the |
| 667 // existing one. This will have the side effect that the existing timeout will |
| 668 // be forgotten. |
666 Time requested_end_time = Time::Now() + delay; | 669 Time requested_end_time = Time::Now() + delay; |
667 if (time_when_considered_hung_.is_null()) | 670 if (time_when_considered_hung_.is_null() || |
| 671 time_when_considered_hung_ > requested_end_time) |
668 time_when_considered_hung_ = requested_end_time; | 672 time_when_considered_hung_ = requested_end_time; |
669 | 673 |
670 // If we already have a timer with the same or shorter duration, then we can | 674 // If we already have a timer with the same or shorter duration, then we can |
671 // wait for it to finish. | 675 // wait for it to finish. |
672 if (hung_renderer_timer_.IsRunning() && | 676 if (hung_renderer_timer_.IsRunning() && |
673 hung_renderer_timer_.GetCurrentDelay() <= delay) { | 677 hung_renderer_timer_.GetCurrentDelay() <= delay) { |
674 // If time_when_considered_hung_ was null, this timer may fire early. | 678 // If time_when_considered_hung_ was null, this timer may fire early. |
675 // CheckRendererIsUnresponsive handles that by calling | 679 // CheckRendererIsUnresponsive handles that by calling |
676 // StartHangMonitorTimeout with the remaining time. | 680 // StartHangMonitorTimeout with the remaining time. |
677 // If time_when_considered_hung_ was non-null, it means we still haven't | 681 // 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... |
872 | 876 |
873 // Any non-wheel input event cancels pending wheel events. | 877 // Any non-wheel input event cancels pending wheel events. |
874 if (input_event.type != WebInputEvent::MouseWheel) | 878 if (input_event.type != WebInputEvent::MouseWheel) |
875 coalesced_mouse_wheel_events_.clear(); | 879 coalesced_mouse_wheel_events_.clear(); |
876 | 880 |
877 // Any input event cancels a pending mouse move event. Note that | 881 // Any input event cancels a pending mouse move event. Note that |
878 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| | 882 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| |
879 // after this line. | 883 // after this line. |
880 next_mouse_move_.reset(); | 884 next_mouse_move_.reset(); |
881 | 885 |
882 in_flight_event_count_++; | 886 increment_in_flight_event_count(); |
883 StartHangMonitorTimeout( | 887 StartHangMonitorTimeout( |
884 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 888 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
885 } | 889 } |
886 | 890 |
887 void RenderWidgetHostImpl::ForwardTouchEvent( | 891 void RenderWidgetHostImpl::ForwardTouchEvent( |
888 const WebKit::WebTouchEvent& touch_event) { | 892 const WebKit::WebTouchEvent& touch_event) { |
889 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); | 893 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); |
890 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 894 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
891 return; | 895 return; |
892 | 896 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 | 1318 |
1315 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type, | 1319 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type, |
1316 bool processed) { | 1320 bool processed) { |
1317 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck"); | 1321 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck"); |
1318 | 1322 |
1319 // Log the time delta for processing an input event. | 1323 // Log the time delta for processing an input event. |
1320 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 1324 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
1321 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); | 1325 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); |
1322 | 1326 |
1323 // Cancel pending hung renderer checks since the renderer is responsive. | 1327 // Cancel pending hung renderer checks since the renderer is responsive. |
1324 if (--in_flight_event_count_ == 0) | 1328 if (decrement_in_flight_event_count() == 0) |
1325 StopHangMonitorTimeout(); | 1329 StopHangMonitorTimeout(); |
1326 | 1330 |
1327 int type = static_cast<int>(event_type); | 1331 int type = static_cast<int>(event_type); |
1328 if (type < WebInputEvent::Undefined) { | 1332 if (type < WebInputEvent::Undefined) { |
1329 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); | 1333 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); |
1330 process_->ReceivedBadMessage(); | 1334 process_->ReceivedBadMessage(); |
1331 } else if (type == WebInputEvent::MouseMove) { | 1335 } else if (type == WebInputEvent::MouseMove) { |
1332 mouse_move_pending_ = false; | 1336 mouse_move_pending_ = false; |
1333 | 1337 |
1334 // now, we can send the next mouse move event | 1338 // now, we can send the next mouse move event |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 // indicate that no callback is in progress (i.e. without this line | 1747 // indicate that no callback is in progress (i.e. without this line |
1744 // DelayedAutoResized will not get called again). | 1748 // DelayedAutoResized will not get called again). |
1745 new_auto_size_.SetSize(0, 0); | 1749 new_auto_size_.SetSize(0, 0); |
1746 if (!should_auto_resize_) | 1750 if (!should_auto_resize_) |
1747 return; | 1751 return; |
1748 | 1752 |
1749 OnRenderAutoResized(new_size); | 1753 OnRenderAutoResized(new_size); |
1750 } | 1754 } |
1751 | 1755 |
1752 } // namespace content | 1756 } // namespace content |
OLD | NEW |