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(), frame_tree_node_); | 601 old_render_frame_host->GetSiteInstance(), |
602 old_render_frame_host->render_view_host(), frame_tree_node_); | |
602 CHECK(proxy_hosts_.insert(std::make_pair(old_site_instance_id, proxy)).second) | 603 CHECK(proxy_hosts_.insert(std::make_pair(old_site_instance_id, proxy)).second) |
603 << "Inserting a duplicate item."; | 604 << "Inserting a duplicate item."; |
604 | 605 |
605 // Tell the old RenderFrameHost to swap out and be replaced by the proxy. | 606 // Tell the old RenderFrameHost to swap out and be replaced by the proxy. |
606 old_render_frame_host->SwapOut(proxy, true); | 607 old_render_frame_host->SwapOut(proxy, true); |
607 | 608 |
608 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized. | 609 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized. |
609 proxy->set_render_frame_proxy_created(true); | 610 proxy->set_render_frame_proxy_created(true); |
610 | 611 |
611 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 612 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
(...skipping 21 matching lines...) Expand all Loading... | |
633 // SwapOutOldFrame and we should see that these are unified at some point. | 634 // SwapOutOldFrame and we should see that these are unified at some point. |
634 | 635 |
635 // If the SiteInstance for the pending RFH is being used by others don't | 636 // If the SiteInstance for the pending RFH is being used by others don't |
636 // delete the RFH. Just swap it out and it can be reused at a later point. | 637 // delete the RFH. Just swap it out and it can be reused at a later point. |
637 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); | 638 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
638 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { | 639 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { |
639 // Any currently suspended navigations are no longer needed. | 640 // Any currently suspended navigations are no longer needed. |
640 render_frame_host->CancelSuspendedNavigations(); | 641 render_frame_host->CancelSuspendedNavigations(); |
641 | 642 |
642 CHECK(!GetRenderFrameProxyHost(site_instance)); | 643 CHECK(!GetRenderFrameProxyHost(site_instance)); |
643 RenderFrameProxyHost* proxy = | 644 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( |
644 new RenderFrameProxyHost(site_instance, frame_tree_node_); | 645 site_instance, render_frame_host->render_view_host(), frame_tree_node_); |
645 proxy_hosts_[site_instance->GetId()] = proxy; | 646 proxy_hosts_[site_instance->GetId()] = proxy; |
646 | 647 |
647 // Check if the RenderFrameHost is already swapped out, to avoid swapping it | 648 // Check if the RenderFrameHost is already swapped out, to avoid swapping it |
648 // out again. | 649 // out again. |
649 if (!render_frame_host->is_swapped_out()) | 650 if (!render_frame_host->is_swapped_out()) |
650 render_frame_host->SwapOut(proxy, false); | 651 render_frame_host->SwapOut(proxy, false); |
651 | 652 |
652 if (frame_tree_node_->IsMainFrame()) | 653 if (frame_tree_node_->IsMainFrame()) |
653 proxy->TakeFrameHostOwnership(render_frame_host.Pass()); | 654 proxy->TakeFrameHostOwnership(render_frame_host.Pass()); |
654 } else { | 655 } else { |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1494 RenderViewHostImpl* render_view_host = | 1495 RenderViewHostImpl* render_view_host = |
1495 new_render_frame_host->render_view_host(); | 1496 new_render_frame_host->render_view_host(); |
1496 int proxy_routing_id = MSG_ROUTING_NONE; | 1497 int proxy_routing_id = MSG_ROUTING_NONE; |
1497 | 1498 |
1498 // Prevent the process from exiting while we're trying to navigate in it. | 1499 // Prevent the process from exiting while we're trying to navigate in it. |
1499 // Otherwise, if the new RFH is swapped out already, store it. | 1500 // Otherwise, if the new RFH is swapped out already, store it. |
1500 if (!swapped_out) { | 1501 if (!swapped_out) { |
1501 new_render_frame_host->GetProcess()->AddPendingView(); | 1502 new_render_frame_host->GetProcess()->AddPendingView(); |
1502 } else { | 1503 } else { |
1503 proxy = new RenderFrameProxyHost( | 1504 proxy = new RenderFrameProxyHost( |
1504 new_render_frame_host->GetSiteInstance(), frame_tree_node_); | 1505 new_render_frame_host->GetSiteInstance(), |
1506 new_render_frame_host->render_view_host(), frame_tree_node_); | |
1505 proxy_hosts_[instance->GetId()] = proxy; | 1507 proxy_hosts_[instance->GetId()] = proxy; |
1506 proxy_routing_id = proxy->GetRoutingID(); | 1508 proxy_routing_id = proxy->GetRoutingID(); |
1507 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); | 1509 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); |
1508 } | 1510 } |
1509 | 1511 |
1510 success = | 1512 success = |
1511 InitRenderView(render_view_host, opener_route_id, proxy_routing_id, | 1513 InitRenderView(render_view_host, opener_route_id, proxy_routing_id, |
1512 !!(flags & CREATE_RF_FOR_MAIN_FRAME_NAVIGATION)); | 1514 !!(flags & CREATE_RF_FOR_MAIN_FRAME_NAVIGATION)); |
1513 if (success) { | 1515 if (success) { |
1514 // Remember that InitRenderView also created the RenderFrameProxy. | 1516 // Remember that InitRenderView also created the RenderFrameProxy. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1561 // A RenderFrameProxyHost should never be created in the same SiteInstance as | 1563 // A RenderFrameProxyHost should never be created in the same SiteInstance as |
1562 // the current RFH. | 1564 // the current RFH. |
1563 CHECK(instance); | 1565 CHECK(instance); |
1564 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); | 1566 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); |
1565 | 1567 |
1566 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1568 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1567 if (proxy && proxy->is_render_frame_proxy_live()) | 1569 if (proxy && proxy->is_render_frame_proxy_live()) |
1568 return proxy->GetRoutingID(); | 1570 return proxy->GetRoutingID(); |
1569 | 1571 |
1570 if (!proxy) { | 1572 if (!proxy) { |
1571 proxy = new RenderFrameProxyHost(instance, frame_tree_node_); | 1573 proxy = new RenderFrameProxyHost( |
1574 instance, frame_tree_node_->frame_tree()->GetRenderViewHost(instance), | |
ncarter (slow)
2015/05/22 23:03:13
Would it be worth adding a comment here about why
nasko
2015/05/22 23:46:49
This is just temporary. My bigger CL to remove swa
ncarter (slow)
2015/05/23 00:33:36
Acknowledged.
| |
1575 frame_tree_node_); | |
1572 proxy_hosts_[instance->GetId()] = proxy; | 1576 proxy_hosts_[instance->GetId()] = proxy; |
1573 } | 1577 } |
1574 proxy->InitRenderFrameProxy(); | 1578 proxy->InitRenderFrameProxy(); |
1575 return proxy->GetRoutingID(); | 1579 return proxy->GetRoutingID(); |
1576 } | 1580 } |
1577 | 1581 |
1578 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { | 1582 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { |
1579 for (const auto& pair : proxy_hosts_) { | 1583 for (const auto& pair : proxy_hosts_) { |
1580 child->render_manager()->CreateRenderFrameProxy( | 1584 child->render_manager()->CreateRenderFrameProxy( |
1581 pair.second->GetSiteInstance()); | 1585 pair.second->GetSiteInstance()); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2110 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2114 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
2111 SiteInstance* instance) { | 2115 SiteInstance* instance) { |
2112 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2116 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
2113 if (iter != proxy_hosts_.end()) { | 2117 if (iter != proxy_hosts_.end()) { |
2114 delete iter->second; | 2118 delete iter->second; |
2115 proxy_hosts_.erase(iter); | 2119 proxy_hosts_.erase(iter); |
2116 } | 2120 } |
2117 } | 2121 } |
2118 | 2122 |
2119 } // namespace content | 2123 } // namespace content |
OLD | NEW |