OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/browsing_instance.h" | 5 #include "content/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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.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 #include "content/browser/content_browser_client.h" |
12 #include "content/browser/site_instance.h" | 13 #include "content/browser/site_instance.h" |
13 #include "content/browser/webui/web_ui_factory.h" | 14 #include "content/browser/webui/web_ui_factory.h" |
| 15 #include "content/common/content_client.h" |
14 | 16 |
15 // static | 17 // static |
16 BrowsingInstance::ProfileSiteInstanceMap | 18 BrowsingInstance::ProfileSiteInstanceMap |
17 BrowsingInstance::profile_site_instance_map_; | 19 BrowsingInstance::profile_site_instance_map_; |
18 | 20 |
19 BrowsingInstance::BrowsingInstance(Profile* profile) | 21 BrowsingInstance::BrowsingInstance(Profile* profile) |
20 : profile_(profile) { | 22 : profile_(profile) { |
21 } | 23 } |
22 | 24 |
23 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { | 25 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { |
24 // Returns true if we should use the process-per-site model. This will be | 26 // Returns true if we should use the process-per-site model. This will be |
25 // the case if the --process-per-site switch is specified, or in | 27 // the case if the --process-per-site switch is specified, or in |
26 // process-per-site-instance for particular sites (e.g., the new tab page). | 28 // process-per-site-instance for particular sites (e.g., the new tab page). |
27 | 29 |
28 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 30 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
29 if (command_line.HasSwitch(switches::kProcessPerSite)) | 31 if (command_line.HasSwitch(switches::kProcessPerSite)) |
30 return true; | 32 return true; |
31 | 33 |
32 // We want to consolidate particular sites like extensions and WebUI whether | 34 // We want to consolidate particular sites like extensions and WebUI whether |
33 // it is in process-per-tab or process-per-site-instance. | 35 // it is in process-per-tab or process-per-site-instance. |
34 // 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 |
35 // 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 |
36 // about it here. | 38 // about it here. |
37 | 39 |
38 if (url.SchemeIs(chrome::kExtensionScheme)) | 40 if (url.SchemeIs(chrome::kExtensionScheme)) |
39 return true; | 41 return true; |
40 | 42 |
41 // DevTools pages have WebUI type but should not reuse the same host. | 43 // DevTools pages have WebUI type but should not reuse the same host. |
42 if (WebUIFactory::UseWebUIForURL(profile_, url) && | 44 if (content::WebUIFactory::Get()->UseWebUIForURL(profile_, url) && |
43 !url.SchemeIs(chrome::kChromeDevToolsScheme)) | 45 !url.SchemeIs(chrome::kChromeDevToolsScheme)) { |
44 return true; | 46 return true; |
| 47 } |
45 | 48 |
46 // In all other cases, don't use process-per-site logic. | 49 // In all other cases, don't use process-per-site logic. |
47 return false; | 50 return false; |
48 } | 51 } |
49 | 52 |
50 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( | 53 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( |
51 Profile* profile, const GURL& url) { | 54 Profile* profile, const GURL& url) { |
52 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) { | 55 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) { |
53 // Not using process-per-site, so use a map specific to this instance. | 56 // Not using process-per-site, so use a map specific to this instance. |
54 return &site_instance_map_; | 57 return &site_instance_map_; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return true; | 143 return true; |
141 } | 144 } |
142 return false; | 145 return false; |
143 } | 146 } |
144 | 147 |
145 BrowsingInstance::~BrowsingInstance() { | 148 BrowsingInstance::~BrowsingInstance() { |
146 // We should only be deleted when all of the SiteInstances that refer to | 149 // We should only be deleted when all of the SiteInstances that refer to |
147 // us are gone. | 150 // us are gone. |
148 DCHECK(site_instance_map_.empty()); | 151 DCHECK(site_instance_map_.empty()); |
149 } | 152 } |
OLD | NEW |