| 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 // In --site-per-process, delete the proxy for the SiteInstance we are | 1404 CHECK(proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()) == |
| 1405 // committing. In the case of main frame, the proxy wraps the | 1405 proxy_hosts_.end()); |
| 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 } | |
| 1420 | 1406 |
| 1421 // Capture the active view count on the old RFH SiteInstance, since the | 1407 // Capture the active view count on the old RFH SiteInstance, since the |
| 1422 // ownership might be passed into the proxy and the pointer will be | 1408 // ownership might be passed into the proxy and the pointer will be |
| 1423 // invalid. | 1409 // invalid. |
| 1424 int active_view_count = | 1410 int active_view_count = |
| 1425 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) | 1411 static_cast<SiteInstanceImpl*>(old_render_frame_host->GetSiteInstance()) |
| 1426 ->active_view_count(); | 1412 ->active_view_count(); |
| 1427 | 1413 |
| 1428 if (is_main_frame) { | 1414 if (is_main_frame) { |
| 1429 RenderFrameProxyHostMap::iterator iter = | 1415 RenderFrameProxyHostMap::iterator iter = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1444 // new process. | 1430 // new process. |
| 1445 if (!is_main_frame) { | 1431 if (!is_main_frame) { |
| 1446 RenderFrameProxyHost* proxy = GetProxyToParent(); | 1432 RenderFrameProxyHost* proxy = GetProxyToParent(); |
| 1447 if (proxy) { | 1433 if (proxy) { |
| 1448 proxy->SetChildRWHView( | 1434 proxy->SetChildRWHView( |
| 1449 render_frame_host_->render_view_host()->GetView()); | 1435 render_frame_host_->render_view_host()->GetView()); |
| 1450 } | 1436 } |
| 1451 } | 1437 } |
| 1452 } | 1438 } |
| 1453 } | 1439 } |
| 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()); | |
| 1459 } | 1440 } |
| 1460 | 1441 |
| 1461 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance( | 1442 void RenderFrameHostManager::ShutdownRenderFrameProxyHostsInSiteInstance( |
| 1462 int32 site_instance_id) { | 1443 int32 site_instance_id) { |
| 1463 // First remove any swapped out RFH for this SiteInstance from our own list. | 1444 // First remove any swapped out RFH for this SiteInstance from our own list. |
| 1464 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); | 1445 ClearProxiesInSiteInstance(site_instance_id, frame_tree_node_); |
| 1465 | 1446 |
| 1466 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts | 1447 // Use the safe RenderWidgetHost iterator for now to find all RenderViewHosts |
| 1467 // in the SiteInstance, then tell their respective FrameTrees to remove all | 1448 // in the SiteInstance, then tell their respective FrameTrees to remove all |
| 1468 // RenderFrameProxyHosts corresponding to them. | 1449 // RenderFrameProxyHosts corresponding to them. |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1736 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1717 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 1737 SiteInstance* instance) { | 1718 SiteInstance* instance) { |
| 1738 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1719 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
| 1739 if (iter != proxy_hosts_.end()) { | 1720 if (iter != proxy_hosts_.end()) { |
| 1740 delete iter->second; | 1721 delete iter->second; |
| 1741 proxy_hosts_.erase(iter); | 1722 proxy_hosts_.erase(iter); |
| 1742 } | 1723 } |
| 1743 } | 1724 } |
| 1744 | 1725 |
| 1745 } // namespace content | 1726 } // namespace content |
| OLD | NEW |