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

Unified Diff: content/browser/site_instance_impl_unittest.cc

Issue 16267002: Re-fix http://crbug.com/87176, and add a test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Much shorter test Created 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/site_instance_impl_unittest.cc
diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc
index 7e807bdc7f733199d8848784f61b4dd465585ee8..3c3a09c6a4de13479113bd117d911afac7e2d513 100644
--- a/content/browser/site_instance_impl_unittest.cc
+++ b/content/browser/site_instance_impl_unittest.cc
@@ -103,6 +103,7 @@ class SiteInstanceTest : public testing::Test {
EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd());
SetBrowserClientForTesting(old_browser_client_);
+ SiteInstanceImpl::set_render_process_host_factory(NULL);
// http://crbug.com/143565 found SiteInstanceTest leaking an
// AppCacheDatabase. This happens because some part of the test indirectly
@@ -543,21 +544,17 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) {
DrainMessageLoops();
}
-static SiteInstanceImpl* CreateSiteInstance(
- BrowserContext* browser_context,
- RenderProcessHostFactory* factory,
- const GURL& url) {
- SiteInstanceImpl* instance =
- reinterpret_cast<SiteInstanceImpl*>(
- SiteInstance::CreateForURL(browser_context, url));
- instance->set_render_process_host_factory(factory);
- return instance;
+static SiteInstanceImpl* CreateSiteInstance(BrowserContext* browser_context,
+ const GURL& url) {
+ return static_cast<SiteInstanceImpl*>(
+ SiteInstance::CreateForURL(browser_context, url));
}
// Test to ensure that pages that require certain privileges are grouped
// in processes with similar pages.
TEST_F(SiteInstanceTest, ProcessSharingByType) {
MockRenderProcessHostFactory rph_factory;
+ SiteInstanceImpl::set_render_process_host_factory(&rph_factory);
ChildProcessSecurityPolicyImpl* policy =
ChildProcessSecurityPolicyImpl::GetInstance();
@@ -569,12 +566,12 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
// Create some extension instances and make sure they share a process.
scoped_refptr<SiteInstanceImpl> extension1_instance(
- CreateSiteInstance(browser_context.get(), &rph_factory,
+ CreateSiteInstance(browser_context.get(),
GURL(kPrivilegedScheme + std::string("://foo/bar"))));
set_privileged_process_id(extension1_instance->GetProcess()->GetID());
scoped_refptr<SiteInstanceImpl> extension2_instance(
- CreateSiteInstance(browser_context.get(), &rph_factory,
+ CreateSiteInstance(browser_context.get(),
GURL(kPrivilegedScheme + std::string("://baz/bar"))));
scoped_ptr<RenderProcessHost> extension_host(
@@ -584,12 +581,12 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
// Create some WebUI instances and make sure they share a process.
scoped_refptr<SiteInstanceImpl> webui1_instance(CreateSiteInstance(
- browser_context.get(), &rph_factory,
+ browser_context.get(),
GURL(chrome::kChromeUIScheme + std::string("://newtab"))));
policy->GrantWebUIBindings(webui1_instance->GetProcess()->GetID());
scoped_refptr<SiteInstanceImpl> webui2_instance(CreateSiteInstance(
- browser_context.get(), &rph_factory,
+ browser_context.get(),
GURL(chrome::kChromeUIScheme + std::string("://history"))));
scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess());

Powered by Google App Engine
This is Rietveld 408576698