Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 10008015: Fixing a problem, where a hung renderer process is not killed when navigating away (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes based on feedback and new test Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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. Otherwise, update
632 // time_when_considered_hung_ if the caller's request is sooner than the
633 // existing one. This will have the side effect that the existing timeout will
634 // be forgotten.
632 Time requested_end_time = Time::Now() + delay; 635 Time requested_end_time = Time::Now() + delay;
633 if (time_when_considered_hung_.is_null()) 636 if (time_when_considered_hung_.is_null() ||
637 time_when_considered_hung_ > requested_end_time)
634 time_when_considered_hung_ = requested_end_time; 638 time_when_considered_hung_ = requested_end_time;
635 639
636 // If we already have a timer with the same or shorter duration, then we can 640 // If we already have a timer with the same or shorter duration, then we can
637 // wait for it to finish. 641 // wait for it to finish.
638 if (hung_renderer_timer_.IsRunning() && 642 if (hung_renderer_timer_.IsRunning() &&
639 hung_renderer_timer_.GetCurrentDelay() <= delay) { 643 hung_renderer_timer_.GetCurrentDelay() <= delay) {
640 // If time_when_considered_hung_ was null, this timer may fire early. 644 // If time_when_considered_hung_ was null, this timer may fire early.
641 // CheckRendererIsUnresponsive handles that by calling 645 // CheckRendererIsUnresponsive handles that by calling
642 // StartHangMonitorTimeout with the remaining time. 646 // StartHangMonitorTimeout with the remaining time.
643 // If time_when_considered_hung_ was non-null, it means we still haven't 647 // 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
838 842
839 // Any non-wheel input event cancels pending wheel events. 843 // Any non-wheel input event cancels pending wheel events.
840 if (input_event.type != WebInputEvent::MouseWheel) 844 if (input_event.type != WebInputEvent::MouseWheel)
841 coalesced_mouse_wheel_events_.clear(); 845 coalesced_mouse_wheel_events_.clear();
842 846
843 // Any input event cancels a pending mouse move event. Note that 847 // 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| 848 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event|
845 // after this line. 849 // after this line.
846 next_mouse_move_.reset(); 850 next_mouse_move_.reset();
847 851
848 in_flight_event_count_++; 852 increment_in_flight_event_count();
849 StartHangMonitorTimeout( 853 StartHangMonitorTimeout(
850 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); 854 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_));
851 } 855 }
852 856
853 void RenderWidgetHostImpl::ForwardTouchEvent( 857 void RenderWidgetHostImpl::ForwardTouchEvent(
854 const WebKit::WebTouchEvent& touch_event) { 858 const WebKit::WebTouchEvent& touch_event) {
855 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); 859 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent");
856 if (ignore_input_events_ || process_->IgnoreInputEvents()) 860 if (ignore_input_events_ || process_->IgnoreInputEvents())
857 return; 861 return;
858 862
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 1284
1281 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type, 1285 void RenderWidgetHostImpl::OnMsgInputEventAck(WebInputEvent::Type event_type,
1282 bool processed) { 1286 bool processed) {
1283 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck"); 1287 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgInputEventAck");
1284 1288
1285 // Log the time delta for processing an input event. 1289 // Log the time delta for processing an input event.
1286 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 1290 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
1287 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); 1291 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta);
1288 1292
1289 // Cancel pending hung renderer checks since the renderer is responsive. 1293 // Cancel pending hung renderer checks since the renderer is responsive.
1290 if (--in_flight_event_count_ == 0) 1294 if (decrement_in_flight_event_count() == 0)
1291 StopHangMonitorTimeout(); 1295 StopHangMonitorTimeout();
1292 1296
1293 int type = static_cast<int>(event_type); 1297 int type = static_cast<int>(event_type);
1294 if (type < WebInputEvent::Undefined) { 1298 if (type < WebInputEvent::Undefined) {
1295 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); 1299 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2"));
1296 process_->ReceivedBadMessage(); 1300 process_->ReceivedBadMessage();
1297 } else if (type == WebInputEvent::MouseMove) { 1301 } else if (type == WebInputEvent::MouseMove) {
1298 mouse_move_pending_ = false; 1302 mouse_move_pending_ = false;
1299 1303
1300 // now, we can send the next mouse move event 1304 // now, we can send the next mouse move event
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 // indicate that no callback is in progress (i.e. without this line 1713 // indicate that no callback is in progress (i.e. without this line
1710 // DelayedAutoResized will not get called again). 1714 // DelayedAutoResized will not get called again).
1711 new_auto_size_.SetSize(0, 0); 1715 new_auto_size_.SetSize(0, 0);
1712 if (!should_auto_resize_) 1716 if (!should_auto_resize_)
1713 return; 1717 return;
1714 1718
1715 OnRenderAutoResized(new_size); 1719 OnRenderAutoResized(new_size);
1716 } 1720 }
1717 1721
1718 } // namespace content 1722 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698