Commit 4c237a27 authored by Aaron Colwell's avatar Aaron Colwell Committed by Commit Bot

Change DoesSiteInfoRequireDedicatedProcess() param to SiteInfo.

This change converts the site_url param to a SiteInfo in preparation
for adding new checks that are based on other SiteInfo fields. This is
part of an ongoing effort to replace site URL usage in method
signatures with SiteInfo.

Bug: 1085275
Change-Id: I67cc62db168f1d107890f66970041796ea9dcb8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401333
Commit-Queue: Aaron Colwell <acolwell@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Auto-Submit: Aaron Colwell <acolwell@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805520}
parent a108ec37
...@@ -639,9 +639,8 @@ bool SiteInstanceImpl::IsSuitableForURL(const GURL& url) { ...@@ -639,9 +639,8 @@ bool SiteInstanceImpl::IsSuitableForURL(const GURL& url) {
// If the site URLs do not match, but neither this SiteInstance nor the // If the site URLs do not match, but neither this SiteInstance nor the
// destination site_url require dedicated processes, then it is safe to use // destination site_url require dedicated processes, then it is safe to use
// this SiteInstance. // this SiteInstance.
if (!RequiresDedicatedProcess() && if (!RequiresDedicatedProcess() && !DoesSiteInfoRequireDedicatedProcess(
!DoesSiteURLRequireDedicatedProcess(GetIsolationContext(), GetIsolationContext(), site_info)) {
site_info.site_url())) {
return true; return true;
} }
...@@ -660,8 +659,7 @@ bool SiteInstanceImpl::RequiresDedicatedProcess() { ...@@ -660,8 +659,7 @@ bool SiteInstanceImpl::RequiresDedicatedProcess() {
if (!has_site_) if (!has_site_)
return false; return false;
return DoesSiteURLRequireDedicatedProcess(GetIsolationContext(), return DoesSiteInfoRequireDedicatedProcess(GetIsolationContext(), site_info_);
site_info_.site_url());
} }
void SiteInstanceImpl::IncrementActiveFrameCount() { void SiteInstanceImpl::IncrementActiveFrameCount() {
...@@ -1177,8 +1175,7 @@ bool SiteInstanceImpl::CanBePlacedInDefaultSiteInstance( ...@@ -1177,8 +1175,7 @@ bool SiteInstanceImpl::CanBePlacedInDefaultSiteInstance(
// Allow the default SiteInstance to be used for sites that don't need to be // Allow the default SiteInstance to be used for sites that don't need to be
// isolated in their own process. // isolated in their own process.
return !DoesSiteURLRequireDedicatedProcess(isolation_context, return !DoesSiteInfoRequireDedicatedProcess(isolation_context, site_info);
site_info.site_url());
} }
// static // static
...@@ -1209,16 +1206,15 @@ bool SiteInstanceImpl::DoesSiteRequireDedicatedProcess( ...@@ -1209,16 +1206,15 @@ bool SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
const GURL& url) { const GURL& url) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
return SiteIsolationPolicy::UseDedicatedProcessesForAllSites() || return SiteIsolationPolicy::UseDedicatedProcessesForAllSites() ||
DoesSiteURLRequireDedicatedProcess( DoesSiteInfoRequireDedicatedProcess(
isolation_context, isolation_context,
SiteInstanceImpl::ComputeSiteInfo(isolation_context, url) SiteInstanceImpl::ComputeSiteInfo(isolation_context, url));
.site_url());
} }
// static // static
bool SiteInstanceImpl::DoesSiteURLRequireDedicatedProcess( bool SiteInstanceImpl::DoesSiteInfoRequireDedicatedProcess(
const IsolationContext& isolation_context, const IsolationContext& isolation_context,
const GURL& site_url) { const SiteInfo& site_info) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(isolation_context.browser_or_resource_context()); DCHECK(isolation_context.browser_or_resource_context());
...@@ -1226,6 +1222,8 @@ bool SiteInstanceImpl::DoesSiteURLRequireDedicatedProcess( ...@@ -1226,6 +1222,8 @@ bool SiteInstanceImpl::DoesSiteURLRequireDedicatedProcess(
if (SiteIsolationPolicy::UseDedicatedProcessesForAllSites()) if (SiteIsolationPolicy::UseDedicatedProcessesForAllSites())
return true; return true;
const GURL& site_url = site_info.site_url();
// Always require a dedicated process for isolated origins. // Always require a dedicated process for isolated origins.
auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); auto* policy = ChildProcessSecurityPolicyImpl::GetInstance();
if (policy->IsIsolatedOrigin(isolation_context, if (policy->IsIsolatedOrigin(isolation_context,
...@@ -1266,15 +1264,13 @@ bool SiteInstanceImpl::ShouldLockProcess( ...@@ -1266,15 +1264,13 @@ bool SiteInstanceImpl::ShouldLockProcess(
isolation_context.browser_or_resource_context().ToBrowserContext(); isolation_context.browser_or_resource_context().ToBrowserContext();
DCHECK(browser_context); DCHECK(browser_context);
const GURL& site_url = site_info.site_url();
// Don't lock to origin in --single-process mode, since this mode puts // Don't lock to origin in --single-process mode, since this mode puts
// cross-site pages into the same process. Note that this also covers the // cross-site pages into the same process. Note that this also covers the
// single-process mode in Android Webview. // single-process mode in Android Webview.
if (RenderProcessHost::run_renderer_in_process()) if (RenderProcessHost::run_renderer_in_process())
return false; return false;
if (!DoesSiteURLRequireDedicatedProcess(isolation_context, site_url)) if (!DoesSiteInfoRequireDedicatedProcess(isolation_context, site_info))
return false; return false;
// Guest processes cannot be locked to their site because guests always have // Guest processes cannot be locked to their site because guests always have
...@@ -1285,6 +1281,8 @@ bool SiteInstanceImpl::ShouldLockProcess( ...@@ -1285,6 +1281,8 @@ bool SiteInstanceImpl::ShouldLockProcess(
if (is_guest) if (is_guest)
return false; return false;
const GURL& site_url = site_info.site_url();
// Most WebUI processes should be locked on all platforms. The only exception // Most WebUI processes should be locked on all platforms. The only exception
// is NTP, handled via the separate callout to the embedder. // is NTP, handled via the separate callout to the embedder.
const auto& webui_schemes = URLDataManagerBackend::GetWebUISchemes(); const auto& webui_schemes = URLDataManagerBackend::GetWebUISchemes();
......
...@@ -572,15 +572,15 @@ class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance, ...@@ -572,15 +572,15 @@ class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance,
// URLs. // URLs.
static bool HasEffectiveURL(BrowserContext* browser_context, const GURL& url); static bool HasEffectiveURL(BrowserContext* browser_context, const GURL& url);
// Returns true if pages loaded from |site_url| ought to be handled only by a // Returns true if pages loaded from |site_info| ought to be handled only by a
// renderer process isolated from other sites. If --site-per-process is used, // renderer process isolated from other sites. If --site-per-process is used,
// this is true for all sites. In other site isolation modes, only a subset // this is true for all sites. In other site isolation modes, only a subset
// of sites will require dedicated processes. // of sites will require dedicated processes.
// Note: Unlike DoesSiteRequireDedicatedProcess(), this method expects a site // Note: Unlike DoesSiteRequireDedicatedProcess(), this method expects a
// URL instead of a plain URL. // SiteInfo instead of a plain URL.
static bool DoesSiteURLRequireDedicatedProcess( static bool DoesSiteInfoRequireDedicatedProcess(
const IsolationContext& isolation_context, const IsolationContext& isolation_context,
const GURL& site_url); const SiteInfo& site_info);
// Returns true if |url| and its |site_url| can be placed inside a default // Returns true if |url| and its |site_url| can be placed inside a default
// SiteInstance. // SiteInstance.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment