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

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: Fix initialization list again. 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 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 RecordInputEvent();
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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 1146
1143 void RenderWidgetHost::OnMsgInputEventAck(WebInputEvent::Type event_type, 1147 void RenderWidgetHost::OnMsgInputEventAck(WebInputEvent::Type event_type,
1144 bool processed) { 1148 bool processed) {
1145 TRACE_EVENT0("renderer_host", "RenderWidgetHost::OnMsgInputEventAck"); 1149 TRACE_EVENT0("renderer_host", "RenderWidgetHost::OnMsgInputEventAck");
1146 1150
1147 // Log the time delta for processing an input event. 1151 // Log the time delta for processing an input event.
1148 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 1152 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
1149 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); 1153 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta);
1150 1154
1151 // Cancel pending hung renderer checks since the renderer is responsive. 1155 // Cancel pending hung renderer checks since the renderer is responsive.
1152 StopHangMonitorTimeout(); 1156 if (RecordInputEventAck())
1157 StopHangMonitorTimeout();
1153 1158
1154 int type = static_cast<int>(event_type); 1159 int type = static_cast<int>(event_type);
1155 if (type < WebInputEvent::Undefined) { 1160 if (type < WebInputEvent::Undefined) {
1156 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); 1161 content::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2"));
1157 process()->ReceivedBadMessage(); 1162 process()->ReceivedBadMessage();
1158 } else if (type == WebInputEvent::MouseMove) { 1163 } else if (type == WebInputEvent::MouseMove) {
1159 mouse_move_pending_ = false; 1164 mouse_move_pending_ = false;
1160 1165
1161 // now, we can send the next mouse move event 1166 // now, we can send the next mouse move event
1162 if (next_mouse_move_.get()) { 1167 if (next_mouse_move_.get()) {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { 1523 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) {
1519 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 1524 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
1520 return false; 1525 return false;
1521 } else { 1526 } else {
1522 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); 1527 Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
1523 return true; 1528 return true;
1524 } 1529 }
1525 } 1530 }
1526 } 1531 }
1527 1532
1533 void RenderWidgetHost::RecordInputEvent() {
1534 // TODO: remove this check once the compositor thread
1535 // is used by default.
1536 if (!CommandLine::ForCurrentProcess()->HasSwitch(
darin (slow to review) 2012/01/24 17:58:01 I'm not sure it is a good idea to check command li
1537 switches::kEnableThreadedCompositing)) {
1538 return;
1539 }
1540 event_count_++;
1541 }
1542
1543 bool RenderWidgetHost::RecordInputEventAck() {
1544 // TODO: remove this check once the compositor thread
1545 // is used by default.
1546 if (!CommandLine::ForCurrentProcess()->HasSwitch(
1547 switches::kEnableThreadedCompositing)) {
1548 return true;
1549 }
1550 return --event_count_ == 0;
darin (slow to review) 2012/01/24 17:58:01 The name of this function, RecordInputEventAck, do
1551 }
1552
1553
1528 // static 1554 // static
1529 void RenderWidgetHost::AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) { 1555 void RenderWidgetHost::AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) {
1530 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); 1556 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id);
1531 if (ui_shim) 1557 if (ui_shim)
1532 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); 1558 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id));
1533 } 1559 }
1534 1560
1535 // static 1561 // static
1536 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id, 1562 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id,
1537 int gpu_host_id) { 1563 int gpu_host_id) {
1538 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); 1564 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id);
1539 if (ui_shim) 1565 if (ui_shim)
1540 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); 1566 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id));
1541 } 1567 }
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