Chromium Code Reviews| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "content/browser/bad_message.h" | 8 #include "content/browser/bad_message.h" |
| 9 #include "content/browser/frame_host/cross_process_frame_connector.h" | 9 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 site_instance_(site_instance), | 49 site_instance_(site_instance), |
| 50 process_(site_instance->GetProcess()), | 50 process_(site_instance->GetProcess()), |
| 51 frame_tree_node_(frame_tree_node), | 51 frame_tree_node_(frame_tree_node), |
| 52 render_frame_proxy_created_(false) { | 52 render_frame_proxy_created_(false) { |
| 53 GetProcess()->AddRoute(routing_id_, this); | 53 GetProcess()->AddRoute(routing_id_, this); |
| 54 CHECK(g_routing_id_frame_proxy_map.Get().insert( | 54 CHECK(g_routing_id_frame_proxy_map.Get().insert( |
| 55 std::make_pair( | 55 std::make_pair( |
| 56 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), | 56 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), |
| 57 this)).second); | 57 this)).second); |
| 58 | 58 |
| 59 if (!frame_tree_node_->IsMainFrame() && | 59 if ((!frame_tree_node_->IsMainFrame() && |
| 60 frame_tree_node_->parent() | 60 frame_tree_node_->parent() |
| 61 ->render_manager() | 61 ->render_manager() |
| 62 ->current_frame_host() | 62 ->current_frame_host() |
| 63 ->GetSiteInstance() == site_instance) { | 63 ->GetSiteInstance() == site_instance) || |
| 64 // If this is a proxy for the guest FTN in its embedder process, then we | |
| 65 // need a CrossProcessFrameConnector. | |
|
Charlie Reis
2015/05/19 07:12:31
This is getting a bit too complicated, given that
lazyboy
2015/05/21 23:23:47
Done.
| |
| 66 frame_tree_node_->render_manager()->IsGuest()) { | |
| 64 // The RenderFrameHost navigating cross-process is destroyed and a proxy for | 67 // The RenderFrameHost navigating cross-process is destroyed and a proxy for |
| 65 // it is created in the parent's process. CrossProcessFrameConnector | 68 // it is created in the parent's process. CrossProcessFrameConnector |
| 66 // initialization only needs to happen on an initial cross-process | 69 // initialization only needs to happen on an initial cross-process |
| 67 // navigation, when the RenderFrameHost leaves the same process as its | 70 // navigation, when the RenderFrameHost leaves the same process as its |
| 68 // parent. The same CrossProcessFrameConnector is used for subsequent cross- | 71 // parent. The same CrossProcessFrameConnector is used for subsequent cross- |
| 69 // process navigations, but it will be destroyed if the frame is | 72 // process navigations, but it will be destroyed if the frame is |
| 70 // navigated back to the same SiteInstance as its parent. | 73 // navigated back to the same SiteInstance as its parent. |
| 71 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); | 74 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); |
| 72 } | 75 } |
| 73 } | 76 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 85 GetProcess()->RemoveRoute(routing_id_); | 88 GetProcess()->RemoveRoute(routing_id_); |
| 86 g_routing_id_frame_proxy_map.Get().erase( | 89 g_routing_id_frame_proxy_map.Get().erase( |
| 87 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_)); | 90 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_)); |
| 88 } | 91 } |
| 89 | 92 |
| 90 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { | 93 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { |
| 91 cross_process_frame_connector_->set_view( | 94 cross_process_frame_connector_->set_view( |
| 92 static_cast<RenderWidgetHostViewChildFrame*>(view)); | 95 static_cast<RenderWidgetHostViewChildFrame*>(view)); |
| 93 } | 96 } |
| 94 | 97 |
| 98 // TODO(lazyboy): We can probably cache a pointer to RVH in this class | |
| 99 // as we do in RenderFrameHostImpl. | |
| 95 RenderViewHostImpl* RenderFrameProxyHost::GetRenderViewHost() { | 100 RenderViewHostImpl* RenderFrameProxyHost::GetRenderViewHost() { |
| 96 return frame_tree_node_->frame_tree()->GetRenderViewHost( | 101 // RVH of embedder SiteInstance does not live in the guest RFHM, we need to |
| 97 site_instance_.get()); | 102 // look it up in the embedder's FrameTree. |
| 103 RenderFrameProxyHost* proxy_to_embedder = | |
| 104 frame_tree_node_->render_manager()->GetProxyToEmbedder(); | |
| 105 FrameTree* frame_tree = | |
| 106 proxy_to_embedder && | |
| 107 proxy_to_embedder->GetSiteInstance() == GetSiteInstance() | |
| 108 ? proxy_to_embedder->frame_tree_node_->frame_tree() | |
| 109 : frame_tree_node_->frame_tree(); | |
| 110 return frame_tree->GetRenderViewHost(site_instance_.get()); | |
| 98 } | 111 } |
| 99 | 112 |
| 100 void RenderFrameProxyHost::TakeFrameHostOwnership( | 113 void RenderFrameProxyHost::TakeFrameHostOwnership( |
| 101 scoped_ptr<RenderFrameHostImpl> render_frame_host) { | 114 scoped_ptr<RenderFrameHostImpl> render_frame_host) { |
| 102 CHECK(render_frame_host_ == nullptr); | 115 CHECK(render_frame_host_ == nullptr); |
| 103 render_frame_host_ = render_frame_host.Pass(); | 116 render_frame_host_ = render_frame_host.Pass(); |
| 104 render_frame_host_->set_render_frame_proxy_host(this); | 117 render_frame_host_->set_render_frame_proxy_host(this); |
| 105 } | 118 } |
| 106 | 119 |
| 107 scoped_ptr<RenderFrameHostImpl> RenderFrameProxyHost::PassFrameHostOwnership() { | 120 scoped_ptr<RenderFrameHostImpl> RenderFrameProxyHost::PassFrameHostOwnership() { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, | 281 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, |
| 269 message_port_message_filter, target_rfh->GetRoutingID(), | 282 message_port_message_filter, target_rfh->GetRoutingID(), |
| 270 new_params)); | 283 new_params)); |
| 271 } else { | 284 } else { |
| 272 target_rfh->Send( | 285 target_rfh->Send( |
| 273 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); | 286 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); |
| 274 } | 287 } |
| 275 } | 288 } |
| 276 | 289 |
| 277 } // namespace content | 290 } // namespace content |
| OLD | NEW |