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 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 proxy_hosts_.erase(iter); | 1390 proxy_hosts_.erase(iter); |
1391 } | 1391 } |
1392 RFHPendingDeleteMap::iterator pending_delete_iter = | 1392 RFHPendingDeleteMap::iterator pending_delete_iter = |
1393 pending_delete_hosts_.find(old_site_instance_id); | 1393 pending_delete_hosts_.find(old_site_instance_id); |
1394 if (pending_delete_iter == pending_delete_hosts_.end() || | 1394 if (pending_delete_iter == pending_delete_hosts_.end() || |
1395 pending_delete_iter->second.get() != old_render_frame_host) { | 1395 pending_delete_iter->second.get() != old_render_frame_host) { |
1396 pending_delete_hosts_[old_site_instance_id] = | 1396 pending_delete_hosts_[old_site_instance_id] = |
1397 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); | 1397 linked_ptr<RenderFrameHostImpl>(old_render_frame_host.release()); |
1398 } | 1398 } |
1399 } else { | 1399 } else { |
1400 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == | 1400 // In --site-per-process, delete the proxy for the SiteInstance we are |
1401 proxy_hosts_.end()); | 1401 // committing. In the case of main frame, the proxy wraps the |
| 1402 // |old_render_frame_host|, so it must be left intact. |
| 1403 // TODO(nasko): When committing into an existing process, the proxy |
| 1404 // should be swapped in the frame tree with the real frame, but this is |
| 1405 // not yet the case. Revisit this to ensure the necessary context is |
| 1406 // preserved. |
| 1407 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1408 switches::kSitePerProcess) && !is_main_frame) { |
| 1409 RenderFrameProxyHostMap::iterator iter = |
| 1410 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); |
| 1411 if (iter != proxy_hosts_.end()) { |
| 1412 delete iter->second; |
| 1413 proxy_hosts_.erase(iter); |
| 1414 } |
| 1415 } |
1402 | 1416 |
1403 // Capture the active view count on the old RFH SiteInstance, since the | 1417 // Capture the active view count on the old RFH SiteInstance, since the |
1404 // ownership might be passed into the proxy and the pointer will be | 1418 // ownership might be passed into the proxy and the pointer will be |
1405 // invalid. | 1419 // invalid. |
1406 int active_view_count = | 1420 int active_view_count = |
1407 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) | 1421 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) |
1408 ->active_view_count(); | 1422 ->active_view_count(); |
1409 | 1423 |
1410 if (is_main_frame) { | 1424 if (is_main_frame) { |
1411 RenderFrameProxyHostMap::iterator iter = | 1425 RenderFrameProxyHostMap::iterator iter = |
(...skipping 14 matching lines...) Expand all Loading... |
1426 // new process. | 1440 // new process. |
1427 if (!is_main_frame) { | 1441 if (!is_main_frame) { |
1428 RenderFrameProxyHost* proxy = GetProxyToParent(); | 1442 RenderFrameProxyHost* proxy = GetProxyToParent(); |
1429 if (proxy) { | 1443 if (proxy) { |
1430 proxy->SetChildRWHView( | 1444 proxy->SetChildRWHView( |
1431 render_frame_host_->render_view_host()->GetView()); | 1445 render_frame_host_->render_view_host()->GetView()); |
1432 } | 1446 } |
1433 } | 1447 } |
1434 } | 1448 } |
1435 } | 1449 } |
| 1450 |
| 1451 // After all is done, there must never be a proxy in the list which has the |
| 1452 // same SiteInstance as the current RenderFrameHost. |
| 1453 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == |
| 1454 proxy_hosts_.end()); |
1436 } | 1455 } |
1437 | 1456 |
1438 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance( | 1457 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance( |
1439 int32 site_instance_id) { | 1458 int32 site_instance_id) { |
1440 // First remove any swapped out RFH for this SiteInstance from our own list. | 1459 // First remove any swapped out RFH for this SiteInstance from our own list. |
1441 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); | 1460 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); |
1442 | 1461 |
1443 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts | 1462 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts |
1444 // in the SiteInstance, then tell their respective FrameTrees to remove all | 1463 // in the SiteInstance, then tell their respective FrameTrees to remove all |
1445 // RenderFrameProxyHosts corresponding to them. | 1464 // RenderFrameProxyHosts corresponding to them. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1731 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1713 SiteInstance* instance) { | 1732 SiteInstance* instance) { |
1714 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1733 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1715 if (iter != proxy_hosts_.end()) { | 1734 if (iter != proxy_hosts_.end()) { |
1716 delete iter->second; | 1735 delete iter->second; |
1717 proxy_hosts_.erase(iter); | 1736 proxy_hosts_.erase(iter); |
1718 } | 1737 } |
1719 } | 1738 } |
1720 | 1739 |
1721 } // namespace content | 1740 } // namespace content |
OLD | NEW |