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