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