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