| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 23 #include "base/process/kill.h" | 23 #include "base/process/kill.h" |
| 24 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "base/timer/elapsed_timer.h" | 26 #include "base/timer/elapsed_timer.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
| 28 #include "cc/resources/shared_bitmap.h" | 29 #include "cc/resources/shared_bitmap.h" |
| 29 #include "cc/surfaces/frame_sink_id.h" | 30 #include "cc/surfaces/frame_sink_id.h" |
| 30 #include "content/browser/renderer_host/event_with_latency_info.h" | 31 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 31 #include "content/browser/renderer_host/input/input_ack_handler.h" | 32 #include "content/browser/renderer_host/input/input_ack_handler.h" |
| 32 #include "content/browser/renderer_host/input/input_router_client.h" | 33 #include "content/browser/renderer_host/input/input_router_client.h" |
| 33 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" | 34 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" |
| 34 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 35 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 35 #include "content/browser/renderer_host/input/touch_emulator_client.h" | 36 #include "content/browser/renderer_host/input/touch_emulator_client.h" |
| 36 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 37 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 37 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 38 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 38 #include "content/common/drag_event_source_info.h" | 39 #include "content/common/drag_event_source_info.h" |
| 39 #include "content/common/input/input_event_ack_state.h" | 40 #include "content/common/input/input_event_ack_state.h" |
| 40 #include "content/common/input/synthetic_gesture_packet.h" | 41 #include "content/common/input/synthetic_gesture_packet.h" |
| 41 #include "content/common/view_message_enums.h" | 42 #include "content/common/view_message_enums.h" |
| 42 #include "content/public/browser/render_widget_host.h" | 43 #include "content/public/browser/render_widget_host.h" |
| 43 #include "content/public/common/page_zoom.h" | 44 #include "content/public/common/page_zoom.h" |
| 44 #include "content/public/common/url_constants.h" | 45 #include "content/public/common/url_constants.h" |
| 45 #include "ipc/ipc_listener.h" | 46 #include "ipc/ipc_listener.h" |
| 47 #include "mojo/public/cpp/bindings/binding.h" |
| 46 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 48 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
| 47 #include "ui/base/ime/text_input_mode.h" | 49 #include "ui/base/ime/text_input_mode.h" |
| 48 #include "ui/base/ime/text_input_type.h" | 50 #include "ui/base/ime/text_input_type.h" |
| 49 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 51 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 50 #include "ui/gfx/native_widget_types.h" | 52 #include "ui/gfx/native_widget_types.h" |
| 51 #include "ui/latency/latency_info.h" | 53 #include "ui/latency/latency_info.h" |
| 52 | 54 |
| 53 class SkBitmap; | 55 class SkBitmap; |
| 54 struct FrameHostMsg_HittestData_Params; | 56 struct FrameHostMsg_HittestData_Params; |
| 55 struct ViewHostMsg_SelectionBounds_Params; | 57 struct ViewHostMsg_SelectionBounds_Params; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 86 class TimeoutMonitor; | 88 class TimeoutMonitor; |
| 87 class TouchEmulator; | 89 class TouchEmulator; |
| 88 class WebCursor; | 90 class WebCursor; |
| 89 struct EditCommand; | 91 struct EditCommand; |
| 90 struct ResizeParams; | 92 struct ResizeParams; |
| 91 struct ScreenInfo; | 93 struct ScreenInfo; |
| 92 struct TextInputState; | 94 struct TextInputState; |
| 93 | 95 |
| 94 // This implements the RenderWidgetHost interface that is exposed to | 96 // This implements the RenderWidgetHost interface that is exposed to |
| 95 // embedders of content, and adds things only visible to content. | 97 // embedders of content, and adds things only visible to content. |
| 96 class CONTENT_EXPORT RenderWidgetHostImpl : public RenderWidgetHost, | 98 class CONTENT_EXPORT RenderWidgetHostImpl |
| 97 public InputRouterClient, | 99 : public RenderWidgetHost, |
| 98 public InputAckHandler, | 100 public InputRouterClient, |
| 99 public TouchEmulatorClient, | 101 public InputAckHandler, |
| 100 public IPC::Listener { | 102 public TouchEmulatorClient, |
| 103 public NON_EXPORTED_BASE(cc::mojom::MojoCompositorFrameSink), |
| 104 public IPC::Listener { |
| 101 public: | 105 public: |
| 102 // |routing_id| must not be MSG_ROUTING_NONE. | 106 // |routing_id| must not be MSG_ROUTING_NONE. |
| 103 // If this object outlives |delegate|, DetachDelegate() must be called when | 107 // If this object outlives |delegate|, DetachDelegate() must be called when |
| 104 // |delegate| goes away. | 108 // |delegate| goes away. |
| 105 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 109 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| 106 RenderProcessHost* process, | 110 RenderProcessHost* process, |
| 107 int32_t routing_id, | 111 int32_t routing_id, |
| 108 bool hidden); | 112 bool hidden); |
| 109 ~RenderWidgetHostImpl() override; | 113 ~RenderWidgetHostImpl() override; |
| 110 | 114 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); | 450 void ScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); |
| 447 | 451 |
| 448 // Requests the renderer to move the caret selection towards the point. | 452 // Requests the renderer to move the caret selection towards the point. |
| 449 void MoveCaret(const gfx::Point& point); | 453 void MoveCaret(const gfx::Point& point); |
| 450 | 454 |
| 451 // Called when the reponse to a pending mouse lock request has arrived. | 455 // Called when the reponse to a pending mouse lock request has arrived. |
| 452 // Returns true if |allowed| is true and the mouse has been successfully | 456 // Returns true if |allowed| is true and the mouse has been successfully |
| 453 // locked. | 457 // locked. |
| 454 bool GotResponseToLockMouseRequest(bool allowed); | 458 bool GotResponseToLockMouseRequest(bool allowed); |
| 455 | 459 |
| 456 // Called by the view in response to OnSwapCompositorFrame. | |
| 457 void SendReclaimCompositorResources( | |
| 458 bool is_swap_ack, | |
| 459 const cc::ReturnedResourceArray& resources); | |
| 460 | |
| 461 void set_allow_privileged_mouse_lock(bool allow) { | 460 void set_allow_privileged_mouse_lock(bool allow) { |
| 462 allow_privileged_mouse_lock_ = allow; | 461 allow_privileged_mouse_lock_ = allow; |
| 463 } | 462 } |
| 464 | 463 |
| 465 // Resets state variables related to tracking pending size and painting. | 464 // Resets state variables related to tracking pending size and painting. |
| 466 // | 465 // |
| 467 // We need to reset these flags when we want to repaint the contents of | 466 // We need to reset these flags when we want to repaint the contents of |
| 468 // browser plugin in this RWH. Resetting these flags will ensure we ignore | 467 // browser plugin in this RWH. Resetting these flags will ensure we ignore |
| 469 // any previous pending acks that are not relevant upon repaint. | 468 // any previous pending acks that are not relevant upon repaint. |
| 470 void ResetSizeAndRepaintPendingFlags(); | 469 void ResetSizeAndRepaintPendingFlags(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 // true, RenderWidget will respond immediately. If |monitor_updates| is true, | 564 // true, RenderWidget will respond immediately. If |monitor_updates| is true, |
| 566 // then RenderWidget sends updates for each compositor frame when there are | 565 // then RenderWidget sends updates for each compositor frame when there are |
| 567 // changes, or when the text selection changes inside a frame. If both fields | 566 // changes, or when the text selection changes inside a frame. If both fields |
| 568 // are false, RenderWidget will not send any updates. To avoid sending | 567 // are false, RenderWidget will not send any updates. To avoid sending |
| 569 // unnecessary IPCs to RenderWidget (e.g., asking for monitor updates while | 568 // unnecessary IPCs to RenderWidget (e.g., asking for monitor updates while |
| 570 // we are already receiving updates), when | 569 // we are already receiving updates), when |
| 571 // |monitoring_composition_info_| == |monitor_updates| no IPC is sent to the | 570 // |monitoring_composition_info_| == |monitor_updates| no IPC is sent to the |
| 572 // renderer unless it is for an immediate request. | 571 // renderer unless it is for an immediate request. |
| 573 void RequestCompositionUpdates(bool immediate_request, bool monitor_updates); | 572 void RequestCompositionUpdates(bool immediate_request, bool monitor_updates); |
| 574 | 573 |
| 575 // Submits the frame received from RenderWidget. | 574 void RequestMojoCompositorFrameSink( |
| 576 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, | 575 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 577 cc::CompositorFrame frame); | 576 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 578 | 577 |
| 579 const cc::CompositorFrameMetadata& last_frame_metadata() { | 578 const cc::CompositorFrameMetadata& last_frame_metadata() { |
| 580 return last_frame_metadata_; | 579 return last_frame_metadata_; |
| 581 } | 580 } |
| 582 | 581 |
| 582 // cc::mojom::MojoCompositorFrameSink implementation. |
| 583 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
| 584 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, |
| 585 cc::CompositorFrame frame) override; |
| 586 void BeginFrameDidNotSwap(const cc::BeginFrameAck& ack) override; |
| 587 void EvictFrame() override {} |
| 588 |
| 583 protected: | 589 protected: |
| 584 // --------------------------------------------------------------------------- | 590 // --------------------------------------------------------------------------- |
| 585 // The following method is overridden by RenderViewHost to send upwards to | 591 // The following method is overridden by RenderViewHost to send upwards to |
| 586 // its delegate. | 592 // its delegate. |
| 587 | 593 |
| 588 // Callback for notification that we failed to receive any rendered graphics | 594 // Callback for notification that we failed to receive any rendered graphics |
| 589 // from a newly loaded page. Used for testing. | 595 // from a newly loaded page. Used for testing. |
| 590 virtual void NotifyNewContentRenderingTimeoutForTesting() {} | 596 virtual void NotifyNewContentRenderingTimeoutForTesting() {} |
| 591 | 597 |
| 592 // --------------------------------------------------------------------------- | 598 // --------------------------------------------------------------------------- |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 | 637 |
| 632 void OnGpuSwapBuffersCompletedInternal(const ui::LatencyInfo& latency_info); | 638 void OnGpuSwapBuffersCompletedInternal(const ui::LatencyInfo& latency_info); |
| 633 | 639 |
| 634 // IPC message handlers | 640 // IPC message handlers |
| 635 void OnRenderProcessGone(int status, int error_code); | 641 void OnRenderProcessGone(int status, int error_code); |
| 636 void OnClose(); | 642 void OnClose(); |
| 637 void OnUpdateScreenRectsAck(); | 643 void OnUpdateScreenRectsAck(); |
| 638 void OnRequestMove(const gfx::Rect& pos); | 644 void OnRequestMove(const gfx::Rect& pos); |
| 639 void OnSetTooltipText(const base::string16& tooltip_text, | 645 void OnSetTooltipText(const base::string16& tooltip_text, |
| 640 blink::WebTextDirection text_direction_hint); | 646 blink::WebTextDirection text_direction_hint); |
| 641 bool OnSwapCompositorFrame(const IPC::Message& message); | |
| 642 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); | 647 void OnBeginFrameDidNotSwap(const cc::BeginFrameAck& ack); |
| 643 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 648 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
| 644 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); | 649 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); |
| 645 void OnSetCursor(const WebCursor& cursor); | 650 void OnSetCursor(const WebCursor& cursor); |
| 646 void OnTextInputStateChanged(const TextInputState& params); | 651 void OnTextInputStateChanged(const TextInputState& params); |
| 647 | 652 |
| 648 void OnImeCompositionRangeChanged( | 653 void OnImeCompositionRangeChanged( |
| 649 const gfx::Range& range, | 654 const gfx::Range& range, |
| 650 const std::vector<gfx::Rect>& character_bounds); | 655 const std::vector<gfx::Rect>& character_bounds); |
| 651 void OnImeCancelComposition(); | 656 void OnImeCancelComposition(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; | 956 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; |
| 952 #endif | 957 #endif |
| 953 | 958 |
| 954 // These information are used to verify that the renderer does not misbehave | 959 // These information are used to verify that the renderer does not misbehave |
| 955 // when it comes to allocating LocalSurfaceIds. If frame size or device scale | 960 // when it comes to allocating LocalSurfaceIds. If frame size or device scale |
| 956 // factor change, a new LocalSurfaceId must be created. | 961 // factor change, a new LocalSurfaceId must be created. |
| 957 cc::LocalSurfaceId last_local_surface_id_; | 962 cc::LocalSurfaceId last_local_surface_id_; |
| 958 gfx::Size last_frame_size_; | 963 gfx::Size last_frame_size_; |
| 959 float last_device_scale_factor_; | 964 float last_device_scale_factor_; |
| 960 | 965 |
| 961 // Each instance of RendererCompositorFrameSink has an ID that we keep track | 966 mojo::Binding<cc::mojom::MojoCompositorFrameSink> |
| 962 // of so we can tell when a new instance has been created for the purpose of | 967 compositor_frame_sink_binding_; |
| 963 // not returning stale resources. | 968 cc::mojom::MojoCompositorFrameSinkClientPtr renderer_compositor_frame_sink_; |
| 964 uint32_t last_compositor_frame_sink_id_ = 0; | |
| 965 | 969 |
| 966 cc::CompositorFrameMetadata last_frame_metadata_; | 970 cc::CompositorFrameMetadata last_frame_metadata_; |
| 967 | 971 |
| 968 // Last non-zero frame token received from the renderer. Any swap messsages | 972 // Last non-zero frame token received from the renderer. Any swap messsages |
| 969 // having a token less than or equal to this value will be processed. | 973 // having a token less than or equal to this value will be processed. |
| 970 uint32_t last_received_frame_token_ = 0; | 974 uint32_t last_received_frame_token_ = 0; |
| 971 | 975 |
| 972 // List of all swap messages that their corresponding frames have not arrived. | 976 // List of all swap messages that their corresponding frames have not arrived. |
| 973 // Sorted by frame token. | 977 // Sorted by frame token. |
| 974 std::queue<std::pair<uint32_t, std::vector<IPC::Message>>> queued_messages_; | 978 std::queue<std::pair<uint32_t, std::vector<IPC::Message>>> queued_messages_; |
| 975 | 979 |
| 976 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 980 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
| 977 | 981 |
| 978 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 982 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
| 979 }; | 983 }; |
| 980 | 984 |
| 981 } // namespace content | 985 } // namespace content |
| 982 | 986 |
| 983 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 987 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| OLD | NEW |