Page 1 of 1

Custom process model based on URL

PostPosted: Fri Feb 19, 2016 8:20 pm
by Kintoun
Seen this request posted before, so sharing the solution I created. We only have the process models as defined here - ... ess-models

I needed a way however to have local pages all loaded in the same process (web based UI) but still have external pages loaded in the default process-per-site-instance. I did this by implementing content::ContentBrowserClient::ShouldUseProcessPerSite in CefContentBrowserClient. It forwards the request to the application BrowserProcessHandler which my client code implements. It then returns either true or false depending on the site/host/etc of the URL.

Code: Select all
bool CefContentBrowserClient::ShouldUseProcessPerSite(
  content::BrowserContext* browser_context, const GURL& effective_url) {
  if (effective_url.is_valid())
    CefRefPtr<CefApp> app = CefContentClient::Get()->application();
    if (app.get()) {
      CefRefPtr<CefBrowserProcessHandler> handler =
      if (handler.get()) {
        return handler->ShouldUseProcessPerSite(effective_url.spec());

  return false;

You can see another example of this in how Chrome implements ShouldUseProcessPerSite in ChromeContentBrowserClient for its WebUI schemes.

On a side note I believe there is a bug with Chromium process-per-site (2171 branch). During site instance creation when it makes it to navigation it relies on a previous same site being registered in the site process map to use the same process. If you create two site instances with the same site quickly enough they will end up not sharing the same process (of course with process-per-site on). Neither has been registered with the site process map yet. Is this intended? Seems non-trivial to address. Where can I report this?