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