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/logging.h" | 10 #include "base/logging.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 // Tell the old RenderFrameHost to swap out, with no proxy to replace it. | 591 // Tell the old RenderFrameHost to swap out, with no proxy to replace it. |
592 old_render_frame_host->SwapOut(NULL, true); | 592 old_render_frame_host->SwapOut(NULL, true); |
593 MoveToPendingDeleteHosts(old_render_frame_host.Pass()); | 593 MoveToPendingDeleteHosts(old_render_frame_host.Pass()); |
594 return; | 594 return; |
595 } | 595 } |
596 | 596 |
597 // Otherwise there are active views and we need a proxy for the old RFH. | 597 // Otherwise there are active views and we need a proxy for the old RFH. |
598 // (There should not be one yet.) | 598 // (There should not be one yet.) |
599 CHECK(!GetRenderFrameProxyHost(old_render_frame_host->GetSiteInstance())); | 599 CHECK(!GetRenderFrameProxyHost(old_render_frame_host->GetSiteInstance())); |
600 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( | 600 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
601 old_render_frame_host->GetSiteInstance(), | 601 old_render_frame_host->GetSiteInstance(), frame_tree_node_); |
602 old_render_frame_host->render_view_host(), | |
603 frame_tree_node_); | |
604 CHECK(proxy_hosts_.insert(std::make_pair(old_site_instance_id, proxy)).second) | 602 CHECK(proxy_hosts_.insert(std::make_pair(old_site_instance_id, proxy)).second) |
605 << "Inserting a duplicate item."; | 603 << "Inserting a duplicate item."; |
606 | 604 |
607 // Tell the old RenderFrameHost to swap out and be replaced by the proxy. | 605 // Tell the old RenderFrameHost to swap out and be replaced by the proxy. |
608 old_render_frame_host->SwapOut(proxy, true); | 606 old_render_frame_host->SwapOut(proxy, true); |
609 | 607 |
610 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized. | 608 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized. |
611 proxy->set_render_frame_proxy_created(true); | 609 proxy->set_render_frame_proxy_created(true); |
612 | 610 |
613 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 611 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
(...skipping 22 matching lines...) Expand all Loading... |
636 | 634 |
637 // If the SiteInstance for the pending RFH is being used by others don't | 635 // If the SiteInstance for the pending RFH is being used by others don't |
638 // delete the RFH. Just swap it out and it can be reused at a later point. | 636 // delete the RFH. Just swap it out and it can be reused at a later point. |
639 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); | 637 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
640 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { | 638 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { |
641 // Any currently suspended navigations are no longer needed. | 639 // Any currently suspended navigations are no longer needed. |
642 render_frame_host->CancelSuspendedNavigations(); | 640 render_frame_host->CancelSuspendedNavigations(); |
643 | 641 |
644 CHECK(!GetRenderFrameProxyHost(site_instance)); | 642 CHECK(!GetRenderFrameProxyHost(site_instance)); |
645 RenderFrameProxyHost* proxy = | 643 RenderFrameProxyHost* proxy = |
646 new RenderFrameProxyHost(site_instance, | 644 new RenderFrameProxyHost(site_instance, frame_tree_node_); |
647 render_frame_host->render_view_host(), | |
648 frame_tree_node_); | |
649 proxy_hosts_[site_instance->GetId()] = proxy; | 645 proxy_hosts_[site_instance->GetId()] = proxy; |
650 | 646 |
651 // Check if the RenderFrameHost is already swapped out, to avoid swapping it | 647 // Check if the RenderFrameHost is already swapped out, to avoid swapping it |
652 // out again. | 648 // out again. |
653 if (!render_frame_host->is_swapped_out()) | 649 if (!render_frame_host->is_swapped_out()) |
654 render_frame_host->SwapOut(proxy, false); | 650 render_frame_host->SwapOut(proxy, false); |
655 | 651 |
656 if (frame_tree_node_->IsMainFrame()) | 652 if (frame_tree_node_->IsMainFrame()) |
657 proxy->TakeFrameHostOwnership(render_frame_host.Pass()); | 653 proxy->TakeFrameHostOwnership(render_frame_host.Pass()); |
658 } else { | 654 } else { |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 RenderViewHostImpl* render_view_host = | 1508 RenderViewHostImpl* render_view_host = |
1513 new_render_frame_host->render_view_host(); | 1509 new_render_frame_host->render_view_host(); |
1514 int proxy_routing_id = MSG_ROUTING_NONE; | 1510 int proxy_routing_id = MSG_ROUTING_NONE; |
1515 | 1511 |
1516 // Prevent the process from exiting while we're trying to navigate in it. | 1512 // Prevent the process from exiting while we're trying to navigate in it. |
1517 // Otherwise, if the new RFH is swapped out already, store it. | 1513 // Otherwise, if the new RFH is swapped out already, store it. |
1518 if (!swapped_out) { | 1514 if (!swapped_out) { |
1519 new_render_frame_host->GetProcess()->AddPendingView(); | 1515 new_render_frame_host->GetProcess()->AddPendingView(); |
1520 } else { | 1516 } else { |
1521 proxy = new RenderFrameProxyHost( | 1517 proxy = new RenderFrameProxyHost( |
1522 new_render_frame_host->GetSiteInstance(), | 1518 new_render_frame_host->GetSiteInstance(), frame_tree_node_); |
1523 new_render_frame_host->render_view_host(), frame_tree_node_); | |
1524 proxy_hosts_[instance->GetId()] = proxy; | 1519 proxy_hosts_[instance->GetId()] = proxy; |
1525 proxy_routing_id = proxy->GetRoutingID(); | 1520 proxy_routing_id = proxy->GetRoutingID(); |
1526 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | 1521 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); |
1527 } | 1522 } |
1528 | 1523 |
1529 success = | 1524 success = |
1530 InitRenderView(render_view_host, opener_route_id, proxy_routing_id, | 1525 InitRenderView(render_view_host, opener_route_id, proxy_routing_id, |
1531 !!(flags & CREATE_RF_FOR_MAIN_FRAME_NAVIGATION)); | 1526 !!(flags & CREATE_RF_FOR_MAIN_FRAME_NAVIGATION)); |
1532 if (success) { | 1527 if (success) { |
1533 // Remember that InitRenderView also created the RenderFrameProxy. | 1528 // Remember that InitRenderView also created the RenderFrameProxy. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 // A RenderFrameProxyHost should never be created in the same SiteInstance as | 1560 // A RenderFrameProxyHost should never be created in the same SiteInstance as |
1566 // the current RFH. | 1561 // the current RFH. |
1567 CHECK(instance); | 1562 CHECK(instance); |
1568 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); | 1563 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); |
1569 | 1564 |
1570 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1565 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1571 if (proxy && proxy->is_render_frame_proxy_live()) | 1566 if (proxy && proxy->is_render_frame_proxy_live()) |
1572 return proxy->GetRoutingID(); | 1567 return proxy->GetRoutingID(); |
1573 | 1568 |
1574 if (!proxy) { | 1569 if (!proxy) { |
1575 proxy = new RenderFrameProxyHost( | 1570 proxy = new RenderFrameProxyHost(instance, frame_tree_node_); |
1576 instance, frame_tree_node_->frame_tree()->GetRenderViewHost(instance), | |
1577 frame_tree_node_); | |
1578 proxy_hosts_[instance->GetId()] = proxy; | 1571 proxy_hosts_[instance->GetId()] = proxy; |
1579 } | 1572 } |
1580 proxy->InitRenderFrameProxy(); | 1573 proxy->InitRenderFrameProxy(); |
1581 return proxy->GetRoutingID(); | 1574 return proxy->GetRoutingID(); |
1582 } | 1575 } |
1583 | 1576 |
1584 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { | 1577 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { |
1585 for (const auto& pair : proxy_hosts_) { | 1578 for (const auto& pair : proxy_hosts_) { |
1586 child->render_manager()->CreateRenderFrameProxy( | 1579 child->render_manager()->CreateRenderFrameProxy( |
1587 pair.second->GetSiteInstance()); | 1580 pair.second->GetSiteInstance()); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2109 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
2117 SiteInstance* instance) { | 2110 SiteInstance* instance) { |
2118 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2111 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
2119 if (iter != proxy_hosts_.end()) { | 2112 if (iter != proxy_hosts_.end()) { |
2120 delete iter->second; | 2113 delete iter->second; |
2121 proxy_hosts_.erase(iter); | 2114 proxy_hosts_.erase(iter); |
2122 } | 2115 } |
2123 } | 2116 } |
2124 | 2117 |
2125 } // namespace content | 2118 } // namespace content |
OLD | NEW |