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

Side by Side Diff: chrome/browser/tab_contents/site_instance.cc

Issue 126002: Group renderer processes by privilige when we hit the max process count.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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) 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/tab_contents/site_instance.h" 5 #include "chrome/browser/tab_contents/site_instance.h"
6 6
7 #include "chrome/browser/dom_ui/dom_ui_factory.h"
7 #include "chrome/browser/renderer_host/browser_render_process_host.h" 8 #include "chrome/browser/renderer_host/browser_render_process_host.h"
8 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
9 #include "chrome/common/notification_service.h" 10 #include "chrome/common/notification_service.h"
10 #include "net/base/registry_controlled_domain.h" 11 #include "net/base/registry_controlled_domain.h"
11 12
12 SiteInstance::SiteInstance(BrowsingInstance* browsing_instance) 13 SiteInstance::SiteInstance(BrowsingInstance* browsing_instance)
13 : browsing_instance_(browsing_instance), 14 : browsing_instance_(browsing_instance),
14 render_process_host_factory_(NULL), 15 render_process_host_factory_(NULL),
15 process_(NULL), 16 process_(NULL),
16 max_page_id_(-1), 17 max_page_id_(-1),
(...skipping 11 matching lines...) Expand all
28 if (has_site_) 29 if (has_site_)
29 browsing_instance_->UnregisterSiteInstance(this); 30 browsing_instance_->UnregisterSiteInstance(this);
30 } 31 }
31 32
32 RenderProcessHost* SiteInstance::GetProcess() { 33 RenderProcessHost* SiteInstance::GetProcess() {
33 // Create a new process if ours went away or was reused. 34 // Create a new process if ours went away or was reused.
34 if (!process_) { 35 if (!process_) {
35 // See if we should reuse an old process 36 // See if we should reuse an old process
36 if (RenderProcessHost::ShouldTryToUseExistingProcessHost()) 37 if (RenderProcessHost::ShouldTryToUseExistingProcessHost())
37 process_ = RenderProcessHost::GetExistingProcessHost( 38 process_ = RenderProcessHost::GetExistingProcessHost(
38 browsing_instance_->profile()); 39 browsing_instance_->profile(), GetRendererType());
39 40
40 // Otherwise (or if that fails), create a new one. 41 // Otherwise (or if that fails), create a new one.
41 if (!process_) { 42 if (!process_) {
42 if (render_process_host_factory_) { 43 if (render_process_host_factory_) {
43 process_ = render_process_host_factory_->CreateRenderProcessHost( 44 process_ = render_process_host_factory_->CreateRenderProcessHost(
44 browsing_instance_->profile()); 45 browsing_instance_->profile());
45 } else { 46 } else {
46 process_ = new BrowserRenderProcessHost(browsing_instance_->profile()); 47 process_ = new BrowserRenderProcessHost(browsing_instance_->profile());
47 } 48 }
48 } 49 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 160 }
160 161
161 // If the schemes differ, they aren't part of the same site. 162 // If the schemes differ, they aren't part of the same site.
162 if (url1.scheme() != url2.scheme()) { 163 if (url1.scheme() != url2.scheme()) {
163 return false; 164 return false;
164 } 165 }
165 166
166 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); 167 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2);
167 } 168 }
168 169
170 RenderProcessHost::Type SiteInstance::GetRendererType() {
171 // We may not have a site at this point, which generally means this is a
172 // normal navigation.
173 if (!has_site_ || !site_.is_valid())
174 return RenderProcessHost::TYPE_NORMAL;
175
176 if (site_.SchemeIs(chrome::kExtensionScheme))
177 return RenderProcessHost::TYPE_EXTENSION;
178
179 if (DOMUIFactory::HasDOMUIScheme(site_))
180 return RenderProcessHost::TYPE_DOMUI;
181
182 return RenderProcessHost::TYPE_NORMAL;
183 }
184
169 void SiteInstance::Observe(NotificationType type, 185 void SiteInstance::Observe(NotificationType type,
170 const NotificationSource& source, 186 const NotificationSource& source,
171 const NotificationDetails& details) { 187 const NotificationDetails& details) {
172 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); 188 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED);
173 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); 189 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr();
174 if (rph == process_) 190 if (rph == process_)
175 process_ = NULL; 191 process_ = NULL;
176 } 192 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/site_instance.h ('k') | chrome/browser/tab_contents/site_instance_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698