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 | 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 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 21 if (command_line.HasSwitch(switches::kProcessPerSite)) |
21 return true; | 22 return true; |
22 | 23 |
23 if (!CommandLine().HasSwitch(switches::kProcessPerTab)) { | 24 if (!command_line.HasSwitch(switches::kProcessPerTab)) { |
24 // We are not in process-per-site or process-per-tab, so we must be in the | 25 // 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 | 26 // default (process-per-site-instance). Only use the process-per-site |
26 // logic for particular sites that we want to consolidate. | 27 // logic for particular sites that we want to consolidate. |
27 // Note that --single-process may have been specified, but that affects the | 28 // 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 | 29 // process creation logic in RenderProcessHost, so we do not need to worry |
29 // about it here. | 30 // about it here. |
30 if (url.SchemeIs("chrome")) | 31 if (url.SchemeIs("chrome")) |
31 // Always consolidate instances of the new tab page (and instances of any | 32 // Always consolidate instances of the new tab page (and instances of any |
32 // other internal resource urls). | 33 // other internal resource urls). |
33 return true; | 34 return true; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // for the site. (It might have been an unregistered SiteInstance. See the | 105 // for the site. (It might have been an unregistered SiteInstance. See the |
105 // comments in RegisterSiteInstance.) | 106 // comments in RegisterSiteInstance.) |
106 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); | 107 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); |
107 SiteInstanceMap::iterator i = map->find(site); | 108 SiteInstanceMap::iterator i = map->find(site); |
108 if (i != map->end() && i->second == site_instance) { | 109 if (i != map->end() && i->second == site_instance) { |
109 // Matches, so erase it. | 110 // Matches, so erase it. |
110 map->erase(i); | 111 map->erase(i); |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
OLD | NEW |