| 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 "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/renderer_host/site_instance.h" | 9 #include "chrome/browser/renderer_host/site_instance.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 | 12 |
| 13 /*static*/ | 13 /*static*/ |
| 14 BrowsingInstance::ProfileSiteInstanceMap | 14 BrowsingInstance::ProfileSiteInstanceMap |
| 15 BrowsingInstance::profile_site_instance_map_; | 15 BrowsingInstance::profile_site_instance_map_; |
| 16 | 16 |
| 17 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { | 17 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { |
| 18 // Returns true if we should use the process-per-site model. This will be | 18 // Returns true if we should use the process-per-site model. This will be |
| 19 // the case if the --process-per-site switch is specified, or in | 19 // the case if the --process-per-site switch is specified, or in |
| 20 // process-per-site-instance for particular sites (e.g., the new tab page). | 20 // process-per-site-instance for particular sites (e.g., the new tab page). |
| 21 | 21 |
| 22 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 22 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 23 if (command_line.HasSwitch(switches::kProcessPerSite)) | 23 if (command_line.HasSwitch(switches::kProcessPerSite)) |
| 24 return true; | 24 return true; |
| 25 |
| 26 if (url.SchemeIs(chrome::kExtensionScheme)) { |
| 27 // Always consolidate extensions regardless of the command line, because |
| 28 // they will break if split into multiple processes. |
| 29 return true; |
| 30 } |
| 25 | 31 |
| 26 if (!command_line.HasSwitch(switches::kProcessPerTab)) { | 32 if (!command_line.HasSwitch(switches::kProcessPerTab)) { |
| 27 // We are not in process-per-site or process-per-tab, so we must be in the | 33 // We are not in process-per-site or process-per-tab, so we must be in the |
| 28 // default (process-per-site-instance). Only use the process-per-site | 34 // default (process-per-site-instance). Only use the process-per-site |
| 29 // logic for particular sites that we want to consolidate. | 35 // logic for particular sites that we want to consolidate. |
| 30 // Note that --single-process may have been specified, but that affects the | 36 // Note that --single-process may have been specified, but that affects the |
| 31 // process creation logic in RenderProcessHost, so we do not need to worry | 37 // process creation logic in RenderProcessHost, so we do not need to worry |
| 32 // about it here. | 38 // about it here. |
| 33 if (url.SchemeIs(chrome::kChromeUIScheme) || | 39 if (url.SchemeIs(chrome::kChromeUIScheme)) |
| 34 url.SchemeIs(chrome::kExtensionScheme)) | |
| 35 // Always consolidate instances of the new tab page (and instances of any | 40 // Always consolidate instances of the new tab page (and instances of any |
| 36 // other internal resource urls), as well as extensions. | 41 // other internal resource urls. |
| 37 return true; | 42 return true; |
| 38 | 43 |
| 39 // TODO(creis): List any other special cases that we want to limit to a | 44 // TODO(creis): List any other special cases that we want to limit to a |
| 40 // single process for all instances. | 45 // single process for all instances. |
| 41 } | 46 } |
| 42 | 47 |
| 43 // In all other cases, don't use process-per-site logic. | 48 // In all other cases, don't use process-per-site logic. |
| 44 return false; | 49 return false; |
| 45 } | 50 } |
| 46 | 51 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Only unregister the SiteInstance if it is the same one that is registered | 116 // Only unregister the SiteInstance if it is the same one that is registered |
| 112 // for the site. (It might have been an unregistered SiteInstance. See the | 117 // for the site. (It might have been an unregistered SiteInstance. See the |
| 113 // comments in RegisterSiteInstance.) | 118 // comments in RegisterSiteInstance.) |
| 114 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); | 119 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); |
| 115 SiteInstanceMap::iterator i = map->find(site); | 120 SiteInstanceMap::iterator i = map->find(site); |
| 116 if (i != map->end() && i->second == site_instance) { | 121 if (i != map->end() && i->second == site_instance) { |
| 117 // Matches, so erase it. | 122 // Matches, so erase it. |
| 118 map->erase(i); | 123 map->erase(i); |
| 119 } | 124 } |
| 120 } | 125 } |
| OLD | NEW |