| 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 704 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 | 707 |
| 708 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { | 708 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { |
| 709 if (CommandLine::ForCurrentProcess()->HasSwitch( | 709 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 710 switches::kDisableHangMonitor)) { | 710 switches::kDisableHangMonitor)) { |
| 711 return; | 711 return; |
| 712 } | 712 } |
| 713 | 713 |
| 714 // Set time_when_considered_hung_ if it's null. Otherwise, update | 714 // Set time_when_considered_hung_ if it's null. |
| 715 // time_when_considered_hung_ if the caller's request is sooner than the | |
| 716 // existing one. This will have the side effect that the existing timeout will | |
| 717 // be forgotten. | |
| 718 Time requested_end_time = Time::Now() + delay; | 715 Time requested_end_time = Time::Now() + delay; |
| 719 if (time_when_considered_hung_.is_null() || | 716 if (time_when_considered_hung_.is_null()) |
| 720 time_when_considered_hung_ > requested_end_time) | |
| 721 time_when_considered_hung_ = requested_end_time; | 717 time_when_considered_hung_ = requested_end_time; |
| 722 | 718 |
| 723 // If we already have a timer with the same or shorter duration, then we can | 719 // If we already have a timer with the same or shorter duration, then we can |
| 724 // wait for it to finish. | 720 // wait for it to finish. |
| 725 if (hung_renderer_timer_.IsRunning() && | 721 if (hung_renderer_timer_.IsRunning() && |
| 726 hung_renderer_timer_.GetCurrentDelay() <= delay) { | 722 hung_renderer_timer_.GetCurrentDelay() <= delay) { |
| 727 // If time_when_considered_hung_ was null, this timer may fire early. | 723 // If time_when_considered_hung_ was null, this timer may fire early. |
| 728 // CheckRendererIsUnresponsive handles that by calling | 724 // CheckRendererIsUnresponsive handles that by calling |
| 729 // StartHangMonitorTimeout with the remaining time. | 725 // StartHangMonitorTimeout with the remaining time. |
| 730 // If time_when_considered_hung_ was non-null, it means we still haven't | 726 // If time_when_considered_hung_ was non-null, it means we still haven't |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 925 |
| 930 // Any non-wheel input event cancels pending wheel events. | 926 // Any non-wheel input event cancels pending wheel events. |
| 931 if (input_event.type != WebInputEvent::MouseWheel) | 927 if (input_event.type != WebInputEvent::MouseWheel) |
| 932 coalesced_mouse_wheel_events_.clear(); | 928 coalesced_mouse_wheel_events_.clear(); |
| 933 | 929 |
| 934 // Any input event cancels a pending mouse move event. Note that | 930 // Any input event cancels a pending mouse move event. Note that |
| 935 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| | 931 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| |
| 936 // after this line. | 932 // after this line. |
| 937 next_mouse_move_.reset(); | 933 next_mouse_move_.reset(); |
| 938 | 934 |
| 939 increment_in_flight_event_count(); | 935 in_flight_event_count_++; |
| 940 StartHangMonitorTimeout( | 936 StartHangMonitorTimeout( |
| 941 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 937 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
| 942 } | 938 } |
| 943 | 939 |
| 944 void RenderWidgetHostImpl::ForwardTouchEvent( | 940 void RenderWidgetHostImpl::ForwardTouchEvent( |
| 945 const WebKit::WebTouchEvent& touch_event) { | 941 const WebKit::WebTouchEvent& touch_event) { |
| 946 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); | 942 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); |
| 947 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 943 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
| 948 return; | 944 return; |
| 949 | 945 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 | 1391 |
| 1396 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type, | 1392 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type, |
| 1397 bool processed) { | 1393 bool processed) { |
| 1398 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck"); | 1394 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck"); |
| 1399 | 1395 |
| 1400 // Log the time delta for processing an input event. | 1396 // Log the time delta for processing an input event. |
| 1401 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 1397 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
| 1402 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); | 1398 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); |
| 1403 | 1399 |
| 1404 // Cancel pending hung renderer checks since the renderer is responsive. | 1400 // Cancel pending hung renderer checks since the renderer is responsive. |
| 1405 if (decrement_in_flight_event_count() == 0) | 1401 if (--in_flight_event_count_ == 0) |
| 1406 StopHangMonitorTimeout(); | 1402 StopHangMonitorTimeout(); |
| 1407 | 1403 |
| 1408 int type = static_cast<int>(event_type); | 1404 int type = static_cast<int>(event_type); |
| 1409 if (type < WebInputEvent::Undefined) { | 1405 if (type < WebInputEvent::Undefined) { |
| 1410 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); | 1406 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); |
| 1411 process_->ReceivedBadMessage(); | 1407 process_->ReceivedBadMessage(); |
| 1412 } else if (type == WebInputEvent::MouseMove) { | 1408 } else if (type == WebInputEvent::MouseMove) { |
| 1413 mouse_move_pending_ = false; | 1409 mouse_move_pending_ = false; |
| 1414 | 1410 |
| 1415 // now, we can send the next mouse move event | 1411 // now, we can send the next mouse move event |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 // indicate that no callback is in progress (i.e. without this line | 1807 // indicate that no callback is in progress (i.e. without this line |
| 1812 // DelayedAutoResized will not get called again). | 1808 // DelayedAutoResized will not get called again). |
| 1813 new_auto_size_.SetSize(0, 0); | 1809 new_auto_size_.SetSize(0, 0); |
| 1814 if (!should_auto_resize_) | 1810 if (!should_auto_resize_) |
| 1815 return; | 1811 return; |
| 1816 | 1812 |
| 1817 OnRenderAutoResized(new_size); | 1813 OnRenderAutoResized(new_size); |
| 1818 } | 1814 } |
| 1819 | 1815 |
| 1820 } // namespace content | 1816 } // namespace content |
| OLD | NEW |