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.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_
6 #define CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_
8 #include "cc/output/compositor_frame.h"
9 #include "ui/gfx/rect.h"
19 struct FrameHostMsg_BuffersSwappedACK_Params
;
20 struct FrameHostMsg_CompositorFrameSwappedACK_Params
;
21 struct FrameHostMsg_ReclaimCompositorResources_Params
;
22 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params
;
25 class RenderFrameProxyHost
;
26 class RenderWidgetHostImpl
;
27 class RenderWidgetHostViewChildFrame
;
29 // CrossProcessFrameConnector provides the platform view abstraction for
30 // RenderWidgetHostViewChildFrame allowing RWHVChildFrame to remain ignorant
31 // of RenderFrameHost.
33 // The RenderWidgetHostView of an out-of-process child frame needs to
34 // communicate with the RenderFrameProxyHost representing this frame in the
35 // process of the parent frame. For example, assume you have this page:
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 - RFPH for frame 1 in process B
47 // A2 - RFPH for frame 2 in process A
48 // B2 - RFH for frame 2 in process B
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
60 // CrossProcessFrameConnector objects are owned by the RenderFrameProxyHost
61 // in the child frame's RenderFrameHostManager corresponding to the parent's
62 // SiteInstance, A2 in the picture above. When a child frame navigates in a new
63 // process, set_view() is called to update to the new view.
65 class CrossProcessFrameConnector
{
67 // |frame_proxy_in_parent_renderer| corresponds to A2 in the example above.
68 explicit CrossProcessFrameConnector(
69 RenderFrameProxyHost
* frame_proxy_in_parent_renderer
);
70 virtual ~CrossProcessFrameConnector();
72 bool OnMessageReceived(const IPC::Message
&msg
);
74 // |view| corresponds to B2's RenderWidgetHostViewChildFrame in the example
76 void set_view(RenderWidgetHostViewChildFrame
* view
);
77 RenderWidgetHostViewChildFrame
* get_view_for_testing() { return view_
; }
79 void RenderProcessGone();
81 // 'Platform' functionality exposed to RenderWidgetHostViewChildFrame.
82 // These methods can forward messages to the child frame proxy in the parent
83 // frame's renderer or attempt to handle them within the browser process.
84 void ChildFrameBuffersSwapped(
85 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params
& params
,
88 void ChildFrameCompositorFrameSwapped(uint32 output_surface_id
,
91 scoped_ptr
<cc::CompositorFrame
> frame
);
93 gfx::Rect
ChildFrameRect();
96 // Handlers for messages received from the parent frame.
97 void OnBuffersSwappedACK(
98 const FrameHostMsg_BuffersSwappedACK_Params
& params
);
99 void OnCompositorFrameSwappedACK(
100 const FrameHostMsg_CompositorFrameSwappedACK_Params
& params
);
101 void OnReclaimCompositorResources(
102 const FrameHostMsg_ReclaimCompositorResources_Params
& params
);
103 void OnForwardInputEvent(const blink::WebInputEvent
* event
);
104 void OnInitializeChildFrame(gfx::Rect frame_rect
, float scale_factor
);
106 void SetDeviceScaleFactor(float scale_factor
);
107 void SetSize(gfx::Rect frame_rect
);
109 // The RenderFrameProxyHost that routes messages to the parent frame's
111 RenderFrameProxyHost
* frame_proxy_in_parent_renderer_
;
113 // The RenderWidgetHostView for the frame. Initially NULL.
114 RenderWidgetHostViewChildFrame
* view_
;
116 gfx::Rect child_frame_rect_
;
117 float device_scale_factor_
;
120 } // namespace content
122 #endif // CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_