cross_process_frame_connector.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_ 6#define CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_ 7 8#include "cc/output/compositor_frame.h" 9#include "ui/gfx/rect.h" 10 11namespace blink { 12class WebInputEvent; 13} 14 15namespace IPC { 16class Message; 17} 18 19struct FrameHostMsg_BuffersSwappedACK_Params; 20struct FrameHostMsg_CompositorFrameSwappedACK_Params; 21struct FrameHostMsg_ReclaimCompositorResources_Params; 22struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; 23 24namespace content { 25class RenderFrameHostImpl; 26class RenderWidgetHostImpl; 27class RenderWidgetHostViewChildFrame; 28 29// CrossProcessFrameConnector provides the platform view abstraction for 30// RenderWidgetHostViewChildFrame allowing RWHVChildFrame to remain ignorant 31// of RenderFrameHost. 32// 33// The RenderWidgetHostView of an out-of-process child frame needs to 34// communicate with the swapped out RenderFrameHost representing this frame 35// in the process of the parent frame. For example, assume you have this page: 36// 37// ----------------- 38// | frame 1 | 39// | ----------- | 40// | | frame 2 | | 41// | ----------- | 42// ----------------- 43// 44// If frames 1 and 2 are in process A and B, there are 4 RenderFrameHosts: 45// A1 - RFH for frame 1 in process A 46// B1 - Swapped out RFH for frame 1 in process B 47// A2 - Swapped out RFH for frame 2 in process A 48// B2 - RFH for frame 2 in process B 49// 50// B2, having a parent frame in a different process, will have a 51// RenderWidgetHostViewChildFrame. This RenderWidgetHostViewChildFrame needs 52// to communicate with A2 because the embedding process is an abstract 53// for the child frame -- it needs information necessary for compositing child 54// frame textures, and also can pass platform messages such as view resizing. 55// CrossProcessFrameConnector bridges between B2's 56// RenderWidgetHostViewChildFrame and A2 to allow for this communication. 57// (Note: B1 is only mentioned for completeness. It is not needed in this 58// example.) 59// 60// CrossProcessFrameConnector objects are owned by the child frame's 61// RenderFrameHostManager. When a child frame swaps, SetChildFrameView() is 62// called to update to the new view. 63// 64class CrossProcessFrameConnector { 65 public: 66 // |frame_proxy_in_parent_renderer| corresponds to A2 in the example above. 67 explicit CrossProcessFrameConnector( 68 RenderFrameHostImpl* frame_proxy_in_parent_renderer); 69 virtual ~CrossProcessFrameConnector(); 70 71 bool OnMessageReceived(const IPC::Message &msg); 72 73 // |view| corresponds to B2's RenderWidgetHostViewChildFrame in the example 74 // above. 75 void set_view(RenderWidgetHostViewChildFrame* view); 76 77 void RenderProcessGone(); 78 79 // 'Platform' functionality exposed to RenderWidgetHostViewChildFrame. 80 // These methods can forward messages to the child frame proxy in the parent 81 // frame's renderer or attempt to handle them within the browser process. 82 void ChildFrameBuffersSwapped( 83 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, 84 int gpu_host_id); 85 86 void ChildFrameCompositorFrameSwapped(uint32 output_surface_id, 87 int host_id, 88 int route_id, 89 scoped_ptr<cc::CompositorFrame> frame); 90 91 gfx::Rect ChildFrameRect(); 92 93 private: 94 // Handlers for messages received from the parent frame. 95 void OnBuffersSwappedACK( 96 const FrameHostMsg_BuffersSwappedACK_Params& params); 97 void OnCompositorFrameSwappedACK( 98 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); 99 void OnReclaimCompositorResources( 100 const FrameHostMsg_ReclaimCompositorResources_Params& params); 101 void OnForwardInputEvent(const blink::WebInputEvent* event); 102 103 // The RenderFrameHost that routes messages to the parent frame's renderer 104 // process. 105 // TODO(kenrb): The type becomes RenderFrameProxyHost when that class comes 106 // to exist. 107 RenderFrameHostImpl* frame_proxy_in_parent_renderer_; 108 109 // The RenderWidgetHostView for the frame. Initially NULL. 110 RenderWidgetHostViewChildFrame* view_; 111 112 gfx::Rect child_frame_rect_; 113}; 114 115} // namespace content 116 117#endif // CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_ 118 119