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

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

Issue 6713082: Move WebUIFactory to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ContentWebUIClient Created 9 years, 9 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
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/site_instance.h" 12 #include "content/browser/site_instance.h"
13 #include "content/browser/webui/web_ui_factory.h" 13 #include "content/browser/webui/content_web_ui_client.h"
14 #include "content/common/content_client.h"
14 15
15 // static 16 // static
16 BrowsingInstance::ProfileSiteInstanceMap 17 BrowsingInstance::ProfileSiteInstanceMap
17 BrowsingInstance::profile_site_instance_map_; 18 BrowsingInstance::profile_site_instance_map_;
18 19
19 BrowsingInstance::BrowsingInstance(Profile* profile) 20 BrowsingInstance::BrowsingInstance(Profile* profile)
20 : profile_(profile) { 21 : profile_(profile) {
21 } 22 }
22 23
23 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { 24 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) {
24 // Returns true if we should use the process-per-site model. This will be 25 // 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 26 // 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). 27 // process-per-site-instance for particular sites (e.g., the new tab page).
27 28
28 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 29 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
29 if (command_line.HasSwitch(switches::kProcessPerSite)) 30 if (command_line.HasSwitch(switches::kProcessPerSite))
30 return true; 31 return true;
31 32
32 // We want to consolidate particular sites like extensions and WebUI whether 33 // We want to consolidate particular sites like extensions and WebUI whether
33 // it is in process-per-tab or process-per-site-instance. 34 // it is in process-per-tab or process-per-site-instance.
34 // Note that --single-process may have been specified, but that affects the 35 // 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 36 // process creation logic in RenderProcessHost, so we do not need to worry
36 // about it here. 37 // about it here.
37 38
38 if (url.SchemeIs(chrome::kExtensionScheme)) 39 if (url.SchemeIs(chrome::kExtensionScheme))
39 return true; 40 return true;
40 41
41 // DevTools pages have WebUI type but should not reuse the same host. 42 // DevTools pages have WebUI type but should not reuse the same host.
42 if (WebUIFactory::UseWebUIForURL(profile_, url) && 43 if (content::GetContentClient()->web_ui()->UseWebUIForURL(profile_, url) &&
43 !url.SchemeIs(chrome::kChromeDevToolsScheme)) 44 !url.SchemeIs(chrome::kChromeDevToolsScheme)) {
44 return true; 45 return true;
46 }
45 47
46 // In all other cases, don't use process-per-site logic. 48 // In all other cases, don't use process-per-site logic.
47 return false; 49 return false;
48 } 50 }
49 51
50 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( 52 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap(
51 Profile* profile, const GURL& url) { 53 Profile* profile, const GURL& url) {
52 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) { 54 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) {
53 // Not using process-per-site, so use a map specific to this instance. 55 // Not using process-per-site, so use a map specific to this instance.
54 return &site_instance_map_; 56 return &site_instance_map_;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return true; 142 return true;
141 } 143 }
142 return false; 144 return false;
143 } 145 }
144 146
145 BrowsingInstance::~BrowsingInstance() { 147 BrowsingInstance::~BrowsingInstance() {
146 // We should only be deleted when all of the SiteInstances that refer to 148 // We should only be deleted when all of the SiteInstances that refer to
147 // us are gone. 149 // us are gone.
148 DCHECK(site_instance_map_.empty()); 150 DCHECK(site_instance_map_.empty());
149 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698