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 26 matching lines...) Expand all Loading... |
37 RenderFrameProxyHost* RenderFrameProxyHost::FromID(int process_id, | 37 RenderFrameProxyHost* RenderFrameProxyHost::FromID(int process_id, |
38 int routing_id) { | 38 int routing_id) { |
39 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 39 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
40 RoutingIDFrameProxyMap* frames = g_routing_id_frame_proxy_map.Pointer(); | 40 RoutingIDFrameProxyMap* frames = g_routing_id_frame_proxy_map.Pointer(); |
41 RoutingIDFrameProxyMap::iterator it = frames->find( | 41 RoutingIDFrameProxyMap::iterator it = frames->find( |
42 RenderFrameProxyHostID(process_id, routing_id)); | 42 RenderFrameProxyHostID(process_id, routing_id)); |
43 return it == frames->end() ? NULL : it->second; | 43 return it == frames->end() ? NULL : it->second; |
44 } | 44 } |
45 | 45 |
46 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, | 46 RenderFrameProxyHost::RenderFrameProxyHost(SiteInstance* site_instance, |
| 47 RenderViewHostImpl* render_view_host, |
47 FrameTreeNode* frame_tree_node) | 48 FrameTreeNode* frame_tree_node) |
48 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), | 49 : routing_id_(site_instance->GetProcess()->GetNextRoutingID()), |
49 site_instance_(site_instance), | 50 site_instance_(site_instance), |
50 process_(site_instance->GetProcess()), | 51 process_(site_instance->GetProcess()), |
51 frame_tree_node_(frame_tree_node), | 52 frame_tree_node_(frame_tree_node), |
52 render_frame_proxy_created_(false) { | 53 render_frame_proxy_created_(false), |
| 54 render_view_host_(render_view_host) { |
53 GetProcess()->AddRoute(routing_id_, this); | 55 GetProcess()->AddRoute(routing_id_, this); |
54 CHECK(g_routing_id_frame_proxy_map.Get().insert( | 56 CHECK(g_routing_id_frame_proxy_map.Get().insert( |
55 std::make_pair( | 57 std::make_pair( |
56 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), | 58 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), |
57 this)).second); | 59 this)).second); |
| 60 CHECK(render_view_host_); |
| 61 frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_); |
58 | 62 |
59 if (!frame_tree_node_->IsMainFrame() && | 63 if (!frame_tree_node_->IsMainFrame() && |
60 frame_tree_node_->parent() | 64 frame_tree_node_->parent() |
61 ->render_manager() | 65 ->render_manager() |
62 ->current_frame_host() | 66 ->current_frame_host() |
63 ->GetSiteInstance() == site_instance) { | 67 ->GetSiteInstance() == site_instance) { |
64 // The RenderFrameHost navigating cross-process is destroyed and a proxy for | 68 // The RenderFrameHost navigating cross-process is destroyed and a proxy for |
65 // it is created in the parent's process. CrossProcessFrameConnector | 69 // it is created in the parent's process. CrossProcessFrameConnector |
66 // initialization only needs to happen on an initial cross-process | 70 // initialization only needs to happen on an initial cross-process |
67 // navigation, when the RenderFrameHost leaves the same process as its | 71 // navigation, when the RenderFrameHost leaves the same process as its |
68 // parent. The same CrossProcessFrameConnector is used for subsequent cross- | 72 // parent. The same CrossProcessFrameConnector is used for subsequent cross- |
69 // process navigations, but it will be destroyed if the frame is | 73 // process navigations, but it will be destroyed if the frame is |
70 // navigated back to the same SiteInstance as its parent. | 74 // navigated back to the same SiteInstance as its parent. |
71 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); | 75 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); |
72 } | 76 } |
73 } | 77 } |
74 | 78 |
75 RenderFrameProxyHost::~RenderFrameProxyHost() { | 79 RenderFrameProxyHost::~RenderFrameProxyHost() { |
76 if (GetProcess()->HasConnection()) { | 80 if (GetProcess()->HasConnection()) { |
77 // TODO(nasko): For now, don't send this IPC for top-level frames, as | 81 // TODO(nasko): For now, don't send this IPC for top-level frames, as |
78 // the top-level RenderFrame will delete the RenderFrameProxy. | 82 // the top-level RenderFrame will delete the RenderFrameProxy. |
79 // This can be removed once we don't have a swapped out state on | 83 // This can be removed once we don't have a swapped out state on |
80 // RenderFrame. See https://crbug.com/357747 | 84 // RenderFrame. See https://crbug.com/357747 |
81 if (!frame_tree_node_->IsMainFrame()) | 85 if (!frame_tree_node_->IsMainFrame()) |
82 Send(new FrameMsg_DeleteProxy(routing_id_)); | 86 Send(new FrameMsg_DeleteProxy(routing_id_)); |
83 } | 87 } |
84 | 88 |
| 89 frame_tree_node_->frame_tree()->ReleaseRenderViewHostRef(render_view_host_); |
85 GetProcess()->RemoveRoute(routing_id_); | 90 GetProcess()->RemoveRoute(routing_id_); |
86 g_routing_id_frame_proxy_map.Get().erase( | 91 g_routing_id_frame_proxy_map.Get().erase( |
87 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_)); | 92 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_)); |
88 } | 93 } |
89 | 94 |
90 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { | 95 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { |
91 cross_process_frame_connector_->set_view( | 96 cross_process_frame_connector_->set_view( |
92 static_cast<RenderWidgetHostViewChildFrame*>(view)); | 97 static_cast<RenderWidgetHostViewChildFrame*>(view)); |
93 } | 98 } |
94 | 99 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, | 273 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, |
269 message_port_message_filter, target_rfh->GetRoutingID(), | 274 message_port_message_filter, target_rfh->GetRoutingID(), |
270 new_params)); | 275 new_params)); |
271 } else { | 276 } else { |
272 target_rfh->Send( | 277 target_rfh->Send( |
273 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); | 278 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); |
274 } | 279 } |
275 } | 280 } |
276 | 281 |
277 } // namespace content | 282 } // namespace content |
OLD | NEW |