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

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

Issue 953503002: PlzNavigate: test updates post beforeUnload IPC refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR comments. Created 5 years, 9 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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 if (force_browsing_instance_swap) { 1026 if (force_browsing_instance_swap) {
1027 CHECK(!dest_instance->IsRelatedSiteInstance( 1027 CHECK(!dest_instance->IsRelatedSiteInstance(
1028 render_frame_host_->GetSiteInstance())); 1028 render_frame_host_->GetSiteInstance()));
1029 } 1029 }
1030 return dest_instance; 1030 return dest_instance;
1031 } 1031 }
1032 1032
1033 // If a swap is required, we need to force the SiteInstance AND 1033 // If a swap is required, we need to force the SiteInstance AND
1034 // BrowsingInstance to be different ones, using CreateForURL. 1034 // BrowsingInstance to be different ones, using CreateForURL.
1035 if (force_browsing_instance_swap) 1035 if (force_browsing_instance_swap)
1036 return SiteInstance::CreateForURL(browser_context, dest_url); 1036 return CreateSiteInstanceForURL(browser_context, dest_url);
1037 1037
1038 // (UGLY) HEURISTIC, process-per-site only: 1038 // (UGLY) HEURISTIC, process-per-site only:
1039 // 1039 //
1040 // If this navigation is generated, then it probably corresponds to a search 1040 // If this navigation is generated, then it probably corresponds to a search
1041 // query. Given that search results typically lead to users navigating to 1041 // query. Given that search results typically lead to users navigating to
1042 // other sites, we don't really want to use the search engine hostname to 1042 // other sites, we don't really want to use the search engine hostname to
1043 // determine the site instance for this navigation. 1043 // determine the site instance for this navigation.
1044 // 1044 //
1045 // NOTE: This can be removed once we have a way to transition between 1045 // NOTE: This can be removed once we have a way to transition between
1046 // RenderViews in response to a link click. 1046 // RenderViews in response to a link click.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 // have a RenderProcessHost of PRIV_NORMAL. Create a new SiteInstance for 1083 // have a RenderProcessHost of PRIV_NORMAL. Create a new SiteInstance for
1084 // this URL instead (with the correct process type). 1084 // this URL instead (with the correct process type).
1085 if (current_site_instance->HasWrongProcessForURL(dest_url)) 1085 if (current_site_instance->HasWrongProcessForURL(dest_url))
1086 return current_site_instance->GetRelatedSiteInstance(dest_url); 1086 return current_site_instance->GetRelatedSiteInstance(dest_url);
1087 1087
1088 // View-source URLs must use a new SiteInstance and BrowsingInstance. 1088 // View-source URLs must use a new SiteInstance and BrowsingInstance.
1089 // TODO(nasko): This is the same condition as later in the function. This 1089 // TODO(nasko): This is the same condition as later in the function. This
1090 // should be taken into account when refactoring this method as part of 1090 // should be taken into account when refactoring this method as part of
1091 // http://crbug.com/123007. 1091 // http://crbug.com/123007.
1092 if (dest_is_view_source_mode) 1092 if (dest_is_view_source_mode)
1093 return SiteInstance::CreateForURL(browser_context, dest_url); 1093 return CreateSiteInstanceForURL(browser_context, dest_url);
1094 1094
1095 // If we are navigating from a blank SiteInstance to a WebUI, make sure we 1095 // If we are navigating from a blank SiteInstance to a WebUI, make sure we
1096 // create a new SiteInstance. 1096 // create a new SiteInstance.
1097 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( 1097 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL(
1098 browser_context, dest_url)) { 1098 browser_context, dest_url)) {
1099 return SiteInstance::CreateForURL(browser_context, dest_url); 1099 return CreateSiteInstanceForURL(browser_context, dest_url);
1100 } 1100 }
1101 1101
1102 // Normally the "site" on the SiteInstance is set lazily when the load 1102 // Normally the "site" on the SiteInstance is set lazily when the load
1103 // actually commits. This is to support better process sharing in case 1103 // actually commits. This is to support better process sharing in case
1104 // the site redirects to some other site: we want to use the destination 1104 // the site redirects to some other site: we want to use the destination
1105 // site in the site instance. 1105 // site in the site instance.
1106 // 1106 //
1107 // In the case of session restore, as it loads all the pages immediately 1107 // In the case of session restore, as it loads all the pages immediately
1108 // we need to set the site first, otherwise after a restore none of the 1108 // we need to set the site first, otherwise after a restore none of the
1109 // pages would share renderers in process-per-site. 1109 // pages would share renderers in process-per-site.
(...skipping 29 matching lines...) Expand all
1139 } 1139 }
1140 1140
1141 // View-source URLs must use a new SiteInstance and BrowsingInstance. 1141 // View-source URLs must use a new SiteInstance and BrowsingInstance.
1142 // We don't need a swap when going from view-source to a debug URL like 1142 // We don't need a swap when going from view-source to a debug URL like
1143 // chrome://crash, however. 1143 // chrome://crash, however.
1144 // TODO(creis): Refactor this method so this duplicated code isn't needed. 1144 // TODO(creis): Refactor this method so this duplicated code isn't needed.
1145 // See http://crbug.com/123007. 1145 // See http://crbug.com/123007.
1146 if (current_entry && 1146 if (current_entry &&
1147 current_entry->IsViewSourceMode() != dest_is_view_source_mode && 1147 current_entry->IsViewSourceMode() != dest_is_view_source_mode &&
1148 !IsRendererDebugURL(dest_url)) { 1148 !IsRendererDebugURL(dest_url)) {
1149 return SiteInstance::CreateForURL(browser_context, dest_url); 1149 return CreateSiteInstanceForURL(browser_context, dest_url);
1150 } 1150 }
1151 1151
1152 // Use the source SiteInstance in case of data URLs or about:blank pages, 1152 // Use the source SiteInstance in case of data URLs or about:blank pages,
1153 // because the content is then controlled and/or scriptable by the source 1153 // because the content is then controlled and/or scriptable by the source
1154 // SiteInstance. 1154 // SiteInstance.
1155 GURL about_blank(url::kAboutBlankURL); 1155 GURL about_blank(url::kAboutBlankURL);
1156 if (source_instance && 1156 if (source_instance &&
1157 (dest_url == about_blank || dest_url.scheme() == url::kDataScheme)) 1157 (dest_url == about_blank || dest_url.scheme() == url::kDataScheme))
1158 return source_instance; 1158 return source_instance;
1159 1159
1160 // Use the current SiteInstance for same site navigations, as long as the 1160 // Use the current SiteInstance for same site navigations, as long as the
1161 // process type is correct. (The URL may have been installed as an app since 1161 // process type is correct. (The URL may have been installed as an app since
1162 // the last time we visited it.) 1162 // the last time we visited it.)
1163 const GURL& current_url = 1163 const GURL& current_url =
1164 GetCurrentURLForSiteInstance(current_instance, current_entry); 1164 GetCurrentURLForSiteInstance(current_instance, current_entry);
1165 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && 1165 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) &&
1166 !current_site_instance->HasWrongProcessForURL(dest_url)) { 1166 !current_site_instance->HasWrongProcessForURL(dest_url)) {
1167 return current_instance; 1167 return current_instance;
1168 } 1168 }
1169 1169
1170 // Start the new renderer in a new SiteInstance, but in the current 1170 // Start the new renderer in a new SiteInstance, but in the current
1171 // BrowsingInstance. It is important to immediately give this new 1171 // BrowsingInstance. It is important to immediately give this new
1172 // SiteInstance to a RenderViewHost (if it is different than our current 1172 // SiteInstance to a RenderViewHost (if it is different than our current
1173 // SiteInstance), so that it is ref counted. This will happen in 1173 // SiteInstance), so that it is ref counted. This will happen in
1174 // CreateRenderView. 1174 // CreateRenderView.
1175 return current_instance->GetRelatedSiteInstance(dest_url); 1175 return current_instance->GetRelatedSiteInstance(dest_url);
1176 } 1176 }
1177 1177
1178 SiteInstance* RenderFrameHostManager::CreateSiteInstanceForURL(
1179 BrowserContext* browser_context,
1180 const GURL& dest_url) {
1181 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1182 switches::kEnableBrowserSideNavigation) &&
1183 speculative_render_frame_host_ &&
1184 speculative_render_frame_host_->GetSiteInstance()->GetSiteURL() ==
1185 dest_url) {
1186 // We already created a new SiteInstance for this specific URL for this same
1187 // navigation and stored it in the speculative RenderFrameHost, so there's
1188 // no need to create a new one again.
1189 return speculative_render_frame_host_->GetSiteInstance();
1190 }
1191 return SiteInstance::CreateForURL(browser_context, dest_url);
1192 }
1193
1178 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( 1194 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance(
1179 SiteInstance* current_instance, NavigationEntry* current_entry) { 1195 SiteInstance* current_instance, NavigationEntry* current_entry) {
1180 // If this is a subframe that is potentially out of process from its parent, 1196 // If this is a subframe that is potentially out of process from its parent,
1181 // don't consider using current_entry's url for SiteInstance selection, since 1197 // don't consider using current_entry's url for SiteInstance selection, since
1182 // current_entry's url is for the main frame and may be in a different site 1198 // current_entry's url is for the main frame and may be in a different site
1183 // than this frame. 1199 // than this frame.
1184 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url. 1200 // TODO(creis): Remove this when we can check the FrameNavigationEntry's url.
1185 // See http://crbug.com/369654 1201 // See http://crbug.com/369654
1186 if (!frame_tree_node_->IsMainFrame() && 1202 if (!frame_tree_node_->IsMainFrame() &&
1187 base::CommandLine::ForCurrentProcess()->HasSwitch( 1203 base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1966 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1951 SiteInstance* instance) { 1967 SiteInstance* instance) {
1952 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1968 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1953 if (iter != proxy_hosts_.end()) { 1969 if (iter != proxy_hosts_.end()) {
1954 delete iter->second; 1970 delete iter->second;
1955 proxy_hosts_.erase(iter); 1971 proxy_hosts_.erase(iter);
1956 } 1972 }
1957 } 1973 }
1958 1974
1959 } // namespace content 1975 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698