Chromium Code Reviews| Index: content/browser/renderer_host/render_process_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc |
| index d18fd32416a5d398395e58b9e776a8c26850380c..c9834e862c1a611c594faf507d6a222d6fe1d223 100644 |
| --- a/content/browser/renderer_host/render_process_host_impl.cc |
| +++ b/content/browser/renderer_host/render_process_host_impl.cc |
| @@ -929,6 +929,7 @@ RenderProcessHostImpl::RenderProcessHostImpl( |
| sudden_termination_allowed_(true), |
| ignore_input_events_(false), |
| is_for_guests_only_(is_for_guests_only), |
| + can_become_dedicated_process_(true), |
| gpu_observer_registered_(false), |
| delayed_cleanup_needed_(false), |
| within_process_died_observer_(false), |
| @@ -1760,6 +1761,14 @@ bool RenderProcessHostImpl::MayReuseHost() { |
| return GetContentClient()->browser()->MayReuseHost(this); |
| } |
| +bool RenderProcessHostImpl::CanBecomeDedicatedProcess() { |
| + return can_become_dedicated_process_; |
| +} |
| + |
| +void RenderProcessHostImpl::UnsetCanBecomeDedicatedProcess() { |
| + can_become_dedicated_process_ = false; |
|
alexmos
2017/06/12 17:35:07
Note that I'm specifically not calling this in Inc
|
| +} |
| + |
| mojom::RouteProvider* RenderProcessHostImpl::GetRemoteRouteProvider() { |
| return remote_route_provider_.get(); |
| } |
| @@ -2851,13 +2860,27 @@ bool RenderProcessHostImpl::IsSuitableHost(RenderProcessHost* host, |
| return false; |
| // TODO(nick): Consult the SiteIsolationPolicy here. https://crbug.com/513036 |
|
Charlie Reis
2017/06/12 23:08:17
Is this TODO resolved now?
alexmos
2017/06/14 22:39:04
Indeed, removed.
|
| - if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| - host->GetID()) != |
| + auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); |
| + if (policy->HasWebUIBindings(host->GetID()) != |
| WebUIControllerFactoryRegistry::GetInstance()->UseWebUIBindingsForURL( |
| browser_context, site_url)) { |
| return false; |
| } |
| + // Sites requiring dedicated processes can only reuse a compatible process. |
| + if (policy->HasOriginLock(host->GetID())) { |
| + // If the process is already dedicated to a site, only allow the destination |
| + // URL to reuse this process if the URL's has the same site. |
| + return policy->IsLockedToOrigin(host->GetID(), site_url); |
|
Charlie Reis
2017/06/12 23:08:17
I'm a little concerned about TOCTTOU problems here
alexmos
2017/06/14 22:39:05
Yes, good questions. Since we always set origin l
Charlie Reis
2017/06/17 23:13:53
I really like the enum idea, especially because it
alexmos
2017/06/19 20:03:58
Done.
|
| + } else if (!host->CanBecomeDedicatedProcess() && |
| + SiteInstanceImpl::DoesSiteRequireDedicatedProcess(browser_context, |
| + site_url)) { |
| + // Otherwise, if this process cannot host a site that requires a dedicated |
| + // process (e.g., if it has hosted any other content), it cannot be reused |
| + // if the destination site indeed requires a dedicated process. |
| + return false; |
| + } |
| + |
| return GetContentClient()->browser()->IsSuitableHost(host, site_url); |
| } |
| @@ -2902,20 +2925,9 @@ RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { |
| bool RenderProcessHost::ShouldTryToUseExistingProcessHost( |
| BrowserContext* browser_context, |
| const GURL& url) { |
| - // This needs to be checked first to ensure that --single-process |
| - // and --site-per-process can be used together. |
| if (run_renderer_in_process()) |
| return true; |
| - // If --site-per-process is enabled, do not try to reuse renderer processes |
| - // when over the limit. |
| - // TODO(nick): This is overly conservative and isn't launchable. Move this |
| - // logic into IsSuitableHost, and check |url| against the URL the process is |
| - // dedicated to. This will allow pages from the same site to share, and will |
| - // also allow non-isolated sites to share processes. https://crbug.com/513036 |
| - if (SiteIsolationPolicy::UseDedicatedProcessesForAllSites()) |
| - return false; |
| - |
| // NOTE: Sometimes it's necessary to create more render processes than |
| // GetMaxRendererProcessCount(), for instance when we want to create |
| // a renderer process for a browser context that has no existing |
| @@ -2991,11 +3003,10 @@ RenderProcessHost* RenderProcessHostImpl::GetProcessHostForSite( |
| // See if we have an existing process with appropriate bindings for this site. |
| // If not, the caller should create a new process and register it. |
| - std::string site = |
| - SiteInstance::GetSiteForURL(browser_context, url).possibly_invalid_spec(); |
| - RenderProcessHost* host = map->FindProcess(site); |
| + GURL site_url = SiteInstance::GetSiteForURL(browser_context, url); |
| + RenderProcessHost* host = map->FindProcess(site_url.possibly_invalid_spec()); |
| if (host && (!host->MayReuseHost() || |
| - !IsSuitableHost(host, browser_context, url))) { |
| + !IsSuitableHost(host, browser_context, site_url))) { |
|
alexmos
2017/06/12 17:35:07
After my IsSuitableHost modifications, a few exten
Charlie Reis
2017/06/12 23:08:17
Nice. Can you give an example of what the previou
alexmos
2017/06/14 22:39:05
Sorry, typo here - this should've just been "when
Charlie Reis
2017/06/17 23:13:52
I see now-- thanks!
alexmos
2017/06/19 20:03:58
Done - filed https://bugs.chromium.org/p/chromium/
|
| // The registered process does not have an appropriate set of bindings for |
| // the url. Remove it from the map so we can register a better one. |
| RecordAction( |