Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/browsing_instance.h" | 5 #include "chrome/browser/browsing_instance.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/dom_ui/dom_ui_factory.h" | |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/renderer_host/site_instance.h" | 11 #include "chrome/browser/renderer_host/site_instance.h" |
| 11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 13 | 14 |
| 14 /*static*/ | 15 /*static*/ |
| 15 BrowsingInstance::ProfileSiteInstanceMap | 16 BrowsingInstance::ProfileSiteInstanceMap |
| 16 BrowsingInstance::profile_site_instance_map_; | 17 BrowsingInstance::profile_site_instance_map_; |
| 17 | 18 |
| 18 BrowsingInstance::BrowsingInstance(Profile* profile) | 19 BrowsingInstance::BrowsingInstance(Profile* profile) |
| 19 : profile_(profile) { | 20 : profile_(profile) { |
| 20 } | 21 } |
| 21 | 22 |
| 22 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { | 23 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { |
| 23 // Returns true if we should use the process-per-site model. This will be | 24 // Returns true if we should use the process-per-site model. This will be |
| 24 // the case if the --process-per-site switch is specified, or in | 25 // the case if the --process-per-site switch is specified, or in |
| 25 // process-per-site-instance for particular sites (e.g., the new tab page). | 26 // process-per-site-instance for particular sites (e.g., the new tab page). |
| 26 | 27 |
| 27 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 28 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 28 if (command_line.HasSwitch(switches::kProcessPerSite)) | 29 if (command_line.HasSwitch(switches::kProcessPerSite)) |
| 29 return true; | 30 return true; |
| 30 | 31 |
| 31 if (url.SchemeIs(chrome::kExtensionScheme)) { | 32 // We want to consolidate the particular sites like extensions and DOMUI |
|
Charlie Reis
2011/01/06 21:36:59
Nit: "consolidate particular"
| |
| 32 // Always consolidate extensions regardless of the command line, because | 33 // whether it is in process-per-tab or process-per-site-instance. |
| 33 // they will break if split into multiple processes. | 34 // Note that --single-process may have been specified, but that affects the |
| 35 // process creation logic in RenderProcessHost, so we do not need to worry | |
| 36 // about it here. | |
| 37 | |
| 38 if (url.SchemeIs(chrome::kExtensionScheme)) | |
| 34 return true; | 39 return true; |
| 35 } | |
| 36 | 40 |
| 37 if (!command_line.HasSwitch(switches::kProcessPerTab)) { | 41 if (DOMUIFactory::UseDOMUIForURL(profile_, url)) |
| 38 // We are not in process-per-site or process-per-tab, so we must be in the | 42 return true; |
| 39 // default (process-per-site-instance). Only use the process-per-site | |
| 40 // logic for particular sites that we want to consolidate. | |
| 41 // Note that --single-process may have been specified, but that affects the | |
| 42 // process creation logic in RenderProcessHost, so we do not need to worry | |
| 43 // about it here. | |
| 44 if (url.SchemeIs(chrome::kChromeUIScheme)) | |
| 45 // Always consolidate instances of the new tab page (and instances of any | |
| 46 // other internal resource urls. | |
| 47 return true; | |
| 48 | |
| 49 // TODO(creis): List any other special cases that we want to limit to a | |
| 50 // single process for all instances. | |
| 51 } | |
| 52 | 43 |
| 53 // In all other cases, don't use process-per-site logic. | 44 // In all other cases, don't use process-per-site logic. |
| 54 return false; | 45 return false; |
| 55 } | 46 } |
| 56 | 47 |
| 57 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( | 48 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( |
| 58 Profile* profile, const GURL& url) { | 49 Profile* profile, const GURL& url) { |
| 59 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) { | 50 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) { |
| 60 // Not using process-per-site, so use a map specific to this instance. | 51 // Not using process-per-site, so use a map specific to this instance. |
| 61 return &site_instance_map_; | 52 return &site_instance_map_; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 return true; | 138 return true; |
| 148 } | 139 } |
| 149 return false; | 140 return false; |
| 150 } | 141 } |
| 151 | 142 |
| 152 BrowsingInstance::~BrowsingInstance() { | 143 BrowsingInstance::~BrowsingInstance() { |
| 153 // We should only be deleted when all of the SiteInstances that refer to | 144 // We should only be deleted when all of the SiteInstances that refer to |
| 154 // us are gone. | 145 // us are gone. |
| 155 DCHECK(site_instance_map_.empty()); | 146 DCHECK(site_instance_map_.empty()); |
| 156 } | 147 } |
| OLD | NEW |