Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: content/browser/browsing_instance.cc

Issue 6708114: Revert 79691 - Move WebUIFactory to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | content/browser/content_browser_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
13 #include "content/browser/site_instance.h" 12 #include "content/browser/site_instance.h"
14 #include "content/browser/webui/web_ui_factory.h" 13 #include "content/browser/webui/web_ui_factory.h"
15 #include "content/common/content_client.h"
16 14
17 // static 15 // static
18 BrowsingInstance::ProfileSiteInstanceMap 16 BrowsingInstance::ProfileSiteInstanceMap
19 BrowsingInstance::profile_site_instance_map_; 17 BrowsingInstance::profile_site_instance_map_;
20 18
21 BrowsingInstance::BrowsingInstance(Profile* profile) 19 BrowsingInstance::BrowsingInstance(Profile* profile)
22 : profile_(profile) { 20 : profile_(profile) {
23 } 21 }
24 22
25 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { 23 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) {
26 // Returns true if we should use the process-per-site model. This will be 24 // Returns true if we should use the process-per-site model. This will be
27 // the case if the --process-per-site switch is specified, or in 25 // the case if the --process-per-site switch is specified, or in
28 // process-per-site-instance for particular sites (e.g., the new tab page). 26 // process-per-site-instance for particular sites (e.g., the new tab page).
29 27
30 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 28 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
31 if (command_line.HasSwitch(switches::kProcessPerSite)) 29 if (command_line.HasSwitch(switches::kProcessPerSite))
32 return true; 30 return true;
33 31
34 // We want to consolidate particular sites like extensions and WebUI whether 32 // We want to consolidate particular sites like extensions and WebUI whether
35 // it is in process-per-tab or process-per-site-instance. 33 // it is in process-per-tab or process-per-site-instance.
36 // Note that --single-process may have been specified, but that affects the 34 // Note that --single-process may have been specified, but that affects the
37 // process creation logic in RenderProcessHost, so we do not need to worry 35 // process creation logic in RenderProcessHost, so we do not need to worry
38 // about it here. 36 // about it here.
39 37
40 if (url.SchemeIs(chrome::kExtensionScheme)) 38 if (url.SchemeIs(chrome::kExtensionScheme))
41 return true; 39 return true;
42 40
43 // DevTools pages have WebUI type but should not reuse the same host. 41 // DevTools pages have WebUI type but should not reuse the same host.
44 if (content::WebUIFactory::Get()->UseWebUIForURL(profile_, url) && 42 if (WebUIFactory::UseWebUIForURL(profile_, url) &&
45 !url.SchemeIs(chrome::kChromeDevToolsScheme)) { 43 !url.SchemeIs(chrome::kChromeDevToolsScheme))
46 return true; 44 return true;
47 }
48 45
49 // In all other cases, don't use process-per-site logic. 46 // In all other cases, don't use process-per-site logic.
50 return false; 47 return false;
51 } 48 }
52 49
53 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( 50 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap(
54 Profile* profile, const GURL& url) { 51 Profile* profile, const GURL& url) {
55 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) { 52 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) {
56 // Not using process-per-site, so use a map specific to this instance. 53 // Not using process-per-site, so use a map specific to this instance.
57 return &site_instance_map_; 54 return &site_instance_map_;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return true; 140 return true;
144 } 141 }
145 return false; 142 return false;
146 } 143 }
147 144
148 BrowsingInstance::~BrowsingInstance() { 145 BrowsingInstance::~BrowsingInstance() {
149 // We should only be deleted when all of the SiteInstances that refer to 146 // We should only be deleted when all of the SiteInstances that refer to
150 // us are gone. 147 // us are gone.
151 DCHECK(site_instance_map_.empty()); 148 DCHECK(site_instance_map_.empty());
152 } 149 }
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | content/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698