Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: content/browser/frame_host/render_frame_proxy_host.cc

Issue 972313002: Make <webview> use out-of-process iframe architecture. (Closed) Base URL: ssh://saopaulo.wat/mnt/dev/shared/src@testoopif2z-better-chrome
Patch Set: address comments from nasko@ + git cl format Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 site_instance_(site_instance), 50 site_instance_(site_instance),
51 process_(site_instance->GetProcess()), 51 process_(site_instance->GetProcess()),
52 frame_tree_node_(frame_tree_node), 52 frame_tree_node_(frame_tree_node),
53 render_frame_proxy_created_(false), 53 render_frame_proxy_created_(false),
54 render_view_host_(render_view_host) { 54 render_view_host_(render_view_host) {
55 GetProcess()->AddRoute(routing_id_, this); 55 GetProcess()->AddRoute(routing_id_, this);
56 CHECK(g_routing_id_frame_proxy_map.Get().insert( 56 CHECK(g_routing_id_frame_proxy_map.Get().insert(
57 std::make_pair( 57 std::make_pair(
58 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_), 58 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_),
59 this)).second); 59 this)).second);
60 CHECK(render_view_host_); 60 CHECK_IMPLIES(!render_view_host,
61 frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_); 61 frame_tree_node_->render_manager()->ForInnerDelegate());
62 if (render_view_host)
63 frame_tree_node_->frame_tree()->AddRenderViewHostRef(render_view_host_);
62 64
63 if (!frame_tree_node_->IsMainFrame() && 65 bool is_proxy_to_parent = !frame_tree_node_->IsMainFrame() &&
64 frame_tree_node_->parent() 66 frame_tree_node_->parent()
65 ->render_manager() 67 ->render_manager()
66 ->current_frame_host() 68 ->current_frame_host()
67 ->GetSiteInstance() == site_instance) { 69 ->GetSiteInstance() == site_instance;
70
71 // If this is a proxy to parent frame or this proxy is for the inner
72 // WebContents's FrameTreeNode in outer WebContents's SiteInstance, then we
73 // need a CrossProcessFrameConnector.
74 if (is_proxy_to_parent ||
75 frame_tree_node_->render_manager()->ForInnerDelegate()) {
68 // The RenderFrameHost navigating cross-process is destroyed and a proxy for 76 // The RenderFrameHost navigating cross-process is destroyed and a proxy for
69 // it is created in the parent's process. CrossProcessFrameConnector 77 // it is created in the parent's process. CrossProcessFrameConnector
70 // initialization only needs to happen on an initial cross-process 78 // initialization only needs to happen on an initial cross-process
71 // navigation, when the RenderFrameHost leaves the same process as its 79 // navigation, when the RenderFrameHost leaves the same process as its
72 // parent. The same CrossProcessFrameConnector is used for subsequent cross- 80 // parent. The same CrossProcessFrameConnector is used for subsequent cross-
73 // process navigations, but it will be destroyed if the frame is 81 // process navigations, but it will be destroyed if the frame is
74 // navigated back to the same SiteInstance as its parent. 82 // navigated back to the same SiteInstance as its parent.
75 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this)); 83 cross_process_frame_connector_.reset(new CrossProcessFrameConnector(this));
76 } 84 }
77 } 85 }
78 86
79 RenderFrameProxyHost::~RenderFrameProxyHost() { 87 RenderFrameProxyHost::~RenderFrameProxyHost() {
80 if (GetProcess()->HasConnection()) { 88 if (GetProcess()->HasConnection()) {
81 // TODO(nasko): For now, don't send this IPC for top-level frames, as 89 // TODO(nasko): For now, don't send this IPC for top-level frames, as
82 // the top-level RenderFrame will delete the RenderFrameProxy. 90 // the top-level RenderFrame will delete the RenderFrameProxy.
83 // This can be removed once we don't have a swapped out state on 91 // This can be removed once we don't have a swapped out state on
84 // RenderFrame. See https://crbug.com/357747 92 // RenderFrame. See https://crbug.com/357747
85 if (!frame_tree_node_->IsMainFrame()) 93 if (!frame_tree_node_->IsMainFrame())
86 Send(new FrameMsg_DeleteProxy(routing_id_)); 94 Send(new FrameMsg_DeleteProxy(routing_id_));
87 } 95 }
88 96
89 frame_tree_node_->frame_tree()->ReleaseRenderViewHostRef(render_view_host_); 97 if (render_view_host_)
98 frame_tree_node_->frame_tree()->ReleaseRenderViewHostRef(render_view_host_);
90 GetProcess()->RemoveRoute(routing_id_); 99 GetProcess()->RemoveRoute(routing_id_);
91 g_routing_id_frame_proxy_map.Get().erase( 100 g_routing_id_frame_proxy_map.Get().erase(
92 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_)); 101 RenderFrameProxyHostID(GetProcess()->GetID(), routing_id_));
93 } 102 }
94 103
95 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) { 104 void RenderFrameProxyHost::SetChildRWHView(RenderWidgetHostView* view) {
96 cross_process_frame_connector_->set_view( 105 cross_process_frame_connector_->set_view(
97 static_cast<RenderWidgetHostViewChildFrame*>(view)); 106 static_cast<RenderWidgetHostViewChildFrame*>(view));
98 } 107 }
99 108
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 187
179 render_frame_proxy_created_ = true; 188 render_frame_proxy_created_ = true;
180 return true; 189 return true;
181 } 190 }
182 191
183 void RenderFrameProxyHost::DisownOpener() { 192 void RenderFrameProxyHost::DisownOpener() {
184 Send(new FrameMsg_DisownOpener(GetRoutingID())); 193 Send(new FrameMsg_DisownOpener(GetRoutingID()));
185 } 194 }
186 195
187 void RenderFrameProxyHost::OnDetach() { 196 void RenderFrameProxyHost::OnDetach() {
197 if (frame_tree_node_->render_manager()->ForInnerDelegate()) {
198 frame_tree_node_->render_manager()->RemoveOuterDelegateFrame();
199 return;
200 }
201
188 // This message should only be received for subframes. Note that we can't 202 // This message should only be received for subframes. Note that we can't
189 // restrict it to just the current SiteInstances of the ancestors of this 203 // restrict it to just the current SiteInstances of the ancestors of this
190 // frame, because another frame in the tree may be able to detach this frame 204 // frame, because another frame in the tree may be able to detach this frame
191 // by navigating its parent. 205 // by navigating its parent.
192 if (frame_tree_node_->IsMainFrame()) { 206 if (frame_tree_node_->IsMainFrame()) {
193 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); 207 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH);
194 return; 208 return;
195 } 209 }
196 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_); 210 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_);
197 } 211 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, 292 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts,
279 message_port_message_filter, target_rfh->GetRoutingID(), 293 message_port_message_filter, target_rfh->GetRoutingID(),
280 new_params)); 294 new_params));
281 } else { 295 } else {
282 target_rfh->Send( 296 target_rfh->Send(
283 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); 297 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params));
284 } 298 }
285 } 299 }
286 300
287 } // namespace content 301 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698