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

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

Issue 600553003: Enable swapping a frame back in to its parent process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remoteToLocal
Patch Set: Created 6 years, 2 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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 // const GURL& current_url = current_instance->site(); 974 // const GURL& current_url = current_instance->site();
975 // For now, though, we're in a hybrid model where you only switch 975 // For now, though, we're in a hybrid model where you only switch
976 // SiteInstances if you type in a cross-site URL. This means we have to 976 // SiteInstances if you type in a cross-site URL. This means we have to
977 // compare the entry's URL to the last committed entry's URL. 977 // compare the entry's URL to the last committed entry's URL.
978 NavigationEntry* current_entry = controller.GetLastCommittedEntry(); 978 NavigationEntry* current_entry = controller.GetLastCommittedEntry();
979 if (interstitial_page_) { 979 if (interstitial_page_) {
980 // The interstitial is currently the last committed entry, but we want to 980 // The interstitial is currently the last committed entry, but we want to
981 // compare against the last non-interstitial entry. 981 // compare against the last non-interstitial entry.
982 current_entry = controller.GetEntryAtOffset(-1); 982 current_entry = controller.GetEntryAtOffset(-1);
983 } 983 }
984 // If there is no last non-interstitial entry (and current_instance already
985 // has a site), then we must have been opened from another tab. We want
986 // to compare against the URL of the page that opened us, but we can't
987 // get to it directly. The best we can do is check against the site of
988 // the SiteInstance. This will be correct when we intercept links and
989 // script-based navigations, but for now, it could place some pages in a
990 // new process unnecessarily. We should only hit this case if a page tries
991 // to open a new tab to an interstitial-inducing URL, and then navigates
992 // the page to a different same-site URL. (This seems very unlikely in
993 // practice.)
994 const GURL& current_url = (current_entry) ? current_entry->GetURL() :
Nate Chapin 2014/09/30 21:44:47 This code and comment are really old (pre-opensour
Charlie Reis 2014/09/30 23:02:43 Ah, this is tricky. We should fix this in its own
Nate Chapin 2014/09/30 23:19:44 I can try that. I had also considered making the b
995 current_instance->GetSiteURL();
996 984
997 // View-source URLs must use a new SiteInstance and BrowsingInstance. 985 // View-source URLs must use a new SiteInstance and BrowsingInstance.
998 // We don't need a swap when going from view-source to a debug URL like 986 // We don't need a swap when going from view-source to a debug URL like
999 // chrome://crash, however. 987 // chrome://crash, however.
1000 // TODO(creis): Refactor this method so this duplicated code isn't needed. 988 // TODO(creis): Refactor this method so this duplicated code isn't needed.
1001 // See http://crbug.com/123007. 989 // See http://crbug.com/123007.
1002 if (current_entry && 990 if (current_entry &&
1003 current_entry->IsViewSourceMode() != dest_is_view_source_mode && 991 current_entry->IsViewSourceMode() != dest_is_view_source_mode &&
1004 !IsRendererDebugURL(dest_url)) { 992 !IsRendererDebugURL(dest_url)) {
1005 return SiteInstance::CreateForURL(browser_context, dest_url); 993 return SiteInstance::CreateForURL(browser_context, dest_url);
1006 } 994 }
1007 995
1008 // Use the current SiteInstance for same site navigations, as long as the 996 // Use the current SiteInstance for same site navigations, as long as the
1009 // process type is correct. (The URL may have been installed as an app since 997 // process type is correct. (The URL may have been installed as an app since
1010 // the last time we visited it.) 998 // the last time we visited it.)
999 const GURL& current_url = current_instance->GetSiteURL();
1011 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && 1000 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) &&
1012 !current_site_instance->HasWrongProcessForURL(dest_url)) { 1001 !current_site_instance->HasWrongProcessForURL(dest_url)) {
1013 return current_instance; 1002 return current_instance;
1014 } 1003 }
1015 1004
1016 // Start the new renderer in a new SiteInstance, but in the current 1005 // Start the new renderer in a new SiteInstance, but in the current
1017 // BrowsingInstance. It is important to immediately give this new 1006 // BrowsingInstance. It is important to immediately give this new
1018 // SiteInstance to a RenderViewHost (if it is different than our current 1007 // SiteInstance to a RenderViewHost (if it is different than our current
1019 // SiteInstance), so that it is ref counted. This will happen in 1008 // SiteInstance), so that it is ref counted. This will happen in
1020 // CreateRenderView. 1009 // CreateRenderView.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 new_render_frame_host = CreateRenderFrameHost( 1129 new_render_frame_host = CreateRenderFrameHost(
1141 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden); 1130 instance, MSG_ROUTING_NONE, MSG_ROUTING_NONE, swapped_out, hidden);
1142 RenderViewHostImpl* render_view_host = 1131 RenderViewHostImpl* render_view_host =
1143 new_render_frame_host->render_view_host(); 1132 new_render_frame_host->render_view_host();
1144 int proxy_routing_id = MSG_ROUTING_NONE; 1133 int proxy_routing_id = MSG_ROUTING_NONE;
1145 1134
1146 // Prevent the process from exiting while we're trying to navigate in it. 1135 // Prevent the process from exiting while we're trying to navigate in it.
1147 // Otherwise, if the new RFH is swapped out already, store it. 1136 // Otherwise, if the new RFH is swapped out already, store it.
1148 if (!swapped_out) { 1137 if (!swapped_out) {
1149 new_render_frame_host->GetProcess()->AddPendingView(); 1138 new_render_frame_host->GetProcess()->AddPendingView();
1150 } else { 1139 } else if (!proxy) {
1151 proxy = new RenderFrameProxyHost( 1140 RenderFrameProxyHost* new_proxy = new RenderFrameProxyHost(
1152 new_render_frame_host->GetSiteInstance(), frame_tree_node_); 1141 new_render_frame_host->GetSiteInstance(), frame_tree_node_);
1153 proxy_hosts_[instance->GetId()] = proxy; 1142 proxy_hosts_[instance->GetId()] = new_proxy;
1154 proxy_routing_id = proxy->GetRoutingID(); 1143 proxy_routing_id = new_proxy->GetRoutingID();
1155 if (frame_tree_node_->IsMainFrame()) 1144 if (frame_tree_node_->IsMainFrame())
1156 proxy->TakeFrameHostOwnership(new_render_frame_host.Pass()); 1145 new_proxy->TakeFrameHostOwnership(new_render_frame_host.Pass());
1157 } 1146 }
1158 1147
1159 bool success = InitRenderView(render_view_host, 1148 bool success = InitRenderView(render_view_host,
1160 opener_route_id, 1149 opener_route_id,
1161 proxy_routing_id, 1150 proxy_routing_id,
1162 for_main_frame_navigation); 1151 for_main_frame_navigation);
1163 if (success) { 1152 if (success) {
1164 if (frame_tree_node_->IsMainFrame()) { 1153 if (frame_tree_node_->IsMainFrame()) {
1165 // Don't show the main frame's view until we get a DidNavigate from it. 1154 // Don't show the main frame's view until we get a DidNavigate from it.
1166 render_view_host->GetView()->Hide(); 1155 render_view_host->GetView()->Hide();
1156 } else if (proxy) {
1157 proxy->SwapOut(new_render_frame_host.get());
Nate Chapin 2014/09/30 21:44:47 This case is where we have a RenderFrameProxyHost,
Charlie Reis 2014/09/30 23:02:43 I don't think we want to do the swap until the new
Nate Chapin 2014/09/30 23:19:44 Hrm. I guess that's more accurate.
nasko 2014/10/08 16:42:58 When we are creating a frame and there exists a pr
1158 delete proxy;
1159 proxy_hosts_.erase(instance->GetId());
1167 } else if (!swapped_out) { 1160 } else if (!swapped_out) {
1168 // Init the RFH, so a RenderFrame is created in the renderer. 1161 // Init the RFH, so a RenderFrame is created in the renderer.
1169 DCHECK(new_render_frame_host.get()); 1162 DCHECK(new_render_frame_host.get());
1170 success = InitRenderFrame(new_render_frame_host.get()); 1163 success = InitRenderFrame(new_render_frame_host.get());
1171 } 1164 }
1172 if (swapped_out) { 1165 if (swapped_out) {
1173 proxy_hosts_[instance->GetId()]->InitRenderFrameProxy(); 1166 proxy_hosts_[instance->GetId()]->InitRenderFrameProxy();
1174 } 1167 }
1175 } else if (!swapped_out && pending_render_frame_host_) { 1168 } else if (!swapped_out && pending_render_frame_host_) {
1176 CancelPending(); 1169 CancelPending();
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1701 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1709 SiteInstance* instance) { 1702 SiteInstance* instance) {
1710 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1703 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1711 if (iter != proxy_hosts_.end()) { 1704 if (iter != proxy_hosts_.end()) {
1712 delete iter->second; 1705 delete iter->second;
1713 proxy_hosts_.erase(iter); 1706 proxy_hosts_.erase(iter);
1714 } 1707 }
1715 } 1708 }
1716 1709
1717 } // namespace content 1710 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698