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

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: sync Created 5 years, 5 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 191
183 render_frame_proxy_created_ = true; 192 render_frame_proxy_created_ = true;
184 return true; 193 return true;
185 } 194 }
186 195
187 void RenderFrameProxyHost::DisownOpener() { 196 void RenderFrameProxyHost::DisownOpener() {
188 Send(new FrameMsg_DisownOpener(GetRoutingID())); 197 Send(new FrameMsg_DisownOpener(GetRoutingID()));
189 } 198 }
190 199
191 void RenderFrameProxyHost::OnDetach() { 200 void RenderFrameProxyHost::OnDetach() {
201 if (frame_tree_node_->render_manager()->ForInnerDelegate()) {
202 frame_tree_node_->render_manager()->RemoveOuterDelegateFrame();
203 return;
204 }
205
192 // This message should only be received for subframes. Note that we can't 206 // This message should only be received for subframes. Note that we can't
193 // restrict it to just the current SiteInstances of the ancestors of this 207 // restrict it to just the current SiteInstances of the ancestors of this
194 // frame, because another frame in the tree may be able to detach this frame 208 // frame, because another frame in the tree may be able to detach this frame
195 // by navigating its parent. 209 // by navigating its parent.
196 if (frame_tree_node_->IsMainFrame()) { 210 if (frame_tree_node_->IsMainFrame()) {
197 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH); 211 bad_message::ReceivedBadMessage(GetProcess(), bad_message::RFPH_DETACH);
198 return; 212 return;
199 } 213 }
200 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_); 214 frame_tree_node_->frame_tree()->RemoveFrame(frame_tree_node_);
201 } 215 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, 287 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts,
274 message_port_message_filter, target_rfh->GetRoutingID(), 288 message_port_message_filter, target_rfh->GetRoutingID(),
275 new_params)); 289 new_params));
276 } else { 290 } else {
277 target_rfh->Send( 291 target_rfh->Send(
278 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params)); 292 new FrameMsg_PostMessageEvent(target_rfh->GetRoutingID(), new_params));
279 } 293 }
280 } 294 }
281 295
282 } // namespace content 296 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698