OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_RENDERER_RENDER_FRAME_PROXY_H_ | 5 #ifndef CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ |
6 #define CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ | 6 #define CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // finished executing. It will still be responsible for routing IPC messages | 41 // finished executing. It will still be responsible for routing IPC messages |
42 // which are valid for cross-site interactions between frames. | 42 // which are valid for cross-site interactions between frames. |
43 // RenderFrameProxy will be deleted when the node in the frame tree is deleted | 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 | 44 // or when navigating the frame causes it to return to this process and a new |
45 // RenderFrame is created for it. | 45 // RenderFrame is created for it. |
46 class CONTENT_EXPORT RenderFrameProxy | 46 class CONTENT_EXPORT RenderFrameProxy |
47 : public IPC::Listener, | 47 : public IPC::Listener, |
48 public IPC::Sender, | 48 public IPC::Sender, |
49 NON_EXPORTED_BASE(public blink::WebFrameClient) { | 49 NON_EXPORTED_BASE(public blink::WebFrameClient) { |
50 public: | 50 public: |
| 51 // This method should be used to create a RenderFrameProxy, which will replace |
| 52 // an existing RenderFrame during its cross-process navigation from the |
| 53 // current process to a different one. |routing_id| will be ID of the newly |
| 54 // created RenderFrameProxy. |frame_to_replace| is the frame that the new |
| 55 // proxy will eventually swap places with. |
| 56 static RenderFrameProxy* CreateProxyToReplaceFrame( |
| 57 RenderFrameImpl* frame_to_replace, |
| 58 int routing_id); |
| 59 |
| 60 // This method should be used to create a RenderFrameProxy, when there isn't |
| 61 // an existing RenderFrame. It should be called to construct a local |
| 62 // representation of a RenderFrame that has been created in another process -- |
| 63 // for example, after a cross-process navigation or after the addition of a |
| 64 // new frame local to some other process. |routing_id| will be the ID of the |
| 65 // newly created RenderFrameProxy. |parent_routing_id| is the routing ID of |
| 66 // the RenderFrameProxy to which the new frame is parented. |
| 67 // |render_view_routing_id| identifies the RenderView to be associated with |
| 68 // this frame. |
| 69 // |
| 70 // |parent_routing_id| always identifies a RenderFrameProxy (never a |
| 71 // RenderFrame) because a new child of a local frame should always start out |
| 72 // as a frame, not a proxy. |
51 static RenderFrameProxy* CreateFrameProxy(int routing_id, | 73 static RenderFrameProxy* CreateFrameProxy(int routing_id, |
52 int frame_routing_id); | 74 int parent_routing_id, |
| 75 int render_view_routing_id); |
53 | 76 |
54 // Returns the RenderFrameProxy for the given routing ID. | 77 // Returns the RenderFrameProxy for the given routing ID. |
55 static RenderFrameProxy* FromRoutingID(int routing_id); | 78 static RenderFrameProxy* FromRoutingID(int routing_id); |
56 | 79 |
| 80 // Returns the RenderFrameProxy given a WebFrame. |
| 81 static RenderFrameProxy* FromWebFrame(blink::WebFrame* web_frame); |
| 82 |
57 virtual ~RenderFrameProxy(); | 83 virtual ~RenderFrameProxy(); |
58 | 84 |
59 // IPC::Sender | 85 // IPC::Sender |
60 virtual bool Send(IPC::Message* msg) OVERRIDE; | 86 virtual bool Send(IPC::Message* msg) OVERRIDE; |
61 | 87 |
62 RenderFrameImpl* render_frame() { | |
63 return render_frame_; | |
64 } | |
65 | |
66 // Out-of-process child frames receive a signal from RenderWidgetCompositor | 88 // Out-of-process child frames receive a signal from RenderWidgetCompositor |
67 // when a compositor frame has committed. | 89 // when a compositor frame has committed. |
68 void DidCommitCompositorFrame(); | 90 void DidCommitCompositorFrame(); |
69 | 91 |
| 92 int routing_id() { return routing_id_; } |
| 93 RenderViewImpl* render_view() { return render_view_; } |
| 94 blink::WebRemoteFrame* web_frame() { return web_frame_; } |
| 95 |
70 private: | 96 private: |
71 RenderFrameProxy(int routing_id, int frame_routing_id); | 97 RenderFrameProxy(int routing_id, int frame_routing_id); |
72 | 98 |
| 99 void Init(blink::WebRemoteFrame* frame, RenderViewImpl* render_view); |
| 100 |
73 // IPC::Listener | 101 // IPC::Listener |
74 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 102 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
75 | 103 |
76 // IPC handlers | 104 // IPC handlers |
77 void OnDeleteProxy(); | 105 void OnDeleteProxy(); |
78 void OnChildFrameProcessGone(); | 106 void OnChildFrameProcessGone(); |
79 void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params); | 107 void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params); |
80 void OnCompositorFrameSwapped(const IPC::Message& message); | 108 void OnCompositorFrameSwapped(const IPC::Message& message); |
81 | 109 |
82 blink::WebFrame* GetWebFrame(); | 110 // The routing ID by which this RenderFrameProxy is known. |
| 111 const int routing_id_; |
83 | 112 |
84 int routing_id_; | 113 // The routing ID of the local RenderFrame (if any) which this |
85 int frame_routing_id_; | 114 // RenderFrameProxy is meant to replace in the frame tree. |
86 RenderFrameImpl* render_frame_; | 115 const int frame_routing_id_; |
87 | 116 |
| 117 // Stores the WebRemoteFrame we are associated with. |
| 118 blink::WebRemoteFrame* web_frame_; |
88 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; | 119 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
89 | 120 |
| 121 RenderViewImpl* render_view_; |
| 122 |
90 DISALLOW_COPY_AND_ASSIGN(RenderFrameProxy); | 123 DISALLOW_COPY_AND_ASSIGN(RenderFrameProxy); |
91 }; | 124 }; |
92 | 125 |
93 } // namespace | 126 } // namespace |
94 | 127 |
95 #endif // CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ | 128 #endif // CONTENT_RENDERER_RENDER_FRAME_PROXY_H_ |
OLD | NEW |