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 #include "content/browser/frame_host/render_frame_proxy_host.h" | 5 #include "content/browser/frame_host/render_frame_proxy_host.h" |
6 | 6 |
| 7 #include "content/browser/frame_host/frame_tree_node.h" |
7 #include "content/browser/frame_host/render_frame_host_impl.h" | 8 #include "content/browser/frame_host/render_frame_host_impl.h" |
8 #include "content/browser/site_instance_impl.h" | 9 #include "content/browser/site_instance_impl.h" |
| 10 #include "content/common/frame_messages.h" |
| 11 #include "ipc/ipc_message.h" |
9 | 12 |
10 namespace content { | 13 namespace content { |
11 | 14 |
12 RenderFrameProxyHost::RenderFrameProxyHost( | 15 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, |
13 scoped_ptr<RenderFrameHostImpl> render_frame_host) | 16 FrameTreeNode* frame_tree_node) |
14 : site_instance_(render_frame_host->GetSiteInstance()), | 17 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), |
15 render_frame_host_(render_frame_host.Pass()) {} | 18 site_instance_(site_instance), |
| 19 frame_tree_node_(frame_tree_node) { |
| 20 GetProcess()->AddRoute(routing_id_, this); |
| 21 } |
16 | 22 |
17 RenderFrameProxyHost::~RenderFrameProxyHost() {} | 23 RenderFrameProxyHost::~RenderFrameProxyHost() { |
| 24 if (GetProcess()->HasConnection()) |
| 25 Send(new FrameMsg_DeleteProxy(routing_id_)); |
| 26 |
| 27 GetProcess()->RemoveRoute(routing_id_); |
| 28 } |
| 29 |
| 30 RenderViewHostImpl* RenderFrameProxyHost::GetRenderViewHost() { |
| 31 if (render_frame_host_.get()) |
| 32 return render_frame_host_->render_view_host(); |
| 33 return NULL; |
| 34 } |
| 35 |
| 36 scoped_ptr<RenderFrameHostImpl> RenderFrameProxyHost::PassFrameHostOwnership() { |
| 37 render_frame_host_->set_render_frame_proxy_host(NULL); |
| 38 return render_frame_host_.Pass(); |
| 39 } |
| 40 |
| 41 bool RenderFrameProxyHost::Send(IPC::Message *msg) { |
| 42 // TODO(nasko): For now, RenderFrameHost uses this object to send IPC messages |
| 43 // while swapped out. This can be removed once we don't have a swapped out |
| 44 // state on RenderFrameHosts. See https://crbug.com/357747. |
| 45 msg->set_routing_id(routing_id_); |
| 46 return GetProcess()->Send(msg); |
| 47 } |
| 48 |
| 49 bool RenderFrameProxyHost::OnMessageReceived(const IPC::Message& msg) { |
| 50 // TODO(nasko): This can be removed once we don't have a swapped out state on |
| 51 // RenderFrameHosts. See https://crbug.com/357747. |
| 52 if (render_frame_host_.get()) |
| 53 return render_frame_host_->OnMessageReceived(msg); |
| 54 |
| 55 return false; |
| 56 } |
18 | 57 |
19 } // namespace content | 58 } // namespace content |
OLD | NEW |