IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / browser / frame_host / cross_process_frame_connector.h
blobe107accc156c39954093ba2132dee137bd2388b6
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"
11 namespace IPC {
12 class Message;
15 struct FrameHostMsg_BuffersSwappedACK_Params;
16 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
18 namespace content {
19 class RenderFrameHostImpl;
20 class RenderWidgetHostImpl;
21 class RenderWidgetHostViewChildFrame;
23 // CrossProcessFrameConnector provides the platform view abstraction for
24 // RenderWidgetHostViewChildFrame allowing RWHVChildFrame to remain ignorant
25 // of RenderFrameHost.
27 // The RenderWidgetHostView of an out-of-process child frame needs to
28 // communicate with the swapped out RenderFrameHost representing this frame
29 // in the process of the parent frame. For example, assume you have this page:
31 // -----------------
32 // | frame 1 |
33 // | ----------- |
34 // | | frame 2 | |
35 // | ----------- |
36 // -----------------
38 // If frames 1 and 2 are in process A and B, there are 4 RenderFrameHosts:
39 // A1 - RFH for frame 1 in process A
40 // B1 - Swapped out RFH for frame 1 in process B
41 // A2 - Swapped out RFH for frame 2 in process A
42 // B2 - RFH for frame 2 in process B
44 // B2, having a parent frame in a diferent process, will have a
45 // RenderWidgetHostViewChildFrame. This RenderWidgetHostViewChildFrame needs
46 // to communicate with A2 so that the painting logic in process A can
47 // composite B2's data with A1's. CrossProcessFrameConnector bridges between
48 // B2's RenderWidgetHostViewChildFrame and A2 to allow for this communication.
49 // (Note: B1 is only mentioned for completeness. It is not needed in this
50 // example.)
52 // CrossProcessFrameConnector objects are owned by the child frame's
53 // RenderFrameHostManager. When a child frame swaps, SetChildFrameView() is
54 // called to update to the new view.
56 // TODO(kenrb): Double-check this comment's accuracy.
57 class CrossProcessFrameConnector {
58 public:
59 // |frame_proxy_in_parent_renderer| corresponds to A2 in the example above.
60 explicit CrossProcessFrameConnector(
61 RenderFrameHostImpl* frame_proxy_in_parent_renderer);
62 virtual ~CrossProcessFrameConnector();
64 bool OnMessageReceived(const IPC::Message &msg);
66 // |view| corresponds to B2's RenderWidgetHostViewChildFrame in the example
67 // above.
68 void SetView(RenderWidgetHostViewChildFrame* view);
70 // 'Platform' functionality exposed to RenderWidgetHostViewChildFrame.
71 // These methods can forward messages to the child frame proxy in the parent
72 // frame renderer or attempt to handle them within the browser process.
73 void ChildFrameBuffersSwapped(
74 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
75 int gpu_host_id);
77 void ChildFrameCompositorFrameSwapped(
78 uint32 output_surface_id,
79 scoped_ptr<cc::CompositorFrame> frame);
81 gfx::Rect ChildFrameRect();
83 private:
84 // Handlers for messages received from the parent frame.
85 void OnBuffersSwappedACK(
86 const FrameHostMsg_BuffersSwappedACK_Params& params);
88 // The RenderFrameHost that routes messages to the parent frame's renderer
89 // process.
90 // TODO(kenrb): The type becomes RenderFrameProxyHost when that class comes
91 // to exist.
92 RenderFrameHostImpl* frame_proxy_in_parent_renderer_;
94 // The RenderWidgetHostView for the frame. Initially NULL.
95 RenderWidgetHostViewChildFrame* view_;
97 gfx::Rect child_frame_rect_;
100 } // namespace content
102 #endif // CONTENT_BROWSER_FRAME_HOST_CROSS_PROCESS_FRAME_CONNECTOR_H_