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

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

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "content/browser/accessibility/browser_accessibility_state.h" 15 #include "content/browser/accessibility/browser_accessibility_state.h"
16 #include "content/browser/gpu/gpu_process_host.h" 16 #include "content/browser/gpu/gpu_process_host.h"
17 #include "content/browser/renderer_host/backing_store.h" 17 #include "content/browser/renderer_host/backing_store.h"
18 #include "content/browser/renderer_host/backing_store_manager.h" 18 #include "content/browser/renderer_host/backing_store_manager.h"
19 #include "content/browser/renderer_host/render_process_host.h" 19 #include "content/browser/renderer_host/render_process_host_impl.h"
20 #include "content/browser/renderer_host/render_widget_helper.h" 20 #include "content/browser/renderer_host/render_widget_helper.h"
21 #include "content/browser/renderer_host/render_widget_host_view.h" 21 #include "content/browser/renderer_host/render_widget_host_view.h"
22 #include "content/browser/user_metrics.h" 22 #include "content/browser/user_metrics.h"
23 #include "content/common/gpu/gpu_messages.h" 23 #include "content/common/gpu/gpu_messages.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
26 #include "content/public/browser/native_web_keyboard_event.h" 26 #include "content/public/browser/native_web_keyboard_event.h"
27 #include "content/public/browser/notification_types.h" 27 #include "content/public/browser/notification_types.h"
28 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
29 #include "content/public/common/result_codes.h" 29 #include "content/public/common/result_codes.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 == new_event.hasPreciseScrollingDeltas && 69 == new_event.hasPreciseScrollingDeltas &&
70 last_event.phase == new_event.phase && 70 last_event.phase == new_event.phase &&
71 last_event.momentumPhase == new_event.momentumPhase; 71 last_event.momentumPhase == new_event.momentumPhase;
72 } 72 }
73 73
74 } // namespace 74 } // namespace
75 75
76 /////////////////////////////////////////////////////////////////////////////// 76 ///////////////////////////////////////////////////////////////////////////////
77 // RenderWidgetHost 77 // RenderWidgetHost
78 78
79 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, 79 RenderWidgetHost::RenderWidgetHost(content::RenderProcessHost* process,
80 int routing_id) 80 int routing_id)
81 : renderer_initialized_(false), 81 : renderer_initialized_(false),
82 renderer_accessible_(false), 82 renderer_accessible_(false),
83 view_(NULL), 83 view_(NULL),
84 process_(process), 84 process_(process),
85 routing_id_(routing_id), 85 routing_id_(routing_id),
86 is_loading_(false), 86 is_loading_(false),
87 is_hidden_(false), 87 is_hidden_(false),
88 is_accelerated_compositing_active_(false), 88 is_accelerated_compositing_active_(false),
89 repaint_ack_pending_(false), 89 repaint_ack_pending_(false),
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // Don't bother reporting hung state when we aren't the active tab. 257 // Don't bother reporting hung state when we aren't the active tab.
258 StopHangMonitorTimeout(); 258 StopHangMonitorTimeout();
259 259
260 // If we have a renderer, then inform it that we are being hidden so it can 260 // If we have a renderer, then inform it that we are being hidden so it can
261 // reduce its resource utilization. 261 // reduce its resource utilization.
262 Send(new ViewMsg_WasHidden(routing_id_)); 262 Send(new ViewMsg_WasHidden(routing_id_));
263 263
264 GpuProcessHost::SendOnIO( 264 GpuProcessHost::SendOnIO(
265 0, 265 0,
266 content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 266 content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
267 new GpuMsg_VisibilityChanged(routing_id_, process()->id(), false)); 267 new GpuMsg_VisibilityChanged(routing_id_, process()->GetID(), false));
268 268
269 // Tell the RenderProcessHost we were hidden. 269 // Tell the RenderProcessHost we were hidden.
270 process_->WidgetHidden(); 270 process_->WidgetHidden();
271 271
272 bool is_visible = false; 272 bool is_visible = false;
273 content::NotificationService::current()->Notify( 273 content::NotificationService::current()->Notify(
274 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, 274 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
275 content::Source<RenderWidgetHost>(this), 275 content::Source<RenderWidgetHost>(this),
276 content::Details<bool>(&is_visible)); 276 content::Details<bool>(&is_visible));
277 } 277 }
(...skipping 15 matching lines...) Expand all
293 needs_repainting = true; 293 needs_repainting = true;
294 needs_repainting_on_restore_ = false; 294 needs_repainting_on_restore_ = false;
295 } else { 295 } else {
296 needs_repainting = false; 296 needs_repainting = false;
297 } 297 }
298 Send(new ViewMsg_WasRestored(routing_id_, needs_repainting)); 298 Send(new ViewMsg_WasRestored(routing_id_, needs_repainting));
299 299
300 GpuProcessHost::SendOnIO( 300 GpuProcessHost::SendOnIO(
301 0, 301 0,
302 content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, 302 content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
303 new GpuMsg_VisibilityChanged(routing_id_, process()->id(), true)); 303 new GpuMsg_VisibilityChanged(routing_id_, process()->GetID(), true));
304 304
305 process_->WidgetRestored(); 305 process_->WidgetRestored();
306 306
307 bool is_visible = true; 307 bool is_visible = true;
308 content::NotificationService::current()->Notify( 308 content::NotificationService::current()->Notify(
309 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, 309 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
310 content::Source<RenderWidgetHost>(this), 310 content::Source<RenderWidgetHost>(this),
311 content::Details<bool>(&is_visible)); 311 content::Details<bool>(&is_visible));
312 312
313 // It's possible for our size to be out of sync with the renderer. The 313 // It's possible for our size to be out of sync with the renderer. The
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 void RenderWidgetHost::StopHangMonitorTimeout() { 540 void RenderWidgetHost::StopHangMonitorTimeout() {
541 time_when_considered_hung_ = Time(); 541 time_when_considered_hung_ = Time();
542 RendererIsResponsive(); 542 RendererIsResponsive();
543 543
544 // We do not bother to stop the hung_renderer_timer_ here in case it will be 544 // We do not bother to stop the hung_renderer_timer_ here in case it will be
545 // started again shortly, which happens to be the common use case. 545 // started again shortly, which happens to be the common use case.
546 } 546 }
547 547
548 void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) { 548 void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
549 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardMouseEvent"); 549 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardMouseEvent");
550 if (ignore_input_events_ || process_->ignore_input_events()) 550 if (ignore_input_events_ || process_->IgnoreInputEvents())
551 return; 551 return;
552 552
553 // Avoid spamming the renderer with mouse move events. It is important 553 // Avoid spamming the renderer with mouse move events. It is important
554 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our 554 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our
555 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way 555 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way
556 // more WM_MOUSEMOVE events than we wish to send to the renderer. 556 // more WM_MOUSEMOVE events than we wish to send to the renderer.
557 if (mouse_event.type == WebInputEvent::MouseMove) { 557 if (mouse_event.type == WebInputEvent::MouseMove) {
558 if (mouse_move_pending_) { 558 if (mouse_move_pending_) {
559 if (!next_mouse_move_.get()) { 559 if (!next_mouse_move_.get()) {
560 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); 560 next_mouse_move_.reset(new WebMouseEvent(mouse_event));
(...skipping 14 matching lines...) Expand all
575 575
576 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent), false); 576 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent), false);
577 } 577 }
578 578
579 void RenderWidgetHost::OnMouseActivate() { 579 void RenderWidgetHost::OnMouseActivate() {
580 } 580 }
581 581
582 void RenderWidgetHost::ForwardWheelEvent( 582 void RenderWidgetHost::ForwardWheelEvent(
583 const WebMouseWheelEvent& wheel_event) { 583 const WebMouseWheelEvent& wheel_event) {
584 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent"); 584 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent");
585 if (ignore_input_events_ || process_->ignore_input_events()) 585 if (ignore_input_events_ || process_->IgnoreInputEvents())
586 return; 586 return;
587 587
588 // If there's already a mouse wheel event waiting to be sent to the renderer, 588 // If there's already a mouse wheel event waiting to be sent to the renderer,
589 // add the new deltas to that event. Not doing so (e.g., by dropping the old 589 // add the new deltas to that event. Not doing so (e.g., by dropping the old
590 // event, as for mouse moves) results in very slow scrolling on the Mac (on 590 // event, as for mouse moves) results in very slow scrolling on the Mac (on
591 // which many, very small wheel events are sent). 591 // which many, very small wheel events are sent).
592 if (mouse_wheel_pending_) { 592 if (mouse_wheel_pending_) {
593 if (coalesced_mouse_wheel_events_.empty() || 593 if (coalesced_mouse_wheel_events_.empty() ||
594 !ShouldCoalesceMouseWheelEvents(coalesced_mouse_wheel_events_.back(), 594 !ShouldCoalesceMouseWheelEvents(coalesced_mouse_wheel_events_.back(),
595 wheel_event)) { 595 wheel_event)) {
(...skipping 14 matching lines...) Expand all
610 610
611 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize", 611 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize",
612 coalesced_mouse_wheel_events_.size()); 612 coalesced_mouse_wheel_events_.size());
613 613
614 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), false); 614 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), false);
615 } 615 }
616 616
617 void RenderWidgetHost::ForwardGestureEvent( 617 void RenderWidgetHost::ForwardGestureEvent(
618 const WebKit::WebGestureEvent& gesture_event) { 618 const WebKit::WebGestureEvent& gesture_event) {
619 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent"); 619 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent");
620 if (ignore_input_events_ || process_->ignore_input_events()) 620 if (ignore_input_events_ || process_->IgnoreInputEvents())
621 return; 621 return;
622 622
623 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); 623 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false);
624 } 624 }
625 625
626 void RenderWidgetHost::ForwardKeyboardEvent( 626 void RenderWidgetHost::ForwardKeyboardEvent(
627 const NativeWebKeyboardEvent& key_event) { 627 const NativeWebKeyboardEvent& key_event) {
628 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardKeyboardEvent"); 628 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardKeyboardEvent");
629 if (ignore_input_events_ || process_->ignore_input_events()) 629 if (ignore_input_events_ || process_->IgnoreInputEvents())
630 return; 630 return;
631 631
632 if (key_event.type == WebKeyboardEvent::Char && 632 if (key_event.type == WebKeyboardEvent::Char &&
633 (key_event.windowsKeyCode == ui::VKEY_RETURN || 633 (key_event.windowsKeyCode == ui::VKEY_RETURN ||
634 key_event.windowsKeyCode == ui::VKEY_SPACE)) { 634 key_event.windowsKeyCode == ui::VKEY_SPACE)) {
635 OnUserGesture(); 635 OnUserGesture();
636 } 636 }
637 637
638 // Double check the type to make sure caller hasn't sent us nonsense that 638 // Double check the type to make sure caller hasn't sent us nonsense that
639 // will mess up our key queue. 639 // will mess up our key queue.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } 685 }
686 686
687 void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event, 687 void RenderWidgetHost::ForwardInputEvent(const WebInputEvent& input_event,
688 int event_size, 688 int event_size,
689 bool is_keyboard_shortcut) { 689 bool is_keyboard_shortcut) {
690 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardInputEvent"); 690 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardInputEvent");
691 691
692 if (!process_->HasConnection()) 692 if (!process_->HasConnection())
693 return; 693 return;
694 694
695 DCHECK(!process_->ignore_input_events()); 695 DCHECK(!process_->IgnoreInputEvents());
696 696
697 IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_); 697 IPC::Message* message = new ViewMsg_HandleInputEvent(routing_id_);
698 message->WriteData( 698 message->WriteData(
699 reinterpret_cast<const char*>(&input_event), event_size); 699 reinterpret_cast<const char*>(&input_event), event_size);
700 // |is_keyboard_shortcut| only makes sense for RawKeyDown events. 700 // |is_keyboard_shortcut| only makes sense for RawKeyDown events.
701 if (input_event.type == WebInputEvent::RawKeyDown) 701 if (input_event.type == WebInputEvent::RawKeyDown)
702 message->WriteBool(is_keyboard_shortcut); 702 message->WriteBool(is_keyboard_shortcut);
703 input_event_start_time_ = TimeTicks::Now(); 703 input_event_start_time_ = TimeTicks::Now();
704 Send(message); 704 Send(message);
705 705
706 // Any non-wheel input event cancels pending wheel events. 706 // Any non-wheel input event cancels pending wheel events.
707 if (input_event.type != WebInputEvent::MouseWheel) 707 if (input_event.type != WebInputEvent::MouseWheel)
708 coalesced_mouse_wheel_events_.clear(); 708 coalesced_mouse_wheel_events_.clear();
709 709
710 // Any input event cancels a pending mouse move event. Note that 710 // Any input event cancels a pending mouse move event. Note that
711 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event| 711 // |next_mouse_move_| possibly owns |input_event|, so don't use |input_event|
712 // after this line. 712 // after this line.
713 next_mouse_move_.reset(); 713 next_mouse_move_.reset();
714 714
715 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs)); 715 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kHungRendererDelayMs));
716 } 716 }
717 717
718 void RenderWidgetHost::ForwardTouchEvent( 718 void RenderWidgetHost::ForwardTouchEvent(
719 const WebKit::WebTouchEvent& touch_event) { 719 const WebKit::WebTouchEvent& touch_event) {
720 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent"); 720 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardTouchEvent");
721 if (ignore_input_events_ || process_->ignore_input_events()) 721 if (ignore_input_events_ || process_->IgnoreInputEvents())
722 return; 722 return;
723 723
724 if (touch_event.type == WebInputEvent::TouchMove && 724 if (touch_event.type == WebInputEvent::TouchMove &&
725 touch_move_pending_) { 725 touch_move_pending_) {
726 touch_event_is_queued_ = true; 726 touch_event_is_queued_ = true;
727 queued_touch_event_ = touch_event; 727 queued_touch_event_ = touch_event;
728 return; 728 return;
729 } 729 }
730 730
731 if (touch_event.type == WebInputEvent::TouchMove) 731 if (touch_event.type == WebInputEvent::TouchMove)
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 pending_mouse_lock_request_ = false; 1469 pending_mouse_lock_request_ = false;
1470 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { 1470 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) {
1471 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 1471 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
1472 return false; 1472 return false;
1473 } else { 1473 } else {
1474 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); 1474 Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
1475 return true; 1475 return true;
1476 } 1476 }
1477 } 1477 }
1478 } 1478 }
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