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

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

Issue 1306053008: Avoid creating a RenderWidgetHostView for proxies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: only call InitRenderView when creating the main frame Created 5 years, 3 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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 // If the current render_frame_host_ isn't live, we should create it so 395 // If the current render_frame_host_ isn't live, we should create it so
396 // that we don't show a sad tab while the dest_render_frame_host fetches 396 // that we don't show a sad tab while the dest_render_frame_host fetches
397 // its first page. (Bug 1145340) 397 // its first page. (Bug 1145340)
398 if (dest_render_frame_host != render_frame_host_ && 398 if (dest_render_frame_host != render_frame_host_ &&
399 !render_frame_host_->IsRenderFrameLive()) { 399 !render_frame_host_->IsRenderFrameLive()) {
400 // Note: we don't call InitRenderView here because we are navigating away 400 // Note: we don't call InitRenderView here because we are navigating away
401 // soon anyway, and we don't have the NavigationEntry for this host. 401 // soon anyway, and we don't have the NavigationEntry for this host.
402 delegate_->CreateRenderViewForRenderManager( 402 delegate_->CreateRenderViewForRenderManager(
403 render_frame_host_->render_view_host(), MSG_ROUTING_NONE, 403 render_frame_host_->render_view_host(), MSG_ROUTING_NONE,
404 MSG_ROUTING_NONE, frame_tree_node_->current_replication_state(), 404 MSG_ROUTING_NONE, frame_tree_node_->current_replication_state());
405 frame_tree_node_->IsMainFrame());
406 } 405 }
407 406
408 // If the renderer crashed, then try to create a new one to satisfy this 407 // If the renderer crashed, then try to create a new one to satisfy this
409 // navigation request. 408 // navigation request.
410 if (!dest_render_frame_host->IsRenderFrameLive()) { 409 if (!dest_render_frame_host->IsRenderFrameLive()) {
411 // Instruct the destination render frame host to set up a Mojo connection 410 // Instruct the destination render frame host to set up a Mojo connection
412 // with the new render frame if necessary. Note that this call needs to 411 // with the new render frame if necessary. Note that this call needs to
413 // occur before initializing the RenderView; the flow of creating the 412 // occur before initializing the RenderView; the flow of creating the
414 // RenderView can cause browser-side code to execute that expects the this 413 // RenderView can cause browser-side code to execute that expects the this
415 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI 414 // RFH's ServiceRegistry to be initialized (e.g., if the site is a WebUI
416 // site that is handled via Mojo, then Mojo WebUI code in //chrome will 415 // site that is handled via Mojo, then Mojo WebUI code in //chrome will
417 // add a service to this RFH's ServiceRegistry). 416 // add a service to this RFH's ServiceRegistry).
418 dest_render_frame_host->SetUpMojoIfNeeded(); 417 dest_render_frame_host->SetUpMojoIfNeeded();
419 418
420 // Recreate the opener chain. 419 // Recreate the opener chain.
421 CreateOpenerProxiesIfNeeded(dest_render_frame_host->GetSiteInstance()); 420 CreateOpenerProxiesIfNeeded(dest_render_frame_host->GetSiteInstance());
422 if (!InitRenderView(dest_render_frame_host->render_view_host(), 421 if (!InitRenderView(dest_render_frame_host->render_view_host(),
423 MSG_ROUTING_NONE, 422 MSG_ROUTING_NONE))
424 frame_tree_node_->IsMainFrame()))
425 return nullptr; 423 return nullptr;
426 424
427 // Now that we've created a new renderer, be sure to hide it if it isn't 425 // Now that we've created a new renderer, be sure to hide it if it isn't
428 // our primary one. Otherwise, we might crash if we try to call Show() 426 // our primary one. Otherwise, we might crash if we try to call Show()
429 // on it later. 427 // on it later.
430 if (dest_render_frame_host != render_frame_host_) { 428 if (dest_render_frame_host != render_frame_host_) {
431 if (dest_render_frame_host->GetView()) 429 if (dest_render_frame_host->GetView())
432 dest_render_frame_host->GetView()->Hide(); 430 dest_render_frame_host->GetView()->Hide();
433 } else { 431 } else {
434 // TODO(nasko): This is a very ugly hack. The Chrome extensions process 432 // TODO(nasko): This is a very ugly hack. The Chrome extensions process
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 } 1035 }
1038 DCHECK(navigation_rfh && 1036 DCHECK(navigation_rfh &&
1039 (navigation_rfh == render_frame_host_.get() || 1037 (navigation_rfh == render_frame_host_.get() ||
1040 navigation_rfh == speculative_render_frame_host_.get())); 1038 navigation_rfh == speculative_render_frame_host_.get()));
1041 1039
1042 // If the RenderFrame that needs to navigate is not live (its process was just 1040 // If the RenderFrame that needs to navigate is not live (its process was just
1043 // created or has crashed), initialize it. 1041 // created or has crashed), initialize it.
1044 if (!navigation_rfh->IsRenderFrameLive()) { 1042 if (!navigation_rfh->IsRenderFrameLive()) {
1045 // Recreate the opener chain. 1043 // Recreate the opener chain.
1046 CreateOpenerProxiesIfNeeded(navigation_rfh->GetSiteInstance()); 1044 CreateOpenerProxiesIfNeeded(navigation_rfh->GetSiteInstance());
1047 if (!InitRenderView(navigation_rfh->render_view_host(), MSG_ROUTING_NONE, 1045 if (!InitRenderView(navigation_rfh->render_view_host(), MSG_ROUTING_NONE)) {
1048 frame_tree_node_->IsMainFrame())) {
1049 return nullptr; 1046 return nullptr;
1050 } 1047 }
1051 1048
1052 if (navigation_rfh == render_frame_host_) { 1049 if (navigation_rfh == render_frame_host_) {
1053 // TODO(nasko): This is a very ugly hack. The Chrome extensions process 1050 // TODO(nasko): This is a very ugly hack. The Chrome extensions process
1054 // manager still uses NotificationService and expects to see a 1051 // manager still uses NotificationService and expects to see a
1055 // RenderViewHost changed notification after WebContents and 1052 // RenderViewHost changed notification after WebContents and
1056 // RenderFrameHostManager are completely initialized. This should be 1053 // RenderFrameHostManager are completely initialized. This should be
1057 // removed once the process manager moves away from NotificationService. 1054 // removed once the process manager moves away from NotificationService.
1058 // See https://crbug.com/462682. 1055 // See https://crbug.com/462682.
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 // to open a new tab to an interstitial-inducing URL, and then navigates 1538 // to open a new tab to an interstitial-inducing URL, and then navigates
1542 // the page to a different same-site URL. (This seems very unlikely in 1539 // the page to a different same-site URL. (This seems very unlikely in
1543 // practice.) 1540 // practice.)
1544 if (current_entry) 1541 if (current_entry)
1545 return current_entry->GetURL(); 1542 return current_entry->GetURL();
1546 return current_instance->GetSiteURL(); 1543 return current_instance->GetSiteURL();
1547 } 1544 }
1548 1545
1549 void RenderFrameHostManager::CreatePendingRenderFrameHost( 1546 void RenderFrameHostManager::CreatePendingRenderFrameHost(
1550 SiteInstance* old_instance, 1547 SiteInstance* old_instance,
1551 SiteInstance* new_instance, 1548 SiteInstance* new_instance) {
1552 bool is_main_frame) {
1553 int create_render_frame_flags = 0; 1549 int create_render_frame_flags = 0;
1554 if (is_main_frame)
1555 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION;
1556
1557 if (delegate_->IsHidden()) 1550 if (delegate_->IsHidden())
1558 create_render_frame_flags |= CREATE_RF_HIDDEN; 1551 create_render_frame_flags |= CREATE_RF_HIDDEN;
1559 1552
1560 if (pending_render_frame_host_) 1553 if (pending_render_frame_host_)
1561 CancelPending(); 1554 CancelPending();
1562 1555
1563 // The process for the new SiteInstance may (if we're sharing a process with 1556 // The process for the new SiteInstance may (if we're sharing a process with
1564 // another host that already initialized it) or may not (we have our own 1557 // another host that already initialized it) or may not (we have our own
1565 // process or the existing process crashed) have been initialized. Calling 1558 // process or the existing process crashed) have been initialized. Calling
1566 // Init multiple times will be ignored, so this is safe. 1559 // Init multiple times will be ignored, so this is safe.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 // The process for the new SiteInstance may (if we're sharing a process with 1660 // The process for the new SiteInstance may (if we're sharing a process with
1668 // another host that already initialized it) or may not (we have our own 1661 // another host that already initialized it) or may not (we have our own
1669 // process or the existing process crashed) have been initialized. Calling 1662 // process or the existing process crashed) have been initialized. Calling
1670 // Init multiple times will be ignored, so this is safe. 1663 // Init multiple times will be ignored, so this is safe.
1671 if (!new_instance->GetProcess()->Init()) 1664 if (!new_instance->GetProcess()->Init())
1672 return false; 1665 return false;
1673 1666
1674 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); 1667 CreateProxiesForNewRenderFrameHost(old_instance, new_instance);
1675 1668
1676 int create_render_frame_flags = 0; 1669 int create_render_frame_flags = 0;
1677 if (frame_tree_node_->IsMainFrame())
1678 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION;
1679 if (delegate_->IsHidden()) 1670 if (delegate_->IsHidden())
1680 create_render_frame_flags |= CREATE_RF_HIDDEN; 1671 create_render_frame_flags |= CREATE_RF_HIDDEN;
1681 speculative_render_frame_host_ = 1672 speculative_render_frame_host_ =
1682 CreateRenderFrame(new_instance, speculative_web_ui_.get(), 1673 CreateRenderFrame(new_instance, speculative_web_ui_.get(),
1683 create_render_frame_flags, nullptr); 1674 create_render_frame_flags, nullptr);
1684 1675
1685 if (!speculative_render_frame_host_) { 1676 if (!speculative_render_frame_host_) {
1686 speculative_web_ui_.reset(); 1677 speculative_web_ui_.reset();
1687 return false; 1678 return false;
1688 } 1679 }
(...skipping 24 matching lines...) Expand all
1713 1704
1714 // We are creating a pending, speculative or swapped out RFH here. We should 1705 // We are creating a pending, speculative or swapped out RFH here. We should
1715 // never create it in the same SiteInstance as our current RFH. 1706 // never create it in the same SiteInstance as our current RFH.
1716 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); 1707 CHECK_NE(render_frame_host_->GetSiteInstance(), instance);
1717 1708
1718 // Check if we've already created an RFH for this SiteInstance. If so, try 1709 // Check if we've already created an RFH for this SiteInstance. If so, try
1719 // to re-use the existing one, which has already been initialized. We'll 1710 // to re-use the existing one, which has already been initialized. We'll
1720 // remove it from the list of proxy hosts below if it will be active. 1711 // remove it from the list of proxy hosts below if it will be active.
1721 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); 1712 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
1722 if (proxy && proxy->render_frame_host()) { 1713 if (proxy && proxy->render_frame_host()) {
1714 RenderViewHost* render_view_host = proxy->GetRenderViewHost();
1723 CHECK(!swapped_out_forbidden); 1715 CHECK(!swapped_out_forbidden);
1724 if (view_routing_id_ptr) 1716 if (view_routing_id_ptr)
1725 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); 1717 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID();
1726 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. 1718 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost.
1727 // Prevent the process from exiting while we're trying to use it. 1719 // Prevent the process from exiting while we're trying to use it.
1728 if (!swapped_out) { 1720 if (!swapped_out) {
1729 new_render_frame_host = proxy->PassFrameHostOwnership(); 1721 new_render_frame_host = proxy->PassFrameHostOwnership();
1730 new_render_frame_host->GetProcess()->AddPendingView(); 1722 new_render_frame_host->GetProcess()->AddPendingView();
1731 1723
1732 proxy_hosts_->Remove(instance->GetId()); 1724 proxy_hosts_->Remove(instance->GetId());
1733 // NB |proxy| is deleted at this point. 1725 // NB |proxy| is deleted at this point.
1734 } 1726 }
1727 // If we are reusing the RenderViewHost and it doesn't already have a
1728 // RenderWidgetHostView, we need to create one if this is the main frame.
1729 if (!render_view_host->GetView() && frame_tree_node_->IsMainFrame())
1730 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host);
1735 } else { 1731 } else {
1736 // Create a new RenderFrameHost if we don't find an existing one. 1732 // Create a new RenderFrameHost if we don't find an existing one.
1737 1733
1738 int32 widget_routing_id = MSG_ROUTING_NONE; 1734 int32 widget_routing_id = MSG_ROUTING_NONE;
1739 int32 surface_id = 0; 1735 int32 surface_id = 0;
1740 // A RenderFrame in a different process from its parent RenderFrame 1736 // A RenderFrame in a different process from its parent RenderFrame
1741 // requires a RenderWidget for input/layout/painting. 1737 // requires a RenderWidget for input/layout/painting.
1742 if (frame_tree_node_->parent() && 1738 if (frame_tree_node_->parent() &&
1743 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance() != 1739 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance() !=
1744 instance) { 1740 instance) {
(...skipping 16 matching lines...) Expand all
1761 new_render_frame_host->GetProcess()->AddPendingView(); 1757 new_render_frame_host->GetProcess()->AddPendingView();
1762 } else { 1758 } else {
1763 proxy = new RenderFrameProxyHost( 1759 proxy = new RenderFrameProxyHost(
1764 new_render_frame_host->GetSiteInstance(), 1760 new_render_frame_host->GetSiteInstance(),
1765 new_render_frame_host->render_view_host(), frame_tree_node_); 1761 new_render_frame_host->render_view_host(), frame_tree_node_);
1766 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); 1762 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy));
1767 proxy_routing_id = proxy->GetRoutingID(); 1763 proxy_routing_id = proxy->GetRoutingID();
1768 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); 1764 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass());
1769 } 1765 }
1770 1766
1771 success = InitRenderView(render_view_host, proxy_routing_id, 1767 if (frame_tree_node_->IsMainFrame()) {
1772 !!(flags & CREATE_RF_FOR_MAIN_FRAME_NAVIGATION)); 1768 success = InitRenderView(render_view_host, proxy_routing_id);
Charlie Reis 2015/09/02 20:13:08 Sanity check: What happens if this is a subframe a
1769
1770 // If we are reusing the RenderViewHost and it doesn't already have a
1771 // RenderWidgetHostView, we need to create one if this is the main frame.
1772 if (!swapped_out && !render_view_host->GetView())
1773 delegate_->CreateRenderWidgetHostViewForRenderManager(render_view_host);
1774 }
1775
1773 if (success) { 1776 if (success) {
1774 // Remember that InitRenderView also created the RenderFrameProxy. 1777 // Remember that InitRenderView also created the RenderFrameProxy.
1775 if (swapped_out) 1778 if (swapped_out)
1776 proxy->set_render_frame_proxy_created(true); 1779 proxy->set_render_frame_proxy_created(true);
1777 if (frame_tree_node_->IsMainFrame()) { 1780 if (frame_tree_node_->IsMainFrame()) {
1778 // Don't show the main frame's view until we get a DidNavigate from it. 1781 // Don't show the main frame's view until we get a DidNavigate from it.
1779 // Only the RenderViewHost for the top-level RenderFrameHost has a 1782 // Only the RenderViewHost for the top-level RenderFrameHost has a
1780 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes 1783 // RenderWidgetHostView; RenderWidgetHosts for out-of-process iframes
1781 // will be created later and hidden. 1784 // will be created later and hidden.
1782 if (render_view_host->GetView()) 1785 if (render_view_host->GetView())
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 return proxy->GetRoutingID(); 1850 return proxy->GetRoutingID();
1848 1851
1849 if (!proxy) { 1852 if (!proxy) {
1850 proxy = 1853 proxy =
1851 new RenderFrameProxyHost(instance, render_view_host, frame_tree_node_); 1854 new RenderFrameProxyHost(instance, render_view_host, frame_tree_node_);
1852 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy)); 1855 proxy_hosts_->Add(instance->GetId(), make_scoped_ptr(proxy));
1853 } 1856 }
1854 1857
1855 if (SiteIsolationPolicy::IsSwappedOutStateForbidden() && 1858 if (SiteIsolationPolicy::IsSwappedOutStateForbidden() &&
1856 frame_tree_node_->IsMainFrame()) { 1859 frame_tree_node_->IsMainFrame()) {
1857 InitRenderView(render_view_host, proxy->GetRoutingID(), true); 1860 InitRenderView(render_view_host, proxy->GetRoutingID());
1858 proxy->set_render_frame_proxy_created(true); 1861 proxy->set_render_frame_proxy_created(true);
1859 } else { 1862 } else {
1860 proxy->InitRenderFrameProxy(); 1863 proxy->InitRenderFrameProxy();
1861 } 1864 }
1862 1865
1863 return proxy->GetRoutingID(); 1866 return proxy->GetRoutingID();
1864 } 1867 }
1865 1868
1866 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) { 1869 void RenderFrameHostManager::CreateProxiesForChildFrame(FrameTreeNode* child) {
1867 for (const auto& pair : *proxy_hosts_) { 1870 for (const auto& pair : *proxy_hosts_) {
(...skipping 17 matching lines...) Expand all
1885 1888
1886 // Recreate the opener chain. 1889 // Recreate the opener chain.
1887 CreateOpenerProxiesIfNeeded(instance); 1890 CreateOpenerProxiesIfNeeded(instance);
1888 1891
1889 // If the proxy in |instance| doesn't exist, this RenderView is not swapped 1892 // If the proxy in |instance| doesn't exist, this RenderView is not swapped
1890 // out and shouldn't be reinitialized here. 1893 // out and shouldn't be reinitialized here.
1891 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); 1894 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance);
1892 if (!proxy) 1895 if (!proxy)
1893 return; 1896 return;
1894 1897
1895 InitRenderView(render_view_host, proxy->GetRoutingID(), false); 1898 InitRenderView(render_view_host, proxy->GetRoutingID());
1896 proxy->set_render_frame_proxy_created(true); 1899 proxy->set_render_frame_proxy_created(true);
1897 } 1900 }
1898 1901
1899 void RenderFrameHostManager::CreateOuterDelegateProxy( 1902 void RenderFrameHostManager::CreateOuterDelegateProxy(
1900 SiteInstance* outer_contents_site_instance, 1903 SiteInstance* outer_contents_site_instance,
1901 RenderFrameHostImpl* render_frame_host) { 1904 RenderFrameHostImpl* render_frame_host) {
1902 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); 1905 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests());
1903 RenderFrameProxyHost* proxy = new RenderFrameProxyHost( 1906 RenderFrameProxyHost* proxy = new RenderFrameProxyHost(
1904 outer_contents_site_instance, nullptr, frame_tree_node_); 1907 outer_contents_site_instance, nullptr, frame_tree_node_);
1905 proxy_hosts_->Add(outer_contents_site_instance->GetId(), 1908 proxy_hosts_->Add(outer_contents_site_instance->GetId(),
(...skipping 14 matching lines...) Expand all
1920 } 1923 }
1921 1924
1922 void RenderFrameHostManager::SetRWHViewForInnerContents( 1925 void RenderFrameHostManager::SetRWHViewForInnerContents(
1923 RenderWidgetHostView* child_rwhv) { 1926 RenderWidgetHostView* child_rwhv) {
1924 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame()); 1927 DCHECK(ForInnerDelegate() && frame_tree_node_->IsMainFrame());
1925 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv); 1928 GetProxyToOuterDelegate()->SetChildRWHView(child_rwhv);
1926 } 1929 }
1927 1930
1928 bool RenderFrameHostManager::InitRenderView( 1931 bool RenderFrameHostManager::InitRenderView(
1929 RenderViewHostImpl* render_view_host, 1932 RenderViewHostImpl* render_view_host,
1930 int proxy_routing_id, 1933 int proxy_routing_id) {
1931 bool for_main_frame_navigation) {
1932 // Ensure the renderer process is initialized before creating the 1934 // Ensure the renderer process is initialized before creating the
1933 // RenderView. 1935 // RenderView.
1934 if (!render_view_host->GetProcess()->Init()) 1936 if (!render_view_host->GetProcess()->Init())
1935 return false; 1937 return false;
1936 1938
1937 // We may have initialized this RenderViewHost for another RenderFrameHost. 1939 // We may have initialized this RenderViewHost for another RenderFrameHost.
1938 if (render_view_host->IsRenderViewLive()) 1940 if (render_view_host->IsRenderViewLive())
1939 return true; 1941 return true;
1940 1942
1941 // If the ongoing navigation is to a WebUI and the RenderView is not in a 1943 // If the ongoing navigation is to a WebUI and the RenderView is not in a
(...skipping 16 matching lines...) Expand all
1958 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 1960 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
1959 render_view_host->GetProcess()->GetID())); 1961 render_view_host->GetProcess()->GetID()));
1960 } 1962 }
1961 } 1963 }
1962 1964
1963 int opener_frame_routing_id = 1965 int opener_frame_routing_id =
1964 GetOpenerRoutingID(render_view_host->GetSiteInstance()); 1966 GetOpenerRoutingID(render_view_host->GetSiteInstance());
1965 1967
1966 return delegate_->CreateRenderViewForRenderManager( 1968 return delegate_->CreateRenderViewForRenderManager(
1967 render_view_host, opener_frame_routing_id, proxy_routing_id, 1969 render_view_host, opener_frame_routing_id, proxy_routing_id,
1968 frame_tree_node_->current_replication_state(), for_main_frame_navigation); 1970 frame_tree_node_->current_replication_state());
1969 } 1971 }
1970 1972
1971 bool RenderFrameHostManager::InitRenderFrame( 1973 bool RenderFrameHostManager::InitRenderFrame(
1972 RenderFrameHostImpl* render_frame_host) { 1974 RenderFrameHostImpl* render_frame_host) {
1973 if (render_frame_host->IsRenderFrameLive()) 1975 if (render_frame_host->IsRenderFrameLive())
1974 return true; 1976 return true;
1975 1977
1976 int parent_routing_id = MSG_ROUTING_NONE; 1978 int parent_routing_id = MSG_ROUTING_NONE;
1977 int previous_sibling_routing_id = MSG_ROUTING_NONE; 1979 int previous_sibling_routing_id = MSG_ROUTING_NONE;
1978 int proxy_routing_id = MSG_ROUTING_NONE; 1980 int proxy_routing_id = MSG_ROUTING_NONE;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 2270
2269 // New SiteInstance: create a pending RFH to navigate. 2271 // New SiteInstance: create a pending RFH to navigate.
2270 2272
2271 // This will possibly create (set to nullptr) a Web UI object for the 2273 // This will possibly create (set to nullptr) a Web UI object for the
2272 // pending page. We'll use this later to give the page special access. This 2274 // pending page. We'll use this later to give the page special access. This
2273 // must happen before the new renderer is created below so it will get 2275 // must happen before the new renderer is created below so it will get
2274 // bindings. It must also happen after the above conditional call to 2276 // bindings. It must also happen after the above conditional call to
2275 // CancelPending(), otherwise CancelPending may clear the pending_web_ui_ 2277 // CancelPending(), otherwise CancelPending may clear the pending_web_ui_
2276 // and the page will not have its bindings set appropriately. 2278 // and the page will not have its bindings set appropriately.
2277 SetPendingWebUI(dest_url, bindings); 2279 SetPendingWebUI(dest_url, bindings);
2278 CreatePendingRenderFrameHost(current_instance, new_instance.get(), 2280 CreatePendingRenderFrameHost(current_instance, new_instance.get());
2279 frame_tree_node_->IsMainFrame());
2280 if (!pending_render_frame_host_) 2281 if (!pending_render_frame_host_)
2281 return nullptr; 2282 return nullptr;
2282 2283
2283 // Check if our current RFH is live before we set up a transition. 2284 // Check if our current RFH is live before we set up a transition.
2284 if (!render_frame_host_->IsRenderFrameLive()) { 2285 if (!render_frame_host_->IsRenderFrameLive()) {
2285 // The current RFH is not live. There's no reason to sit around with a 2286 // The current RFH is not live. There's no reason to sit around with a
2286 // sad tab or a newly created RFH while we wait for the pending RFH to 2287 // sad tab or a newly created RFH while we wait for the pending RFH to
2287 // navigate. Just switch to the pending RFH now and go back to normal. 2288 // navigate. Just switch to the pending RFH now and go back to normal.
2288 // (Note that we don't care about on{before}unload handlers if the current 2289 // (Note that we don't care about on{before}unload handlers if the current
2289 // RFH isn't live.) 2290 // RFH isn't live.)
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 // Ensure that all the nodes in the opener's frame tree have 2551 // Ensure that all the nodes in the opener's frame tree have
2551 // RenderFrameProxyHosts for the new SiteInstance. 2552 // RenderFrameProxyHosts for the new SiteInstance.
2552 frame_tree->CreateProxiesForSiteInstance(nullptr, instance); 2553 frame_tree->CreateProxiesForSiteInstance(nullptr, instance);
2553 } else if (rvh && !rvh->IsRenderViewLive()) { 2554 } else if (rvh && !rvh->IsRenderViewLive()) {
2554 EnsureRenderViewInitialized(rvh, instance); 2555 EnsureRenderViewInitialized(rvh, instance);
2555 } else { 2556 } else {
2556 // Create a swapped out RenderView in the given SiteInstance if none exists, 2557 // Create a swapped out RenderView in the given SiteInstance if none exists,
2557 // setting its opener to the given route_id. Since the opener can point to 2558 // setting its opener to the given route_id. Since the opener can point to
2558 // a subframe, do this on the root frame of the opener's frame tree. 2559 // a subframe, do this on the root frame of the opener's frame tree.
2559 // Return the new view's route_id. 2560 // Return the new view's route_id.
2560 frame_tree->root()->render_manager()-> 2561 frame_tree->root()->render_manager()->CreateRenderFrame(
2561 CreateRenderFrame(instance, nullptr, 2562 instance, nullptr, CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr);
2562 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION |
2563 CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN,
2564 nullptr);
2565 } 2563 }
2566 } 2564 }
2567 2565
2568 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2566 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2569 if (!frame_tree_node_->opener()) 2567 if (!frame_tree_node_->opener())
2570 return MSG_ROUTING_NONE; 2568 return MSG_ROUTING_NONE;
2571 2569
2572 return frame_tree_node_->opener() 2570 return frame_tree_node_->opener()
2573 ->render_manager() 2571 ->render_manager()
2574 ->GetRoutingIdForSiteInstance(instance); 2572 ->GetRoutingIdForSiteInstance(instance);
2575 } 2573 }
2576 2574
2577 } // namespace content 2575 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.h ('k') | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698