Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 1142123002: Remove swapped-out usage in --site-per-process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another round of fixes. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 // If the current render_frame_host_ isn't live, we should create it so 198 // If the current render_frame_host_ isn't live, we should create it so
199 // that we don't show a sad tab while the dest_render_frame_host fetches 199 // that we don't show a sad tab while the dest_render_frame_host fetches
200 // its first page. (Bug 1145340) 200 // its first page. (Bug 1145340)
201 if (dest_render_frame_host != render_frame_host_ && 201 if (dest_render_frame_host != render_frame_host_ &&
202 !render_frame_host_->IsRenderFrameLive()) { 202 !render_frame_host_->IsRenderFrameLive()) {
203 // Note: we don't call InitRenderView here because we are navigating away 203 // Note: we don't call InitRenderView here because we are navigating away
204 // soon anyway, and we don't have the NavigationEntry for this host. 204 // soon anyway, and we don't have the NavigationEntry for this host.
205 delegate_->CreateRenderViewForRenderManager( 205 delegate_->CreateRenderViewForRenderManager(
206 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, 206 render_frame_host_->render_view_host(), MSG_ROUTING_NONE,
207 MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame()); 207 MSG_ROUTING_NONE, frame_tree_node_->current_replication_state(),
208 frame_tree_node_->IsMainFrame());
208 } 209 }
209 210
210 // If the renderer crashed, then try to create a new one to satisfy this 211 // If the renderer crashed, then try to create a new one to satisfy this
211 // navigation request. 212 // navigation request.
212 if (!dest_render_frame_host->IsRenderFrameLive()) { 213 if (!dest_render_frame_host->IsRenderFrameLive()) {
213 // Instruct the destination render frame host to set up a Mojo connection 214 // Instruct the destination render frame host to set up a Mojo connection
214 // with the new render frame if necessary. Note that this call needs to 215 // with the new render frame if necessary. Note that this call needs to
215 // occur before initializing the RenderView; the flow of creating the 216 // occur before initializing the RenderView; the flow of creating the
216 // RenderView can cause browser-side code to execute that expects the this 217 // RenderView can cause browser-side code to execute that expects the this
217 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI 218 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 old_render_frame_host->render_view_host(), frame_tree_node_); 603 old_render_frame_host->render_view_host(), frame_tree_node_);
603 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)
604 << "Inserting a duplicate item."; 605 << "Inserting a duplicate item.";
605 606
606 // 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.
607 old_render_frame_host->SwapOut(proxy, true); 608 old_render_frame_host->SwapOut(proxy, true);
608 609
609 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized. 610 // SwapOut creates a RenderFrameProxy, so set the proxy to be initialized.
610 proxy->set_render_frame_proxy_created(true); 611 proxy->set_render_frame_proxy_created(true);
611 612
612 bool is_main_frame = frame_tree_node_->IsMainFrame();
613 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 613 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
614 switches::kSitePerProcess) && 614 switches::kSitePerProcess)) {
615 !is_main_frame) { 615 // In --site-per-process, frames delete their RFH rather than storing it
616 // In --site-per-process, subframes delete their RFH rather than storing it
617 // in the proxy. Schedule it for deletion once the SwapOutACK comes in. 616 // in the proxy. Schedule it for deletion once the SwapOutACK comes in.
618 // TODO(creis): This will be the default when we remove swappedout://. 617 // TODO(creis): This will be the default when we remove swappedout://.
619 MoveToPendingDeleteHosts(old_render_frame_host.Pass()); 618 MoveToPendingDeleteHosts(old_render_frame_host.Pass());
620 } else { 619 } else {
621 // We shouldn't get here for subframes, since we only swap subframes when 620 // We shouldn't get here for subframes, since we only swap subframes when
622 // --site-per-process is used. 621 // --site-per-process is used.
623 DCHECK(is_main_frame); 622 DCHECK(frame_tree_node_->IsMainFrame());
624 623
625 // The old RenderFrameHost will stay alive inside the proxy so that existing 624 // The old RenderFrameHost will stay alive inside the proxy so that existing
626 // JavaScript window references to it stay valid. 625 // JavaScript window references to it stay valid.
627 proxy->TakeFrameHostOwnership(old_render_frame_host.Pass()); 626 proxy->TakeFrameHostOwnership(old_render_frame_host.Pass());
628 } 627 }
629 } 628 }
630 629
631 void RenderFrameHostManager::DiscardUnusedFrame( 630 void RenderFrameHostManager::DiscardUnusedFrame(
632 scoped_ptr<RenderFrameHostImpl> render_frame_host) { 631 scoped_ptr<RenderFrameHostImpl> render_frame_host) {
633 // TODO(carlosk): this code is very similar to what can be found in 632 // TODO(carlosk): this code is very similar to what can be found in
634 // SwapOutOldFrame and we should see that these are unified at some point. 633 // SwapOutOldFrame and we should see that these are unified at some point.
635 634
636 // 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
637 // 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.
637 // In --site-per-process, RenderFrameHosts are not kept around and are
638 // deleted when not used, replaced by RenderFrameProxyHosts.
638 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); 639 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance();
639 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { 640 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) {
640 // Any currently suspended navigations are no longer needed. 641 // Any currently suspended navigations are no longer needed.
641 render_frame_host->CancelSuspendedNavigations(); 642 render_frame_host->CancelSuspendedNavigations();
642 643
643 CHECK(!GetRenderFrameProxyHost(site_instance)); 644 CHECK(!GetRenderFrameProxyHost(site_instance));
644 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( 645 RenderFrameProxyHost* proxy = new RenderFrameProxyHost(
645 site_instance, render_frame_host->render_view_host(), frame_tree_node_); 646 site_instance, render_frame_host->render_view_host(), frame_tree_node_);
646 proxy_hosts_[site_instance->GetId()] = proxy; 647 proxy_hosts_[site_instance->GetId()] = proxy;
647 648
648 // Check if the RenderFrameHost is already swapped out, to avoid swapping it 649 // Check if the RenderFrameHost is already swapped out, to avoid swapping it
649 // out again. 650 // out again.
650 if (!render_frame_host->is_swapped_out()) 651 if (!render_frame_host->is_swapped_out())
651 render_frame_host->SwapOut(proxy, false); 652 render_frame_host->SwapOut(proxy, false);
652 653
653 if (frame_tree_node_->IsMainFrame()) 654 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
655 switches::kSitePerProcess)) {
656 DCHECK(frame_tree_node_->IsMainFrame());
654 proxy->TakeFrameHostOwnership(render_frame_host.Pass()); 657 proxy->TakeFrameHostOwnership(render_frame_host.Pass());
655 } else { 658 }
659 }
660
661 if (render_frame_host) {
656 // We won't be coming back, so delete this one. 662 // We won't be coming back, so delete this one.
657 ShutdownProxiesIfLastActiveFrameInSiteInstance(render_frame_host.get()); 663 ShutdownProxiesIfLastActiveFrameInSiteInstance(render_frame_host.get());
658 render_frame_host.reset(); 664 render_frame_host.reset();
659 } 665 }
660 } 666 }
661 667
662 void RenderFrameHostManager::MoveToPendingDeleteHosts( 668 void RenderFrameHostManager::MoveToPendingDeleteHosts(
663 scoped_ptr<RenderFrameHostImpl> render_frame_host) { 669 scoped_ptr<RenderFrameHostImpl> render_frame_host) {
664 // |render_frame_host| will be deleted when its SwapOut ACK is received, or 670 // |render_frame_host| will be deleted when its SwapOut ACK is received, or
665 // when the timer times out, or when the RFHM itself is deleted (whichever 671 // when the timer times out, or when the RFHM itself is deleted (whichever
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 RenderFrameProxyHostMap::iterator iter = 919 RenderFrameProxyHostMap::iterator iter =
914 node->render_manager()->proxy_hosts_.find(site_instance_id); 920 node->render_manager()->proxy_hosts_.find(site_instance_id);
915 if (iter != node->render_manager()->proxy_hosts_.end()) { 921 if (iter != node->render_manager()->proxy_hosts_.end()) {
916 RenderFrameProxyHost* proxy = iter->second; 922 RenderFrameProxyHost* proxy = iter->second;
917 // Delete the proxy. If it is for a main frame (and thus the RFH is stored 923 // Delete the proxy. If it is for a main frame (and thus the RFH is stored
918 // in the proxy) and it was still pending swap out, move the RFH to the 924 // in the proxy) and it was still pending swap out, move the RFH to the
919 // pending deletion list first. 925 // pending deletion list first.
920 if (node->IsMainFrame() && 926 if (node->IsMainFrame() &&
921 proxy->render_frame_host() && 927 proxy->render_frame_host() &&
922 proxy->render_frame_host()->rfh_state() == 928 proxy->render_frame_host()->rfh_state() ==
923 RenderFrameHostImpl::STATE_PENDING_SWAP_OUT) { 929 RenderFrameHostImpl::STATE_PENDING_SWAP_OUT) {
930 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
931 switches::kSitePerProcess));
924 scoped_ptr<RenderFrameHostImpl> swapped_out_rfh = 932 scoped_ptr<RenderFrameHostImpl> swapped_out_rfh =
925 proxy->PassFrameHostOwnership(); 933 proxy->PassFrameHostOwnership();
926 node->render_manager()->MoveToPendingDeleteHosts(swapped_out_rfh.Pass()); 934 node->render_manager()->MoveToPendingDeleteHosts(swapped_out_rfh.Pass());
927 } 935 }
928 delete proxy; 936 delete proxy;
929 node->render_manager()->proxy_hosts_.erase(site_instance_id); 937 node->render_manager()->proxy_hosts_.erase(site_instance_id);
930 } 938 }
931 939
932 return true; 940 return true;
933 } 941 }
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 return true; 1459 return true;
1452 } 1460 }
1453 1461
1454 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( 1462 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame(
1455 SiteInstance* instance, 1463 SiteInstance* instance,
1456 WebUIImpl* web_ui, 1464 WebUIImpl* web_ui,
1457 int opener_route_id, 1465 int opener_route_id,
1458 int flags, 1466 int flags,
1459 int* view_routing_id_ptr) { 1467 int* view_routing_id_ptr) {
1460 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); 1468 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT);
1469 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
1470 switches::kSitePerProcess);
1471
1461 CHECK(instance); 1472 CHECK(instance);
1473 CHECK_IMPLIES(is_site_per_process, !swapped_out);
1474 CHECK_IMPLIES(!is_site_per_process, frame_tree_node_->IsMainFrame());
1475
1462 // Swapped out views should always be hidden. 1476 // Swapped out views should always be hidden.
1463 DCHECK(!swapped_out || (flags & CREATE_RF_HIDDEN)); 1477 DCHECK_IMPLIES(swapped_out, (flags & CREATE_RF_HIDDEN));
1464
1465 // TODO(nasko): Remove the following CHECK once cross-process navigation no
1466 // longer relies on swapped out RFH for the top-level frame.
1467 if (!frame_tree_node_->IsMainFrame())
1468 CHECK(!swapped_out);
1469 1478
1470 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; 1479 scoped_ptr<RenderFrameHostImpl> new_render_frame_host;
1471 bool success = true; 1480 bool success = true;
1472 if (view_routing_id_ptr) 1481 if (view_routing_id_ptr)
1473 *view_routing_id_ptr = MSG_ROUTING_NONE; 1482 *view_routing_id_ptr = MSG_ROUTING_NONE;
1474 1483
1475 // We are creating a pending, speculative or swapped out RFH here. We should 1484 // We are creating a pending, speculative or swapped out RFH here. We should
1476 // never create it in the same SiteInstance as our current RFH. 1485 // never create it in the same SiteInstance as our current RFH.
1477 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); 1486 CHECK_NE(render_frame_host_->GetSiteInstance(), instance);
1478 1487
1479 // Check if we've already created an RFH for this SiteInstance. If so, try 1488 // Check if we've already created an RFH for this SiteInstance. If so, try
1480 // to re-use the existing one, which has already been initialized. We'll 1489 // to re-use the existing one, which has already been initialized. We'll
1481 // remove it from the list of proxy hosts below if it will be active. 1490 // remove it from the list of proxy hosts below if it will be active.
1482 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); 1491 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
1483 if (proxy && proxy->render_frame_host()) { 1492 if (proxy && proxy->render_frame_host()) {
1493 CHECK(!is_site_per_process);
1484 if (view_routing_id_ptr) 1494 if (view_routing_id_ptr)
1485 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); 1495 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID();
1486 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. 1496 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost.
1487 // Prevent the process from exiting while we're trying to use it. 1497 // Prevent the process from exiting while we're trying to use it.
1488 if (!swapped_out) { 1498 if (!swapped_out) {
1489 new_render_frame_host = proxy->PassFrameHostOwnership(); 1499 new_render_frame_host = proxy->PassFrameHostOwnership();
1490 new_render_frame_host->GetProcess()->AddPendingView(); 1500 new_render_frame_host->GetProcess()->AddPendingView();
1491 1501
1492 proxy_hosts_.erase(instance->GetId()); 1502 proxy_hosts_.erase(instance->GetId());
1493 delete proxy; 1503 delete proxy;
(...skipping 26 matching lines...) Expand all
1520 // Remember that InitRenderView also created the RenderFrameProxy. 1530 // Remember that InitRenderView also created the RenderFrameProxy.
1521 if (swapped_out) 1531 if (swapped_out)
1522 proxy->set_render_frame_proxy_created(true); 1532 proxy->set_render_frame_proxy_created(true);
1523 if (frame_tree_node_->IsMainFrame()) { 1533 if (frame_tree_node_->IsMainFrame()) {
1524 // Don't show the main frame's view until we get a DidNavigate from it. 1534 // Don't show the main frame's view until we get a DidNavigate from it.
1525 // Only the RenderViewHost for the top-level RenderFrameHost has a 1535 // Only the RenderViewHost for the top-level RenderFrameHost has a
1526 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes 1536 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes
1527 // will be created later and hidden. 1537 // will be created later and hidden.
1528 if (render_view_host->GetView()) 1538 if (render_view_host->GetView())
1529 render_view_host->GetView()->Hide(); 1539 render_view_host->GetView()->Hide();
1530 } else if (!swapped_out) { 1540 }
1541 // With --site-per-process, RenderViewHost for |instance| might exist
1542 // prior to calling CreateRenderFrame, due to a subframe in
1543 // |instance|. In such a case, InitRenderView will not create the
1544 // RenderFrame in the renderer process and it needs to be done
1545 // explicitly.
1546 if (is_site_per_process) {
1531 // Init the RFH, so a RenderFrame is created in the renderer. 1547 // Init the RFH, so a RenderFrame is created in the renderer.
1532 DCHECK(new_render_frame_host); 1548 DCHECK(new_render_frame_host);
1533 success = InitRenderFrame(new_render_frame_host.get()); 1549 success = InitRenderFrame(new_render_frame_host.get());
1534 } 1550 }
1535 } 1551 }
1536 1552
1537 if (success) { 1553 if (success) {
1538 if (view_routing_id_ptr) 1554 if (view_routing_id_ptr)
1539 *view_routing_id_ptr = render_view_host->GetRoutingID(); 1555 *view_routing_id_ptr = render_view_host->GetRoutingID();
1540 } 1556 }
(...skipping 21 matching lines...) Expand all
1562 } 1578 }
1563 return nullptr; 1579 return nullptr;
1564 } 1580 }
1565 1581
1566 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) { 1582 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) {
1567 // A RenderFrameProxyHost should never be created in the same SiteInstance as 1583 // A RenderFrameProxyHost should never be created in the same SiteInstance as
1568 // the current RFH. 1584 // the current RFH.
1569 CHECK(instance); 1585 CHECK(instance);
1570 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); 1586 CHECK_NE(instance, render_frame_host_->GetSiteInstance());
1571 1587
1588 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
1589 switches::kSitePerProcess);
1590 RenderViewHostImpl* render_view_host = nullptr;
1591
1592 // Ensure a RenderViewHost exists for |instance|, as it creates the page
1593 // level structure in Blink.
1594 if (is_site_per_process) {
1595 render_view_host =
1596 frame_tree_node_->frame_tree()->GetRenderViewHost(instance);
1597 if (!render_view_host) {
1598 CHECK(frame_tree_node_->IsMainFrame());
1599 render_view_host = frame_tree_node_->frame_tree()->CreateRenderViewHost(
1600 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, true, true);
1601 }
1602 }
1603
1572 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); 1604 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
1573 if (proxy && proxy->is_render_frame_proxy_live()) 1605 if (proxy && proxy->is_render_frame_proxy_live())
1574 return proxy->GetRoutingID(); 1606 return proxy->GetRoutingID();
1575 1607
1576 if (!proxy) { 1608 if (!proxy) {
1577 proxy = new RenderFrameProxyHost( 1609 proxy = new RenderFrameProxyHost(
1578 instance, frame_tree_node_->frame_tree()->GetRenderViewHost(instance), 1610 instance, render_view_host, frame_tree_node_);
1579 frame_tree_node_);
1580 proxy_hosts_[instance->GetId()] = proxy; 1611 proxy_hosts_[instance->GetId()] = proxy;
1581 } 1612 }
1582 proxy->InitRenderFrameProxy(); 1613
1614 if (is_site_per_process && frame_tree_node_->IsMainFrame()) {
1615 InitRenderView(
1616 render_view_host, MSG_ROUTING_NONE, proxy->GetRoutingID(), true);
1617 proxy->set_render_frame_proxy_created(true);
1618 } else {
1619 proxy->InitRenderFrameProxy();
1620 }
1621
1583 return proxy->GetRoutingID(); 1622 return proxy->GetRoutingID();
1584 } 1623 }
1585 1624
1586 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { 1625 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) {
1587 for (const auto& pair : proxy_hosts_) { 1626 for (const auto& pair : proxy_hosts_) {
1588 child->render_manager()->CreateRenderFrameProxy( 1627 child->render_manager()->CreateRenderFrameProxy(
1589 pair.second->GetSiteInstance()); 1628 pair.second->GetSiteInstance());
1590 } 1629 }
1591 } 1630 }
1592 1631
(...skipping 13 matching lines...) Expand all
1606 InitRenderView(render_view_host, opener_route_id, proxy->GetRoutingID(), 1645 InitRenderView(render_view_host, opener_route_id, proxy->GetRoutingID(),
1607 source->IsMainFrame()); 1646 source->IsMainFrame());
1608 proxy->set_render_frame_proxy_created(true); 1647 proxy->set_render_frame_proxy_created(true);
1609 } 1648 }
1610 1649
1611 bool RenderFrameHostManager::InitRenderView( 1650 bool RenderFrameHostManager::InitRenderView(
1612 RenderViewHostImpl* render_view_host, 1651 RenderViewHostImpl* render_view_host,
1613 int opener_route_id, 1652 int opener_route_id,
1614 int proxy_routing_id, 1653 int proxy_routing_id,
1615 bool for_main_frame_navigation) { 1654 bool for_main_frame_navigation) {
1616 // We may have initialized this RenderViewHost for another RenderFrameHost.
1617 if (render_view_host->IsRenderViewLive())
1618 return true;
1619
1620 // Ensure the renderer process is initialized before creating the 1655 // Ensure the renderer process is initialized before creating the
1621 // RenderView. 1656 // RenderView.
1622 if (!render_view_host->GetProcess()->Init()) 1657 if (!render_view_host->GetProcess()->Init())
1623 return false; 1658 return false;
1624 1659
1660 // We may have initialized this RenderViewHost for another RenderFrameHost.
1661 if (render_view_host->IsRenderViewLive())
1662 return true;
1663
1625 // If the ongoing navigation is to a WebUI and the RenderView is not in a 1664 // If the ongoing navigation is to a WebUI and the RenderView is not in a
1626 // guest process, tell the RenderViewHost about any bindings it will need 1665 // guest process, tell the RenderViewHost about any bindings it will need
1627 // enabled. 1666 // enabled.
1628 WebUIImpl* dest_web_ui = nullptr; 1667 WebUIImpl* dest_web_ui = nullptr;
1629 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1668 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1630 switches::kEnableBrowserSideNavigation)) { 1669 switches::kEnableBrowserSideNavigation)) {
1631 dest_web_ui = 1670 dest_web_ui =
1632 should_reuse_web_ui_ ? web_ui_.get() : speculative_web_ui_.get(); 1671 should_reuse_web_ui_ ? web_ui_.get() : speculative_web_ui_.get();
1633 } else { 1672 } else {
1634 dest_web_ui = pending_web_ui(); 1673 dest_web_ui = pending_web_ui();
1635 } 1674 }
1636 if (dest_web_ui && !render_view_host->GetProcess()->IsIsolatedGuest()) { 1675 if (dest_web_ui && !render_view_host->GetProcess()->IsIsolatedGuest()) {
1637 render_view_host->AllowBindings(dest_web_ui->GetBindings()); 1676 render_view_host->AllowBindings(dest_web_ui->GetBindings());
1638 } else { 1677 } else {
1639 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled 1678 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled
1640 // process unless it's swapped out. 1679 // process unless it's swapped out.
1641 if (render_view_host->is_active()) { 1680 if (render_view_host->is_active()) {
1642 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 1681 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
1643 render_view_host->GetProcess()->GetID())); 1682 render_view_host->GetProcess()->GetID()));
1644 } 1683 }
1645 } 1684 }
1646 1685
1647 return delegate_->CreateRenderViewForRenderManager(render_view_host, 1686 return delegate_->CreateRenderViewForRenderManager(
1648 opener_route_id, 1687 render_view_host,
1649 proxy_routing_id, 1688 opener_route_id,
1650 for_main_frame_navigation); 1689 proxy_routing_id,
1690 frame_tree_node_->current_replication_state(),
1691 for_main_frame_navigation);
1651 } 1692 }
1652 1693
1653 bool RenderFrameHostManager::InitRenderFrame( 1694 bool RenderFrameHostManager::InitRenderFrame(
1654 RenderFrameHostImpl* render_frame_host) { 1695 RenderFrameHostImpl* render_frame_host) {
1655 if (render_frame_host->IsRenderFrameLive()) 1696 if (render_frame_host->IsRenderFrameLive())
1656 return true; 1697 return true;
1657 1698
1658 int parent_routing_id = MSG_ROUTING_NONE; 1699 int parent_routing_id = MSG_ROUTING_NONE;
1659 int previous_sibling_routing_id = MSG_ROUTING_NONE; 1700 int previous_sibling_routing_id = MSG_ROUTING_NONE;
1660 int proxy_routing_id = MSG_ROUTING_NONE; 1701 int proxy_routing_id = MSG_ROUTING_NONE;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 1751
1711 return MSG_ROUTING_NONE; 1752 return MSG_ROUTING_NONE;
1712 } 1753 }
1713 1754
1714 void RenderFrameHostManager::CommitPending() { 1755 void RenderFrameHostManager::CommitPending() {
1715 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", 1756 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending",
1716 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); 1757 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id());
1717 bool browser_side_navigation = 1758 bool browser_side_navigation =
1718 base::CommandLine::ForCurrentProcess()->HasSwitch( 1759 base::CommandLine::ForCurrentProcess()->HasSwitch(
1719 switches::kEnableBrowserSideNavigation); 1760 switches::kEnableBrowserSideNavigation);
1761 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
1762 switches::kSitePerProcess);
1763
1720 // First check whether we're going to want to focus the location bar after 1764 // First check whether we're going to want to focus the location bar after
1721 // this commit. We do this now because the navigation hasn't formally 1765 // this commit. We do this now because the navigation hasn't formally
1722 // committed yet, so if we've already cleared |pending_web_ui_| the call chain 1766 // committed yet, so if we've already cleared |pending_web_ui_| the call chain
1723 // this triggers won't be able to figure out what's going on. 1767 // this triggers won't be able to figure out what's going on.
1724 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); 1768 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault();
1725 1769
1726 // Next commit the Web UI, if any. Either replace |web_ui_| with 1770 // Next commit the Web UI, if any. Either replace |web_ui_| with
1727 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or 1771 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or
1728 // leave |web_ui_| as is if reusing it. 1772 // leave |web_ui_| as is if reusing it.
1729 DCHECK(!(pending_web_ui_ && pending_and_current_web_ui_)); 1773 DCHECK(!(pending_web_ui_ && pending_and_current_web_ui_));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 delegate_->SetFocusToLocationBar(false); 1855 delegate_->SetFocusToLocationBar(false);
1812 } else if (focus_render_view && render_frame_host_->GetView()) { 1856 } else if (focus_render_view && render_frame_host_->GetView()) {
1813 render_frame_host_->GetView()->Focus(); 1857 render_frame_host_->GetView()->Focus();
1814 } 1858 }
1815 1859
1816 // Notify that we've swapped RenderFrameHosts. We do this before shutting down 1860 // Notify that we've swapped RenderFrameHosts. We do this before shutting down
1817 // the RFH so that we can clean up RendererResources related to the RFH first. 1861 // the RFH so that we can clean up RendererResources related to the RFH first.
1818 delegate_->NotifySwappedFromRenderManager( 1862 delegate_->NotifySwappedFromRenderManager(
1819 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); 1863 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame);
1820 1864
1865 // The RenderViewHost keeps track of the main RenderFrameHost routing id.
1866 // If this is committing a main frame navigation, update it and set the
1867 // routing id in the RenderViewHost associated with the old RenderFrameHost
1868 // to MSG_ROUTING_NONE.
1869 if (is_main_frame && is_site_per_process) {
1870 render_frame_host_->render_view_host()->set_main_frame_routing_id(
1871 render_frame_host_->routing_id());
1872 old_render_frame_host->render_view_host()->set_main_frame_routing_id(
1873 MSG_ROUTING_NONE);
1874 }
1875
1821 // Swap out the old frame now that the new one is visible. 1876 // Swap out the old frame now that the new one is visible.
1822 // This will swap it out and then put it on the proxy list (if there are other 1877 // This will swap it out and then put it on the proxy list (if there are other
1823 // active views in its SiteInstance) or schedule it for deletion when the swap 1878 // active views in its SiteInstance) or schedule it for deletion when the swap
1824 // out ack arrives (or immediately if the process isn't live). 1879 // out ack arrives (or immediately if the process isn't live).
1825 // In the --site-per-process case, old subframe RHFs are not kept alive inside 1880 // In the --site-per-process case, old subframe RHFs are not kept alive inside
1826 // the proxy. 1881 // the proxy.
1827 SwapOutOldFrame(old_render_frame_host.Pass()); 1882 SwapOutOldFrame(old_render_frame_host.Pass());
1828 1883
1829 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1884 if (is_site_per_process) {
1830 switches::kSitePerProcess) &&
1831 !is_main_frame) {
1832 // Since the new RenderFrameHost is now committed, there must be no proxies 1885 // Since the new RenderFrameHost is now committed, there must be no proxies
1833 // for its SiteInstance. Delete any existing ones. 1886 // for its SiteInstance. Delete any existing ones.
1834 RenderFrameProxyHostMap::iterator iter = 1887 RenderFrameProxyHostMap::iterator iter =
1835 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); 1888 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId());
1836 if (iter != proxy_hosts_.end()) { 1889 if (iter != proxy_hosts_.end()) {
1837 delete iter->second; 1890 delete iter->second;
1838 proxy_hosts_.erase(iter); 1891 proxy_hosts_.erase(iter);
1839 } 1892 }
1840 1893
1841 // If this is a subframe, it should have a CrossProcessFrameConnector 1894 // If this is a subframe, it should have a CrossProcessFrameConnector
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 2176 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
2124 SiteInstance* instance) { 2177 SiteInstance* instance) {
2125 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 2178 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
2126 if (iter != proxy_hosts_.end()) { 2179 if (iter != proxy_hosts_.end()) {
2127 delete iter->second; 2180 delete iter->second;
2128 proxy_hosts_.erase(iter); 2181 proxy_hosts_.erase(iter);
2129 } 2182 }
2130 } 2183 }
2131 2184
2132 } // namespace content 2185 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698