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

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: remove WebUISource references 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/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::GetContentClient()->browser()->GetWebUIFactory()->
jam 2011/03/25 02:10:02 content::GetContentClient()->browser()->GetWebUIFa
Evan Stade 2011/03/29 00:14:17 Done.
43 !url.SchemeIs(chrome::kChromeDevToolsScheme)) 45 UseWebUIForURL(profile_, url) &&
46 !url.SchemeIs(chrome::kChromeDevToolsScheme)) {
44 return true; 47 return true;
48 }
45 49
46 // In all other cases, don't use process-per-site logic. 50 // In all other cases, don't use process-per-site logic.
47 return false; 51 return false;
48 } 52 }
49 53
50 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( 54 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap(
51 Profile* profile, const GURL& url) { 55 Profile* profile, const GURL& url) {
52 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) { 56 if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(profile, url))) {
53 // Not using process-per-site, so use a map specific to this instance. 57 // Not using process-per-site, so use a map specific to this instance.
54 return &site_instance_map_; 58 return &site_instance_map_;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return true; 144 return true;
141 } 145 }
142 return false; 146 return false;
143 } 147 }
144 148
145 BrowsingInstance::~BrowsingInstance() { 149 BrowsingInstance::~BrowsingInstance() {
146 // We should only be deleted when all of the SiteInstances that refer to 150 // We should only be deleted when all of the SiteInstances that refer to
147 // us are gone. 151 // us are gone.
148 DCHECK(site_instance_map_.empty()); 152 DCHECK(site_instance_map_.empty());
149 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698