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

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

Issue 9129024: Fix for crbug.com/111185. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forgot to commit all changes before uploading. Created 8 years, 11 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.h" 5 #include "content/browser/renderer_host/render_widget_host.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 } // namespace 72 } // namespace
73 73
74 /////////////////////////////////////////////////////////////////////////////// 74 ///////////////////////////////////////////////////////////////////////////////
75 // RenderWidgetHost 75 // RenderWidgetHost
76 76
77 RenderWidgetHost::RenderWidgetHost(content::RenderProcessHost* process, 77 RenderWidgetHost::RenderWidgetHost(content::RenderProcessHost* process,
78 int routing_id) 78 int routing_id)
79 : renderer_initialized_(false), 79 : renderer_initialized_(false),
80 hung_renderer_delay_ms_(kHungRendererDelayMs),
80 renderer_accessible_(false), 81 renderer_accessible_(false),
81 view_(NULL), 82 view_(NULL),
82 process_(process), 83 process_(process),
83 routing_id_(routing_id), 84 routing_id_(routing_id),
84 surface_id_(0), 85 surface_id_(0),
85 is_loading_(false), 86 is_loading_(false),
86 is_hidden_(false), 87 is_hidden_(false),
87 is_accelerated_compositing_active_(false), 88 is_accelerated_compositing_active_(false),
88 repaint_ack_pending_(false), 89 repaint_ack_pending_(false),
89 resize_ack_pending_(false), 90 resize_ack_pending_(false),
90 should_auto_resize_(false), 91 should_auto_resize_(false),
91 mouse_move_pending_(false), 92 mouse_move_pending_(false),
92 mouse_wheel_pending_(false), 93 mouse_wheel_pending_(false),
93 touch_move_pending_(false), 94 touch_move_pending_(false),
94 touch_event_is_queued_(false), 95 touch_event_is_queued_(false),
95 needs_repainting_on_restore_(false), 96 needs_repainting_on_restore_(false),
96 is_unresponsive_(false), 97 is_unresponsive_(false),
98 in_flight_event_count_(0),
97 in_get_backing_store_(false), 99 in_get_backing_store_(false),
98 view_being_painted_(false), 100 view_being_painted_(false),
99 ignore_input_events_(false), 101 ignore_input_events_(false),
100 text_direction_updated_(false), 102 text_direction_updated_(false),
101 text_direction_(WebKit::WebTextDirectionLeftToRight), 103 text_direction_(WebKit::WebTextDirectionLeftToRight),
102 text_direction_canceled_(false), 104 text_direction_canceled_(false),
103 suppress_next_char_events_(false), 105 suppress_next_char_events_(false),
104 pending_mouse_lock_request_(false), 106 pending_mouse_lock_request_(false),
105 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 107 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
106 if (routing_id_ == MSG_ROUTING_NONE) { 108 if (routing_id_ == MSG_ROUTING_NONE) {
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // fire sooner. 533 // fire sooner.
532 time_when_considered_hung_ = requested_end_time; 534 time_when_considered_hung_ = requested_end_time;
533 hung_renderer_timer_.Stop(); 535 hung_renderer_timer_.Stop();
534 hung_renderer_timer_.Start(FROM_HERE, delay, this, 536 hung_renderer_timer_.Start(FROM_HERE, delay, this,
535 &RenderWidgetHost::CheckRendererIsUnresponsive); 537 &RenderWidgetHost::CheckRendererIsUnresponsive);
536 } 538 }
537 539
538 void RenderWidgetHost::RestartHangMonitorTimeout() { 540 void RenderWidgetHost::RestartHangMonitorTimeout() {
539 // Setting to null will cause StartHangMonitorTimeout to restart the timer. 541 // Setting to null will cause StartHangMonitorTimeout to restart the timer.
540 time_when_considered_hung_ = Time(); 542 time_when_considered_hung_ = Time();
541 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 543 StartHangMonitorTimeout(
544 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_));
542 } 545 }
543 546
544 void RenderWidgetHost::StopHangMonitorTimeout() { 547 void RenderWidgetHost::StopHangMonitorTimeout() {
545 time_when_considered_hung_ = Time(); 548 time_when_considered_hung_ = Time();
546 RendererIsResponsive(); 549 RendererIsResponsive();
547
548 // We do not bother to stop the hung_renderer_timer_ here in case it will be 550 // We do not bother to stop the hung_renderer_timer_ here in case it will be
549 // started again shortly, which happens to be the common use case. 551 // started again shortly, which happens to be the common use case.
550 } 552 }
551 553
552 void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) { 554 void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
553 TRACE_EVENT2("renderer_host", "RenderWidgetHost::ForwardMouseEvent", 555 TRACE_EVENT2("renderer_host", "RenderWidgetHost::ForwardMouseEvent",
554 "x", mouse_event.x, "y", mouse_event.y); 556 "x", mouse_event.x, "y", mouse_event.y);
555 if (ignore_input_events_ || process_->IgnoreInputEvents()) 557 if (ignore_input_events_ || process_->IgnoreInputEvents())
556 return; 558 return;
557 559
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 714
713 // Any non-wheel input event cancels pending wheel events. 715 // Any non-wheel input event cancels pending wheel events.
714 if (input_event.type != WebInputEvent::MouseWheel) 716 if (input_event.type != WebInputEvent::MouseWheel)
715 coalesced_mouse_wheel_events_.clear(); 717 coalesced_mouse_wheel_events_.clear();
716 718
717 // Any input event cancels a pending mouse move event. Note that 719 // Any input event cancels a pending mouse move event. Note that
718 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| 720 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event|
719 // after this line. 721 // after this line.
720 next_mouse_move_.reset(); 722 next_mouse_move_.reset();
721 723
722 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 724 in_flight_event_count_++;
725 StartHangMonitorTimeout(
726 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_));
723 } 727 }
724 728
725 void RenderWidgetHost::ForwardTouchEvent( 729 void RenderWidgetHost::ForwardTouchEvent(
726 const WebKit::WebTouchEvent& touch_event) { 730 const WebKit::WebTouchEvent& touch_event) {
727 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent"); 731 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent");
728 if (ignore_input_events_ || process_->IgnoreInputEvents()) 732 if (ignore_input_events_ || process_->IgnoreInputEvents())
729 return; 733 return;
730 734
731 if (touch_event.type == WebInputEvent::TouchMove && 735 if (touch_event.type == WebInputEvent::TouchMove &&
732 touch_move_pending_) { 736 touch_move_pending_) {
(...skipping 30 matching lines...) Expand all
763 767
764 // Reset some fields in preparation for recovering from a crash. 768 // Reset some fields in preparation for recovering from a crash.
765 resize_ack_pending_ = false; 769 resize_ack_pending_ = false;
766 repaint_ack_pending_ = false; 770 repaint_ack_pending_ = false;
767 771
768 in_flight_size_.SetSize(0, 0); 772 in_flight_size_.SetSize(0, 0);
769 current_size_.SetSize(0, 0); 773 current_size_.SetSize(0, 0);
770 is_hidden_ = false; 774 is_hidden_ = false;
771 is_accelerated_compositing_active_ = false; 775 is_accelerated_compositing_active_ = false;
772 776
777 // Reset this to ensure the hung renderer mechanism is working properly.
778 in_flight_event_count_ = 0;
779
773 if (view_) { 780 if (view_) {
774 view_->RenderViewGone(status, exit_code); 781 view_->RenderViewGone(status, exit_code);
775 view_ = NULL; // The View should be deleted by RenderViewGone. 782 view_ = NULL; // The View should be deleted by RenderViewGone.
776 } 783 }
777 784
778 BackingStoreManager::RemoveBackingStore(this); 785 BackingStoreManager::RemoveBackingStore(this);
779 } 786 }
780 787
781 void RenderWidgetHost::UpdateTextDirection(WebTextDirection direction) { 788 void RenderWidgetHost::UpdateTextDirection(WebTextDirection direction) {
782 text_direction_updated_ = true; 789 text_direction_updated_ = true;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 1149
1143 void RenderWidgetHost::OnMsgInputEventAck(WebInputEvent::Type event_type, 1150 void RenderWidgetHost::OnMsgInputEventAck(WebInputEvent::Type event_type,
1144 bool processed) { 1151 bool processed) {
1145 TRACE_EVENT0("renderer_host", "RenderWidgetHost::OnMsgInputEventAck"); 1152 TRACE_EVENT0("renderer_host", "RenderWidgetHost::OnMsgInputEventAck");
1146 1153
1147 // Log the time delta for processing an input event. 1154 // Log the time delta for processing an input event.
1148 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 1155 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
1149 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); 1156 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta);
1150 1157
1151 // Cancel pending hung renderer checks since the renderer is responsive. 1158 // Cancel pending hung renderer checks since the renderer is responsive.
1152 StopHangMonitorTimeout(); 1159 if (--in_flight_event_count_ == 0 ||
1160 !CommandLine::ForCurrentProcess()->HasSwitch(
darin (slow to review) 2012/01/24 20:06:56 I still don't quite understand the need for checki
1161 switches::kEnableThreadedCompositing)) {
1162 // TODO: don't check for kEnableThreadedCompositing when
1163 // the compositor thread is used by default.
1164 StopHangMonitorTimeout();
1165 }
1153 1166
1154 int type = static_cast<int>(event_type); 1167 int type = static_cast<int>(event_type);
1155 if (type < WebInputEvent::Undefined) { 1168 if (type < WebInputEvent::Undefined) {
1156 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); 1169 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2"));
1157 process()->ReceivedBadMessage(); 1170 process()->ReceivedBadMessage();
1158 } else if (type == WebInputEvent::MouseMove) { 1171 } else if (type == WebInputEvent::MouseMove) {
1159 mouse_move_pending_ = false; 1172 mouse_move_pending_ = false;
1160 1173
1161 // now, we can send the next mouse move event 1174 // now, we can send the next mouse move event
1162 if (next_mouse_move_.get()) { 1175 if (next_mouse_move_.get()) {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); 1545 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id));
1533 } 1546 }
1534 1547
1535 // static 1548 // static
1536 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id, 1549 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id,
1537 int gpu_host_id) { 1550 int gpu_host_id) {
1538 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); 1551 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id);
1539 if (ui_shim) 1552 if (ui_shim)
1540 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); 1553 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id));
1541 } 1554 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698