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

Unified Diff: chrome/browser/renderer_host/site_instance.cc

Issue 2928004: Add unit test and supporting code to test process overflow case. (Closed)
Patch Set: linux compile error Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/site_instance.cc
diff --git a/chrome/browser/renderer_host/site_instance.cc b/chrome/browser/renderer_host/site_instance.cc
index cd409d9df4daf68076563eb56cfd143d710d61e6..b0f438695d4b6c4629336d31d7f41b6a642283c3 100644
--- a/chrome/browser/renderer_host/site_instance.cc
+++ b/chrome/browser/renderer_host/site_instance.cc
@@ -48,6 +48,13 @@ bool SiteInstance::HasProcess() const {
}
RenderProcessHost* SiteInstance::GetProcess() {
+ // TODO(erikkay) It would be nice to ensure that the renderer type had been
+ // properly set before we get here. The default tab creation case winds up
+ // with no site set at this point, so it will default to TYPE_NORMAL. This
+ // may not be correct, so we'll wind up potentially creating a process that
+ // we then throw away, or worse sharing a process with the wrong process type.
+ // See crbug.com/43448.
+
// Create a new process if ours went away or was reused.
if (!process_) {
// See if we should reuse an old process
@@ -194,21 +201,30 @@ GURL SiteInstance::GetEffectiveURL(Profile* profile, const GURL& url) {
}
}
-RenderProcessHost::Type SiteInstance::GetRendererType() {
- // We may not have a site at this point, which generally means this is a
- // normal navigation.
- if (!has_site_ || !site_.is_valid())
+/*static*/
+RenderProcessHost::Type SiteInstance::RendererTypeForURL(const GURL& url) {
+ if (!url.is_valid())
return RenderProcessHost::TYPE_NORMAL;
- if (site_.SchemeIs(chrome::kExtensionScheme))
+ if (url.SchemeIs(chrome::kExtensionScheme))
return RenderProcessHost::TYPE_EXTENSION;
- if (DOMUIFactory::HasDOMUIScheme(site_))
+ // TODO(erikkay) creis recommends using UseDOMUIForURL instead.
+ if (DOMUIFactory::HasDOMUIScheme(url))
return RenderProcessHost::TYPE_DOMUI;
return RenderProcessHost::TYPE_NORMAL;
}
+RenderProcessHost::Type SiteInstance::GetRendererType() {
+ // We may not have a site at this point, which generally means this is a
+ // normal navigation.
+ if (!has_site_)
+ return RenderProcessHost::TYPE_NORMAL;
+
+ return RendererTypeForURL(site_);
+}
+
void SiteInstance::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
« no previous file with comments | « chrome/browser/renderer_host/site_instance.h ('k') | chrome/browser/renderer_host/test/render_process_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698