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