OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); | 1286 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); |
1287 | 1287 |
1288 // Swap out the old frame now that the new one is visible. | 1288 // Swap out the old frame now that the new one is visible. |
1289 // This will swap it out and then put it on the proxy list (if there are other | 1289 // This will swap it out and then put it on the proxy list (if there are other |
1290 // active views in its SiteInstance) or schedule it for deletion when the swap | 1290 // active views in its SiteInstance) or schedule it for deletion when the swap |
1291 // out ack arrives (or immediately if the process isn't live). | 1291 // out ack arrives (or immediately if the process isn't live). |
1292 // In the --site-per-process case, old subframe RHFs are not kept alive inside | 1292 // In the --site-per-process case, old subframe RHFs are not kept alive inside |
1293 // the proxy. | 1293 // the proxy. |
1294 SwapOutOldFrame(old_render_frame_host.Pass()); | 1294 SwapOutOldFrame(old_render_frame_host.Pass()); |
1295 | 1295 |
1296 // If this is a subframe, it should have a CrossProcessFrameConnector | |
1297 // created already. Use it to link the new RFH's view to the proxy that | |
1298 // belongs to the parent frame's SiteInstance. | |
1299 // Note: We do this after swapping out the old RFH because that may create the | |
1300 // proxy we're looking for. | |
1301 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) && | 1296 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) && |
1302 !is_main_frame) { | 1297 !is_main_frame) { |
| 1298 // If this is a subframe, it should have a CrossProcessFrameConnector |
| 1299 // created already. Use it to link the new RFH's view to the proxy that |
| 1300 // belongs to the parent frame's SiteInstance. |
| 1301 // Note: We do this after swapping out the old RFH because that may create |
| 1302 // the proxy we're looking for. |
1303 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); | 1303 RenderFrameProxyHost* proxy_to_parent = GetProxyToParent(); |
1304 if (proxy_to_parent) { | 1304 if (proxy_to_parent) { |
1305 proxy_to_parent->SetChildRWHView( | 1305 proxy_to_parent->SetChildRWHView( |
1306 render_frame_host_->render_view_host()->GetView()); | 1306 render_frame_host_->render_view_host()->GetView()); |
1307 } | 1307 } |
| 1308 |
| 1309 // Since the new RenderFrameHost is now committed, there must be no proxies |
| 1310 // for its SiteInstance. Delete any existing ones. |
| 1311 RenderFrameProxyHostMap::iterator iter = |
| 1312 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); |
| 1313 if (iter != proxy_hosts_.end()) { |
| 1314 delete iter->second; |
| 1315 proxy_hosts_.erase(iter); |
| 1316 } |
1308 } | 1317 } |
| 1318 |
| 1319 // After all is done, there must never be a proxy in the list which has the |
| 1320 // same SiteInstance as the current RenderFrameHost. |
| 1321 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == |
| 1322 proxy_hosts_.end()); |
1309 } | 1323 } |
1310 | 1324 |
1311 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance( | 1325 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance( |
1312 int32 site_instance_id) { | 1326 int32 site_instance_id) { |
1313 // First remove any swapped out RFH for this SiteInstance from our own list. | 1327 // First remove any swapped out RFH for this SiteInstance from our own list. |
1314 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); | 1328 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); |
1315 | 1329 |
1316 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts | 1330 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts |
1317 // in the SiteInstance, then tell their respective FrameTrees to remove all | 1331 // in the SiteInstance, then tell their respective FrameTrees to remove all |
1318 // RenderFrameProxyHosts corresponding to them. | 1332 // RenderFrameProxyHosts corresponding to them. |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1605 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1592 SiteInstance* instance) { | 1606 SiteInstance* instance) { |
1593 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1607 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1594 if (iter != proxy_hosts_.end()) { | 1608 if (iter != proxy_hosts_.end()) { |
1595 delete iter->second; | 1609 delete iter->second; |
1596 proxy_hosts_.erase(iter); | 1610 proxy_hosts_.erase(iter); |
1597 } | 1611 } |
1598 } | 1612 } |
1599 | 1613 |
1600 } // namespace content | 1614 } // namespace content |
OLD | NEW |