| 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 // Use RenderWidgetHostImpl::From(rwh) to downcast a | 110 // Use RenderWidgetHostImpl::From(rwh) to downcast a |
| 111 // RenderWidgetHost to a RenderWidgetHostImpl. Internally, this | 111 // RenderWidgetHost to a RenderWidgetHostImpl. Internally, this |
| 112 // uses RenderWidgetHost::AsRenderWidgetHostImpl(). | 112 // uses RenderWidgetHost::AsRenderWidgetHostImpl(). |
| 113 static RenderWidgetHostImpl* From(RenderWidgetHost* rwh); | 113 static RenderWidgetHostImpl* From(RenderWidgetHost* rwh); |
| 114 | 114 |
| 115 void set_hung_renderer_delay(const base::TimeDelta& delay) { | 115 void set_hung_renderer_delay(const base::TimeDelta& delay) { |
| 116 hung_renderer_delay_ = delay; | 116 hung_renderer_delay_ = delay; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void set_new_content_rendering_delay_for_testing( |
| 120 const base::TimeDelta& delay) { |
| 121 new_content_rendering_delay_ = delay; |
| 122 } |
| 123 |
| 119 // RenderWidgetHost implementation. | 124 // RenderWidgetHost implementation. |
| 120 void UpdateTextDirection(blink::WebTextDirection direction) override; | 125 void UpdateTextDirection(blink::WebTextDirection direction) override; |
| 121 void NotifyTextDirection() override; | 126 void NotifyTextDirection() override; |
| 122 void Focus() override; | 127 void Focus() override; |
| 123 void Blur() override; | 128 void Blur() override; |
| 124 void SetActive(bool active) override; | 129 void SetActive(bool active) override; |
| 125 void CopyFromBackingStore(const gfx::Rect& src_rect, | 130 void CopyFromBackingStore(const gfx::Rect& src_rect, |
| 126 const gfx::Size& accelerated_dst_size, | 131 const gfx::Size& accelerated_dst_size, |
| 127 ReadbackRequestCallback& callback, | 132 ReadbackRequestCallback& callback, |
| 128 const SkColorType preferred_color_type) override; | 133 const SkColorType preferred_color_type) override; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 256 |
| 252 // Starts a hang monitor timeout. If there's already a hang monitor timeout | 257 // Starts a hang monitor timeout. If there's already a hang monitor timeout |
| 253 // the new one will only fire if it has a shorter delay than the time | 258 // the new one will only fire if it has a shorter delay than the time |
| 254 // left on the existing timeouts. | 259 // left on the existing timeouts. |
| 255 void StartHangMonitorTimeout(base::TimeDelta delay); | 260 void StartHangMonitorTimeout(base::TimeDelta delay); |
| 256 | 261 |
| 257 // Stops all existing hang monitor timeouts and assumes the renderer is | 262 // Stops all existing hang monitor timeouts and assumes the renderer is |
| 258 // responsive. | 263 // responsive. |
| 259 void StopHangMonitorTimeout(); | 264 void StopHangMonitorTimeout(); |
| 260 | 265 |
| 266 // Starts the rendering timeout, which will clear displayed graphics if |
| 267 // a new compositor frame is not received before it expires. |
| 268 void StartNewContentRenderingTimeout(); |
| 269 |
| 270 // Stops the rendering timeout and prevents it from clearing any displayed |
| 271 // graphics. |
| 272 void StopNewContentRenderingTimeout(); |
| 273 |
| 261 // Forwards the given message to the renderer. These are called by the view | 274 // Forwards the given message to the renderer. These are called by the view |
| 262 // when it has received a message. | 275 // when it has received a message. |
| 263 void ForwardGestureEventWithLatencyInfo( | 276 void ForwardGestureEventWithLatencyInfo( |
| 264 const blink::WebGestureEvent& gesture_event, | 277 const blink::WebGestureEvent& gesture_event, |
| 265 const ui::LatencyInfo& ui_latency); | 278 const ui::LatencyInfo& ui_latency); |
| 266 void ForwardTouchEventWithLatencyInfo( | 279 void ForwardTouchEventWithLatencyInfo( |
| 267 const blink::WebTouchEvent& touch_event, | 280 const blink::WebTouchEvent& touch_event, |
| 268 const ui::LatencyInfo& ui_latency); | 281 const ui::LatencyInfo& ui_latency); |
| 269 void ForwardMouseEventWithLatencyInfo( | 282 void ForwardMouseEventWithLatencyInfo( |
| 270 const blink::WebMouseEvent& mouse_event, | 283 const blink::WebMouseEvent& mouse_event, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // Notification that the user has made some kind of input that could | 498 // Notification that the user has made some kind of input that could |
| 486 // perform an action. The gestures that count are 1) any mouse down | 499 // perform an action. The gestures that count are 1) any mouse down |
| 487 // event and 2) enter or space key presses. | 500 // event and 2) enter or space key presses. |
| 488 virtual void OnUserGesture() {} | 501 virtual void OnUserGesture() {} |
| 489 | 502 |
| 490 // Callbacks for notification when the renderer becomes unresponsive to user | 503 // Callbacks for notification when the renderer becomes unresponsive to user |
| 491 // input events, and subsequently responsive again. | 504 // input events, and subsequently responsive again. |
| 492 virtual void NotifyRendererUnresponsive() {} | 505 virtual void NotifyRendererUnresponsive() {} |
| 493 virtual void NotifyRendererResponsive() {} | 506 virtual void NotifyRendererResponsive() {} |
| 494 | 507 |
| 508 // Callback for notification that we failed to receive any rendered graphics |
| 509 // from a newly loaded page. Used for testing. |
| 510 virtual void NotifyNewContentRenderingTimeoutForTesting() {} |
| 511 |
| 495 // Called when auto-resize resulted in the renderer size changing. | 512 // Called when auto-resize resulted in the renderer size changing. |
| 496 virtual void OnRenderAutoResized(const gfx::Size& new_size) {} | 513 virtual void OnRenderAutoResized(const gfx::Size& new_size) {} |
| 497 | 514 |
| 498 // --------------------------------------------------------------------------- | 515 // --------------------------------------------------------------------------- |
| 499 | 516 |
| 500 // RenderViewHost overrides this method to impose further restrictions on when | 517 // RenderViewHost overrides this method to impose further restrictions on when |
| 501 // to allow mouse lock. | 518 // to allow mouse lock. |
| 502 // Once the request is approved or rejected, GotResponseToLockMouseRequest() | 519 // Once the request is approved or rejected, GotResponseToLockMouseRequest() |
| 503 // will be called. | 520 // will be called. |
| 504 virtual void RequestToLockMouse(bool user_gesture, | 521 virtual void RequestToLockMouse(bool user_gesture, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 562 |
| 546 // A weak pointer to the view. The above pointer should be weak, but changing | 563 // A weak pointer to the view. The above pointer should be weak, but changing |
| 547 // that to be weak causes crashes on Android. | 564 // that to be weak causes crashes on Android. |
| 548 // TODO(ccameron): Fix this. | 565 // TODO(ccameron): Fix this. |
| 549 // http://crbug.com/404828 | 566 // http://crbug.com/404828 |
| 550 base::WeakPtr<RenderWidgetHostViewBase> view_weak_; | 567 base::WeakPtr<RenderWidgetHostViewBase> view_weak_; |
| 551 | 568 |
| 552 // This value indicates how long to wait before we consider a renderer hung. | 569 // This value indicates how long to wait before we consider a renderer hung. |
| 553 base::TimeDelta hung_renderer_delay_; | 570 base::TimeDelta hung_renderer_delay_; |
| 554 | 571 |
| 572 // This value indicates how long to wait for a new compositor frame from a |
| 573 // renderer process before clearing any previously displayed content. |
| 574 base::TimeDelta new_content_rendering_delay_; |
| 575 |
| 555 private: | 576 private: |
| 556 friend class MockRenderWidgetHost; | 577 friend class MockRenderWidgetHost; |
| 557 | 578 |
| 558 // Tell this object to destroy itself. | 579 // Tell this object to destroy itself. |
| 559 void Destroy(); | 580 void Destroy(); |
| 560 | 581 |
| 561 // Called by |hang_monitor_timeout_| on delayed response from the renderer. | 582 // Called by |hang_monitor_timeout_| on delayed response from the renderer. |
| 562 void RendererIsUnresponsive(); | 583 void RendererIsUnresponsive(); |
| 563 | 584 |
| 585 // Called by |new_content_rendering_timeout_| if a renderer has loaded new |
| 586 // content but failed to produce a compositor frame in a defined time. |
| 587 void ClearDisplayedGraphics(); |
| 588 |
| 564 // Called if we know the renderer is responsive. When we currently think the | 589 // Called if we know the renderer is responsive. When we currently think the |
| 565 // renderer is unresponsive, this will clear that state and call | 590 // renderer is unresponsive, this will clear that state and call |
| 566 // NotifyRendererResponsive. | 591 // NotifyRendererResponsive. |
| 567 void RendererIsResponsive(); | 592 void RendererIsResponsive(); |
| 568 | 593 |
| 569 // Routines used to send the RenderWidget its screen color profile. | 594 // Routines used to send the RenderWidget its screen color profile. |
| 570 void DispatchColorProfile(); | 595 void DispatchColorProfile(); |
| 571 void SendColorProfile(); | 596 void SendColorProfile(); |
| 572 | 597 |
| 573 // IPC message handlers | 598 // IPC message handlers |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 808 |
| 784 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; | 809 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; |
| 785 | 810 |
| 786 scoped_ptr<TouchEmulator> touch_emulator_; | 811 scoped_ptr<TouchEmulator> touch_emulator_; |
| 787 | 812 |
| 788 // Receives and handles all input events. | 813 // Receives and handles all input events. |
| 789 scoped_ptr<InputRouter> input_router_; | 814 scoped_ptr<InputRouter> input_router_; |
| 790 | 815 |
| 791 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; | 816 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; |
| 792 | 817 |
| 818 scoped_ptr<TimeoutMonitor> new_content_rendering_timeout_; |
| 819 |
| 793 #if defined(OS_WIN) | 820 #if defined(OS_WIN) |
| 794 std::list<HWND> dummy_windows_for_activation_; | 821 std::list<HWND> dummy_windows_for_activation_; |
| 795 #endif | 822 #endif |
| 796 | 823 |
| 797 RenderWidgetHostLatencyTracker latency_tracker_; | 824 RenderWidgetHostLatencyTracker latency_tracker_; |
| 798 | 825 |
| 799 int next_browser_snapshot_id_; | 826 int next_browser_snapshot_id_; |
| 800 using PendingSnapshotMap = std::map<int, GetSnapshotFromBrowserCallback>; | 827 using PendingSnapshotMap = std::map<int, GetSnapshotFromBrowserCallback>; |
| 801 PendingSnapshotMap pending_browser_snapshots_; | 828 PendingSnapshotMap pending_browser_snapshots_; |
| 802 | 829 |
| 803 // Indicates whether a RenderFramehost has ownership, in which case this | 830 // Indicates whether a RenderFramehost has ownership, in which case this |
| 804 // object does not self destroy. | 831 // object does not self destroy. |
| 805 bool owned_by_render_frame_host_; | 832 bool owned_by_render_frame_host_; |
| 806 | 833 |
| 807 // Indicates whether this RenderWidgetHost thinks is focused. This is trying | 834 // Indicates whether this RenderWidgetHost thinks is focused. This is trying |
| 808 // to match what the renderer process knows. It is different from | 835 // to match what the renderer process knows. It is different from |
| 809 // RenderWidgetHostView::HasFocus in that in that the focus request may fail, | 836 // RenderWidgetHostView::HasFocus in that in that the focus request may fail, |
| 810 // causing HasFocus to return false when is_focused_ is true. | 837 // causing HasFocus to return false when is_focused_ is true. |
| 811 bool is_focused_; | 838 bool is_focused_; |
| 812 | 839 |
| 813 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 840 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
| 814 | 841 |
| 815 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 842 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
| 816 }; | 843 }; |
| 817 | 844 |
| 818 } // namespace content | 845 } // namespace content |
| 819 | 846 |
| 820 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 847 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| OLD | NEW |