[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 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_RENDERER_RENDER_FRAME_PROXY_H_ |
| 6 | #define CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 10 | #include "content/common/content_export.h" |
| 11 | #include "ipc/ipc_listener.h" |
| 12 | #include "ipc/ipc_sender.h" |
| 13 | |
| 14 | #include "third_party/WebKit/public/web/WebFrameClient.h" |
| 15 | #include "third_party/WebKit/public/web/WebRemoteFrame.h" |
| 16 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 17 | struct FrameMsg_BuffersSwapped_Params; |
| 18 | struct FrameMsg_CompositorFrameSwapped_Params; |
| 19 | |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 20 | namespace content { |
| 21 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 22 | class ChildFrameCompositingHelper; |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 23 | class RenderFrameImpl; |
| 24 | class RenderViewImpl; |
| 25 | |
| 26 | // When a page's frames are rendered by multiple processes, each renderer has a |
| 27 | // full copy of the frame tree. It has full RenderFrames for the frames it is |
| 28 | // responsible for rendering and placeholder objects for frames rendered by |
| 29 | // other processes. This class is the renderer-side object for the placeholder. |
| 30 | // RenderFrameProxy allows us to keep existing window references valid over |
| 31 | // cross-process navigations and route cross-site asynchronous JavaScript calls, |
| 32 | // such as postMessage. |
| 33 | // |
| 34 | // For now, RenderFrameProxy is created when RenderFrame is swapped out. It |
| 35 | // acts as a wrapper and is used for sending and receiving IPC messages. It is |
| 36 | // deleted when the RenderFrame is swapped back in or the node of the frame |
| 37 | // tree is deleted. |
| 38 | // |
| 39 | // Long term, RenderFrameProxy will be created to replace the RenderFrame in the |
| 40 | // frame tree and the RenderFrame will be deleted after its unload handler has |
| 41 | // finished executing. It will still be responsible for routing IPC messages |
| 42 | // which are valid for cross-site interactions between frames. |
| 43 | // RenderFrameProxy will be deleted when the node in the frame tree is deleted |
| 44 | // or when navigating the frame causes it to return to this process and a new |
| 45 | // RenderFrame is created for it. |
| 46 | class CONTENT_EXPORT RenderFrameProxy |
| 47 | : public IPC::Listener, |
| 48 | public IPC::Sender, |
| 49 | NON_EXPORTED_BASE(public blink::WebFrameClient) { |
| 50 | public: |
| 51 | static RenderFrameProxy* CreateFrameProxy(int routing_id, |
| 52 | int frame_routing_id); |
| 53 | |
| 54 | // Returns the RenderFrameProxy for the given routing ID. |
| 55 | static RenderFrameProxy* FromRoutingID(int routing_id); |
| 56 | |
| 57 | virtual ~RenderFrameProxy(); |
| 58 | |
| 59 | // IPC::Sender |
| 60 | virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 61 | |
| 62 | RenderFrameImpl* render_frame() { |
| 63 | return render_frame_; |
| 64 | } |
| 65 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 66 | // Out-of-process child frames receive a signal from RenderWidgetCompositor |
| 67 | // when a compositor frame has committed. |
| 68 | void DidCommitCompositorFrame(); |
| 69 | |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 70 | private: |
| 71 | RenderFrameProxy(int routing_id, int frame_routing_id); |
| 72 | |
| 73 | // IPC::Listener |
| 74 | virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 75 | |
| 76 | // IPC handlers |
| 77 | void OnDeleteProxy(); |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 78 | void OnChildFrameProcessGone(); |
| 79 | void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params); |
| 80 | void OnCompositorFrameSwapped(const IPC::Message& message); |
| 81 | |
| 82 | blink::WebFrame* GetWebFrame(); |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 83 | |
| 84 | int routing_id_; |
| 85 | int frame_routing_id_; |
| 86 | RenderFrameImpl* render_frame_; |
| 87 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 88 | scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
| 89 | |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 90 | DISALLOW_COPY_AND_ASSIGN(RenderFrameProxy); |
| 91 | }; |
| 92 | |
| 93 | } // namespace |
| 94 | |
| 95 | #endif // CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ |