Chromium Code Reviews| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 | |
| 1462 // Swapped out views should always be hidden. | 1475 // Swapped out views should always be hidden. |
| 1463 DCHECK(!swapped_out || (flags & CREATE_RF_HIDDEN)); | 1476 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 | 1477 |
| 1470 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 1478 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
| 1471 bool success = true; | 1479 bool success = true; |
| 1472 if (view_routing_id_ptr) | 1480 if (view_routing_id_ptr) |
| 1473 *view_routing_id_ptr = MSG_ROUTING_NONE; | 1481 *view_routing_id_ptr = MSG_ROUTING_NONE; |
| 1474 | 1482 |
| 1475 // We are creating a pending, speculative or swapped out RFH here. We should | 1483 // 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. | 1484 // never create it in the same SiteInstance as our current RFH. |
| 1477 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 1485 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
| 1478 | 1486 |
| 1479 // Check if we've already created an RFH for this SiteInstance. If so, try | 1487 // 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 | 1488 // 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. | 1489 // remove it from the list of proxy hosts below if it will be active. |
| 1482 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1490 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
| 1483 if (proxy && proxy->render_frame_host()) { | 1491 if (proxy && proxy->render_frame_host()) { |
| 1492 CHECK(!is_site_per_process); | |
| 1484 if (view_routing_id_ptr) | 1493 if (view_routing_id_ptr) |
| 1485 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); | 1494 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); |
| 1486 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 1495 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
| 1487 // Prevent the process from exiting while we're trying to use it. | 1496 // Prevent the process from exiting while we're trying to use it. |
| 1488 if (!swapped_out) { | 1497 if (!swapped_out) { |
| 1489 new_render_frame_host = proxy->PassFrameHostOwnership(); | 1498 new_render_frame_host = proxy->PassFrameHostOwnership(); |
| 1490 new_render_frame_host->GetProcess()->AddPendingView(); | 1499 new_render_frame_host->GetProcess()->AddPendingView(); |
| 1491 | 1500 |
| 1492 proxy_hosts_.erase(instance->GetId()); | 1501 proxy_hosts_.erase(instance->GetId()); |
| 1493 delete proxy; | 1502 delete proxy; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1520 // Remember that InitRenderView also created the RenderFrameProxy. | 1529 // Remember that InitRenderView also created the RenderFrameProxy. |
| 1521 if (swapped_out) | 1530 if (swapped_out) |
| 1522 proxy->set_render_frame_proxy_created(true); | 1531 proxy->set_render_frame_proxy_created(true); |
| 1523 if (frame_tree_node_->IsMainFrame()) { | 1532 if (frame_tree_node_->IsMainFrame()) { |
| 1524 // Don't show the main frame's view until we get a DidNavigate from it. | 1533 // 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 | 1534 // Only the RenderViewHost for the top-level RenderFrameHost has a |
| 1526 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes | 1535 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes |
| 1527 // will be created later and hidden. | 1536 // will be created later and hidden. |
| 1528 if (render_view_host->GetView()) | 1537 if (render_view_host->GetView()) |
| 1529 render_view_host->GetView()->Hide(); | 1538 render_view_host->GetView()->Hide(); |
| 1530 } else if (!swapped_out) { | 1539 } |
| 1540 // With --site-per-process, RenderViewHost for |instance| might exist | |
| 1541 // prior to calling CreateRenderFrame, due to a subframe in | |
| 1542 // |instance|. In such a case, InitRenderView will not create the | |
| 1543 // RenderFrame in the renderer process and it needs to be done | |
| 1544 // explicitly. | |
| 1545 if (is_site_per_process) { | |
|
Charlie Reis
2015/06/04 22:27:31
Thanks. The explanation helped, but it's still tr
nasko
2015/06/04 23:38:36
We should never be calling this method for default
Charlie Reis
2015/06/05 18:28:45
Acknowledged.
| |
| 1531 // Init the RFH, so a RenderFrame is created in the renderer. | 1546 // Init the RFH, so a RenderFrame is created in the renderer. |
| 1532 DCHECK(new_render_frame_host); | 1547 DCHECK(new_render_frame_host); |
| 1533 success = InitRenderFrame(new_render_frame_host.get()); | 1548 success = InitRenderFrame(new_render_frame_host.get()); |
| 1534 } | 1549 } |
| 1535 } | 1550 } |
| 1536 | 1551 |
| 1537 if (success) { | 1552 if (success) { |
| 1538 if (view_routing_id_ptr) | 1553 if (view_routing_id_ptr) |
| 1539 *view_routing_id_ptr = render_view_host->GetRoutingID(); | 1554 *view_routing_id_ptr = render_view_host->GetRoutingID(); |
| 1540 } | 1555 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1562 } | 1577 } |
| 1563 return nullptr; | 1578 return nullptr; |
| 1564 } | 1579 } |
| 1565 | 1580 |
| 1566 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) { | 1581 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) { |
| 1567 // A RenderFrameProxyHost should never be created in the same SiteInstance as | 1582 // A RenderFrameProxyHost should never be created in the same SiteInstance as |
| 1568 // the current RFH. | 1583 // the current RFH. |
| 1569 CHECK(instance); | 1584 CHECK(instance); |
| 1570 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); | 1585 CHECK_NE(instance, render_frame_host_->GetSiteInstance()); |
| 1571 | 1586 |
| 1587 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1588 switches::kSitePerProcess); | |
| 1589 RenderViewHostImpl* render_view_host = nullptr; | |
| 1590 | |
| 1591 // Ensure a RenderViewHost exists for |instance|, as it creates the page | |
| 1592 // level structure in Blink. | |
| 1593 if (is_site_per_process) { | |
| 1594 render_view_host = | |
| 1595 frame_tree_node_->frame_tree()->GetRenderViewHost(instance); | |
| 1596 if (!render_view_host) { | |
| 1597 CHECK(frame_tree_node_->IsMainFrame()); | |
| 1598 render_view_host = frame_tree_node_->frame_tree()->CreateRenderViewHost( | |
| 1599 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, true, true); | |
| 1600 } | |
| 1601 } | |
| 1602 | |
| 1572 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1603 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
| 1573 if (proxy && proxy->is_render_frame_proxy_live()) | 1604 if (proxy && proxy->is_render_frame_proxy_live()) |
| 1574 return proxy->GetRoutingID(); | 1605 return proxy->GetRoutingID(); |
| 1575 | 1606 |
| 1576 if (!proxy) { | 1607 if (!proxy) { |
| 1577 proxy = new RenderFrameProxyHost( | 1608 proxy = new RenderFrameProxyHost( |
| 1578 instance, frame_tree_node_->frame_tree()->GetRenderViewHost(instance), | 1609 instance, render_view_host, frame_tree_node_); |
| 1579 frame_tree_node_); | |
| 1580 proxy_hosts_[instance->GetId()] = proxy; | 1610 proxy_hosts_[instance->GetId()] = proxy; |
| 1581 } | 1611 } |
| 1582 proxy->InitRenderFrameProxy(); | 1612 |
| 1613 if (is_site_per_process && frame_tree_node_->IsMainFrame()) { | |
| 1614 InitRenderView( | |
| 1615 render_view_host, MSG_ROUTING_NONE, proxy->GetRoutingID(), true); | |
| 1616 proxy->set_render_frame_proxy_created(true); | |
| 1617 } else { | |
| 1618 proxy->InitRenderFrameProxy(); | |
| 1619 } | |
| 1620 | |
| 1583 return proxy->GetRoutingID(); | 1621 return proxy->GetRoutingID(); |
| 1584 } | 1622 } |
| 1585 | 1623 |
| 1586 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { | 1624 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { |
| 1587 for (const auto& pair : proxy_hosts_) { | 1625 for (const auto& pair : proxy_hosts_) { |
| 1588 child->render_manager()->CreateRenderFrameProxy( | 1626 child->render_manager()->CreateRenderFrameProxy( |
| 1589 pair.second->GetSiteInstance()); | 1627 pair.second->GetSiteInstance()); |
| 1590 } | 1628 } |
| 1591 } | 1629 } |
| 1592 | 1630 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1606 InitRenderView(render_view_host, opener_route_id, proxy->GetRoutingID(), | 1644 InitRenderView(render_view_host, opener_route_id, proxy->GetRoutingID(), |
| 1607 source->IsMainFrame()); | 1645 source->IsMainFrame()); |
| 1608 proxy->set_render_frame_proxy_created(true); | 1646 proxy->set_render_frame_proxy_created(true); |
| 1609 } | 1647 } |
| 1610 | 1648 |
| 1611 bool RenderFrameHostManager::InitRenderView( | 1649 bool RenderFrameHostManager::InitRenderView( |
| 1612 RenderViewHostImpl* render_view_host, | 1650 RenderViewHostImpl* render_view_host, |
| 1613 int opener_route_id, | 1651 int opener_route_id, |
| 1614 int proxy_routing_id, | 1652 int proxy_routing_id, |
| 1615 bool for_main_frame_navigation) { | 1653 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 | 1654 // Ensure the renderer process is initialized before creating the |
| 1621 // RenderView. | 1655 // RenderView. |
| 1622 if (!render_view_host->GetProcess()->Init()) | 1656 if (!render_view_host->GetProcess()->Init()) |
| 1623 return false; | 1657 return false; |
| 1624 | 1658 |
| 1659 // We may have initialized this RenderViewHost for another RenderFrameHost. | |
| 1660 if (render_view_host->IsRenderViewLive()) | |
| 1661 return true; | |
| 1662 | |
| 1625 // If the ongoing navigation is to a WebUI and the RenderView is not in a | 1663 // 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 | 1664 // guest process, tell the RenderViewHost about any bindings it will need |
| 1627 // enabled. | 1665 // enabled. |
| 1628 WebUIImpl* dest_web_ui = nullptr; | 1666 WebUIImpl* dest_web_ui = nullptr; |
| 1629 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1667 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1630 switches::kEnableBrowserSideNavigation)) { | 1668 switches::kEnableBrowserSideNavigation)) { |
| 1631 dest_web_ui = | 1669 dest_web_ui = |
| 1632 should_reuse_web_ui_ ? web_ui_.get() : speculative_web_ui_.get(); | 1670 should_reuse_web_ui_ ? web_ui_.get() : speculative_web_ui_.get(); |
| 1633 } else { | 1671 } else { |
| 1634 dest_web_ui = pending_web_ui(); | 1672 dest_web_ui = pending_web_ui(); |
| 1635 } | 1673 } |
| 1636 if (dest_web_ui && !render_view_host->GetProcess()->IsIsolatedGuest()) { | 1674 if (dest_web_ui && !render_view_host->GetProcess()->IsIsolatedGuest()) { |
| 1637 render_view_host->AllowBindings(dest_web_ui->GetBindings()); | 1675 render_view_host->AllowBindings(dest_web_ui->GetBindings()); |
| 1638 } else { | 1676 } else { |
| 1639 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled | 1677 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled |
| 1640 // process unless it's swapped out. | 1678 // process unless it's swapped out. |
| 1641 if (render_view_host->is_active()) { | 1679 if (render_view_host->is_active()) { |
| 1642 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 1680 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 1643 render_view_host->GetProcess()->GetID())); | 1681 render_view_host->GetProcess()->GetID())); |
| 1644 } | 1682 } |
| 1645 } | 1683 } |
| 1646 | 1684 |
| 1647 return delegate_->CreateRenderViewForRenderManager(render_view_host, | 1685 return delegate_->CreateRenderViewForRenderManager( |
| 1648 opener_route_id, | 1686 render_view_host, |
| 1649 proxy_routing_id, | 1687 opener_route_id, |
| 1650 for_main_frame_navigation); | 1688 proxy_routing_id, |
| 1689 frame_tree_node_->current_replication_state(), | |
| 1690 for_main_frame_navigation); | |
| 1651 } | 1691 } |
| 1652 | 1692 |
| 1653 bool RenderFrameHostManager::InitRenderFrame( | 1693 bool RenderFrameHostManager::InitRenderFrame( |
| 1654 RenderFrameHostImpl* render_frame_host) { | 1694 RenderFrameHostImpl* render_frame_host) { |
| 1655 if (render_frame_host->IsRenderFrameLive()) | 1695 if (render_frame_host->IsRenderFrameLive()) |
| 1656 return true; | 1696 return true; |
| 1657 | 1697 |
| 1658 int parent_routing_id = MSG_ROUTING_NONE; | 1698 int parent_routing_id = MSG_ROUTING_NONE; |
| 1659 int previous_sibling_routing_id = MSG_ROUTING_NONE; | 1699 int previous_sibling_routing_id = MSG_ROUTING_NONE; |
| 1660 int proxy_routing_id = MSG_ROUTING_NONE; | 1700 int proxy_routing_id = MSG_ROUTING_NONE; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1710 | 1750 |
| 1711 return MSG_ROUTING_NONE; | 1751 return MSG_ROUTING_NONE; |
| 1712 } | 1752 } |
| 1713 | 1753 |
| 1714 void RenderFrameHostManager::CommitPending() { | 1754 void RenderFrameHostManager::CommitPending() { |
| 1715 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", | 1755 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", |
| 1716 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 1756 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 1717 bool browser_side_navigation = | 1757 bool browser_side_navigation = |
| 1718 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1758 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1719 switches::kEnableBrowserSideNavigation); | 1759 switches::kEnableBrowserSideNavigation); |
| 1760 bool is_site_per_process = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1761 switches::kSitePerProcess); | |
| 1762 | |
| 1720 // First check whether we're going to want to focus the location bar after | 1763 // 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 | 1764 // 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 | 1765 // 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. | 1766 // this triggers won't be able to figure out what's going on. |
| 1724 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1767 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
| 1725 | 1768 |
| 1726 // Next commit the Web UI, if any. Either replace |web_ui_| with | 1769 // 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 | 1770 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
| 1728 // leave |web_ui_| as is if reusing it. | 1771 // leave |web_ui_| as is if reusing it. |
| 1729 DCHECK(!(pending_web_ui_ && pending_and_current_web_ui_)); | 1772 DCHECK(!(pending_web_ui_ && pending_and_current_web_ui_)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1811 delegate_->SetFocusToLocationBar(false); | 1854 delegate_->SetFocusToLocationBar(false); |
| 1812 } else if (focus_render_view && render_frame_host_->GetView()) { | 1855 } else if (focus_render_view && render_frame_host_->GetView()) { |
| 1813 render_frame_host_->GetView()->Focus(); | 1856 render_frame_host_->GetView()->Focus(); |
| 1814 } | 1857 } |
| 1815 | 1858 |
| 1816 // Notify that we've swapped RenderFrameHosts. We do this before shutting down | 1859 // 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. | 1860 // the RFH so that we can clean up RendererResources related to the RFH first. |
| 1818 delegate_->NotifySwappedFromRenderManager( | 1861 delegate_->NotifySwappedFromRenderManager( |
| 1819 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); | 1862 old_render_frame_host.get(), render_frame_host_.get(), is_main_frame); |
| 1820 | 1863 |
| 1864 // The RenderViewHost keeps track of the main RenderFrameHost routing id. | |
| 1865 // If this is committing a main frame navigation, update it and set the | |
| 1866 // routing id in the RenderViewHost associated with the old RenderFrameHost | |
| 1867 // to MSG_ROUTING_NONE. | |
| 1868 if (is_main_frame && is_site_per_process) { | |
| 1869 render_frame_host_->render_view_host()->set_main_frame_routing_id( | |
| 1870 render_frame_host_->routing_id()); | |
| 1871 old_render_frame_host->render_view_host()->set_main_frame_routing_id( | |
| 1872 MSG_ROUTING_NONE); | |
| 1873 } | |
| 1874 | |
| 1821 // Swap out the old frame now that the new one is visible. | 1875 // 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 | 1876 // 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 | 1877 // 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). | 1878 // 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 | 1879 // In the --site-per-process case, old subframe RHFs are not kept alive inside |
| 1826 // the proxy. | 1880 // the proxy. |
| 1827 SwapOutOldFrame(old_render_frame_host.Pass()); | 1881 SwapOutOldFrame(old_render_frame_host.Pass()); |
| 1828 | 1882 |
| 1829 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1883 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 | 1884 // Since the new RenderFrameHost is now committed, there must be no proxies |
| 1833 // for its SiteInstance. Delete any existing ones. | 1885 // for its SiteInstance. Delete any existing ones. |
| 1834 RenderFrameProxyHostMap::iterator iter = | 1886 RenderFrameProxyHostMap::iterator iter = |
| 1835 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); | 1887 proxy_hosts_.find(render_frame_host_->GetSiteInstance()->GetId()); |
| 1836 if (iter != proxy_hosts_.end()) { | 1888 if (iter != proxy_hosts_.end()) { |
| 1837 delete iter->second; | 1889 delete iter->second; |
| 1838 proxy_hosts_.erase(iter); | 1890 proxy_hosts_.erase(iter); |
| 1839 } | 1891 } |
| 1840 | 1892 |
| 1841 // If this is a subframe, it should have a CrossProcessFrameConnector | 1893 // If this is a subframe, it should have a CrossProcessFrameConnector |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2123 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2175 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 2124 SiteInstance* instance) { | 2176 SiteInstance* instance) { |
| 2125 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2177 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
| 2126 if (iter != proxy_hosts_.end()) { | 2178 if (iter != proxy_hosts_.end()) { |
| 2127 delete iter->second; | 2179 delete iter->second; |
| 2128 proxy_hosts_.erase(iter); | 2180 proxy_hosts_.erase(iter); |
| 2129 } | 2181 } |
| 2130 } | 2182 } |
| 2131 | 2183 |
| 2132 } // namespace content | 2184 } // namespace content |
| OLD | NEW |