| Index: content/browser/site_instance_unittest.cc
|
| ===================================================================
|
| --- content/browser/site_instance_unittest.cc (revision 118703)
|
| +++ content/browser/site_instance_unittest.cc (working copy)
|
| @@ -12,7 +12,7 @@
|
| #include "content/browser/renderer_host/render_process_host_impl.h"
|
| #include "content/browser/renderer_host/render_view_host.h"
|
| #include "content/browser/renderer_host/test_render_view_host.h"
|
| -#include "content/browser/site_instance.h"
|
| +#include "content/browser/site_instance_impl.h"
|
| #include "content/browser/tab_contents/navigation_entry_impl.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
| #include "content/browser/webui/empty_web_ui_factory.h"
|
| @@ -152,7 +152,7 @@
|
| int* delete_counter_;
|
| };
|
|
|
| -class TestSiteInstance : public SiteInstance {
|
| +class TestSiteInstance : public SiteInstanceImpl {
|
| public:
|
| static TestSiteInstance* CreateTestSiteInstance(
|
| content::BrowserContext* browser_context,
|
| @@ -165,7 +165,7 @@
|
|
|
| private:
|
| TestSiteInstance(BrowsingInstance* browsing_instance, int* delete_counter)
|
| - : SiteInstance(browsing_instance), delete_counter_(delete_counter) {}
|
| + : SiteInstanceImpl(browsing_instance), delete_counter_(delete_counter) {}
|
| virtual ~TestSiteInstance() {
|
| (*delete_counter_)++;
|
| }
|
| @@ -248,10 +248,10 @@
|
| int browsing_delete_counter = 0;
|
| const GURL url("test:foo");
|
|
|
| - SiteInstance* instance1 =
|
| + content::SiteInstance* instance1 =
|
| TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter1,
|
| &browsing_delete_counter);
|
| - SiteInstance* instance2 =
|
| + content::SiteInstance* instance2 =
|
| TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter2,
|
| &browsing_delete_counter);
|
|
|
| @@ -284,14 +284,14 @@
|
| // Ensure that GetProcess returns a process.
|
| scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
|
| scoped_ptr<content::RenderProcessHost> host1;
|
| - scoped_refptr<SiteInstance> instance(
|
| - SiteInstance::CreateSiteInstance(browser_context.get()));
|
| + scoped_refptr<content::SiteInstance> instance(
|
| + content::SiteInstance::CreateSiteInstance(browser_context.get()));
|
| host1.reset(instance->GetProcess());
|
| EXPECT_TRUE(host1.get() != NULL);
|
|
|
| // Ensure that GetProcess creates a new process.
|
| - scoped_refptr<SiteInstance> instance2(
|
| - SiteInstance::CreateSiteInstance(browser_context.get()));
|
| + scoped_refptr<content::SiteInstance> instance2(
|
| + content::SiteInstance::CreateSiteInstance(browser_context.get()));
|
| scoped_ptr<content::RenderProcessHost> host2(instance2->GetProcess());
|
| EXPECT_TRUE(host2.get() != NULL);
|
| EXPECT_NE(host1.get(), host2.get());
|
| @@ -299,14 +299,15 @@
|
|
|
| // Test to ensure SetSite and site() work properly.
|
| TEST_F(SiteInstanceTest, SetSite) {
|
| - scoped_refptr<SiteInstance> instance(SiteInstance::CreateSiteInstance(NULL));
|
| - EXPECT_FALSE(instance->has_site());
|
| - EXPECT_TRUE(instance->site().is_empty());
|
| + scoped_refptr<content::SiteInstance> instance(
|
| + content::SiteInstance::CreateSiteInstance(NULL));
|
| + EXPECT_FALSE(instance->HasSite());
|
| + EXPECT_TRUE(instance->GetSite().is_empty());
|
|
|
| instance->SetSite(GURL("http://www.google.com/index.html"));
|
| - EXPECT_EQ(GURL("http://google.com"), instance->site());
|
| + EXPECT_EQ(GURL("http://google.com"), instance->GetSite());
|
|
|
| - EXPECT_TRUE(instance->has_site());
|
| + EXPECT_TRUE(instance->HasSite());
|
| }
|
|
|
| // Test to ensure GetSiteForURL properly returns sites for URLs.
|
| @@ -314,22 +315,23 @@
|
| // Pages are irrelevant.
|
| GURL test_url = GURL("http://www.google.com/index.html");
|
| EXPECT_EQ(GURL("http://google.com"),
|
| - SiteInstance::GetSiteForURL(NULL, test_url));
|
| + content::SiteInstance::GetSiteForURL(NULL, test_url));
|
|
|
| // Ports are irrlevant.
|
| test_url = GURL("https://www.google.com:8080");
|
| EXPECT_EQ(GURL("https://google.com"),
|
| - SiteInstance::GetSiteForURL(NULL, test_url));
|
| + content::SiteInstance::GetSiteForURL(NULL, test_url));
|
|
|
| // Javascript URLs have no site.
|
| test_url = GURL("javascript:foo();");
|
| - EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(NULL, test_url));
|
| + EXPECT_EQ(GURL(), content::SiteInstance::GetSiteForURL(NULL, test_url));
|
|
|
| test_url = GURL("http://foo/a.html");
|
| - EXPECT_EQ(GURL("http://foo"), SiteInstance::GetSiteForURL(NULL, test_url));
|
| + EXPECT_EQ(GURL("http://foo"), content::SiteInstance::GetSiteForURL(
|
| + NULL, test_url));
|
|
|
| test_url = GURL("file:///C:/Downloads/");
|
| - EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(NULL, test_url));
|
| + EXPECT_EQ(GURL(), content::SiteInstance::GetSiteForURL(NULL, test_url));
|
|
|
| // TODO(creis): Do we want to special case file URLs to ensure they have
|
| // either no site or a special "file://" site? We currently return
|
| @@ -351,25 +353,32 @@
|
| GURL url_browser_specified = GURL(kSameAsAnyInstanceURL);
|
|
|
| // Same scheme and port -> same site.
|
| - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo2));
|
| + EXPECT_TRUE(content::SiteInstance::IsSameWebSite(NULL, url_foo, url_foo2));
|
|
|
| // Different scheme -> different site.
|
| - EXPECT_FALSE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo_https));
|
| + EXPECT_FALSE(content::SiteInstance::IsSameWebSite(NULL, url_foo,
|
| + url_foo_https));
|
|
|
| // Different port -> same site.
|
| // (Changes to document.domain make renderer ignore the port.)
|
| - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo_port));
|
| + EXPECT_TRUE(content::SiteInstance::IsSameWebSite(NULL, url_foo,
|
| + url_foo_port));
|
|
|
| // JavaScript links should be considered same site for anything.
|
| - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo));
|
| - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_https));
|
| - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_port));
|
| + EXPECT_TRUE(content::SiteInstance::IsSameWebSite(NULL, url_javascript,
|
| + url_foo));
|
| + EXPECT_TRUE(content::SiteInstance::IsSameWebSite(NULL, url_javascript,
|
| + url_foo_https));
|
| + EXPECT_TRUE(content::SiteInstance::IsSameWebSite(NULL, url_javascript,
|
| + url_foo_port));
|
|
|
| // The URLs specified by the ContentBrowserClient should also be treated as
|
| // same site.
|
| - EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_crash, url_foo));
|
| + EXPECT_TRUE(content::SiteInstance::IsSameWebSite(NULL, url_crash,
|
| + url_foo));
|
| EXPECT_TRUE(
|
| - SiteInstance::IsSameWebSite(NULL, url_browser_specified, url_foo));
|
| + content::SiteInstance::IsSameWebSite(NULL, url_browser_specified,
|
| + url_foo));
|
| }
|
|
|
| // Test to ensure that there is only one SiteInstance per site in a given
|
| @@ -381,13 +390,13 @@
|
| browsing_instance->set_use_process_per_site(false);
|
|
|
| const GURL url_a1("http://www.google.com/1.html");
|
| - scoped_refptr<SiteInstance> site_instance_a1(
|
| + scoped_refptr<content::SiteInstance> site_instance_a1(
|
| browsing_instance->GetSiteInstanceForURL(url_a1));
|
| EXPECT_TRUE(site_instance_a1.get() != NULL);
|
|
|
| // A separate site should create a separate SiteInstance.
|
| const GURL url_b1("http://www.yahoo.com/");
|
| - scoped_refptr<SiteInstance> site_instance_b1(
|
| + scoped_refptr<content::SiteInstance> site_instance_b1(
|
| browsing_instance->GetSiteInstanceForURL(url_b1));
|
| EXPECT_NE(site_instance_a1.get(), site_instance_b1.get());
|
|
|
| @@ -409,7 +418,7 @@
|
| new TestBrowsingInstance(NULL, &delete_counter);
|
| browsing_instance2->set_use_process_per_site(false);
|
| // Ensure the new SiteInstance is ref counted so that it gets deleted.
|
| - scoped_refptr<SiteInstance> site_instance_a2_2(
|
| + scoped_refptr<content::SiteInstance> site_instance_a2_2(
|
| browsing_instance2->GetSiteInstanceForURL(url_a2));
|
| EXPECT_NE(site_instance_a1.get(), site_instance_a2_2.get());
|
|
|
| @@ -439,13 +448,13 @@
|
| browsing_instance->set_use_process_per_site(true);
|
|
|
| const GURL url_a1("http://www.google.com/1.html");
|
| - scoped_refptr<SiteInstance> site_instance_a1(
|
| + scoped_refptr<content::SiteInstance> site_instance_a1(
|
| browsing_instance->GetSiteInstanceForURL(url_a1));
|
| EXPECT_TRUE(site_instance_a1.get() != NULL);
|
|
|
| // A separate site should create a separate SiteInstance.
|
| const GURL url_b1("http://www.yahoo.com/");
|
| - scoped_refptr<SiteInstance> site_instance_b1(
|
| + scoped_refptr<content::SiteInstance> site_instance_b1(
|
| browsing_instance->GetSiteInstanceForURL(url_b1));
|
| EXPECT_NE(site_instance_a1.get(), site_instance_b1.get());
|
|
|
| @@ -479,7 +488,7 @@
|
| new TestBrowsingInstance(browser_context.get(), &delete_counter);
|
| browsing_instance3->set_use_process_per_site(true);
|
| // Ensure the new SiteInstance is ref counted so that it gets deleted.
|
| - scoped_refptr<SiteInstance> site_instance_a2_3(
|
| + scoped_refptr<content::SiteInstance> site_instance_a2_3(
|
| browsing_instance3->GetSiteInstanceForURL(url_a2));
|
| EXPECT_NE(site_instance_a1.get(), site_instance_a2_3.get());
|
|
|
| @@ -502,9 +511,11 @@
|
| // browsing_instances will be deleted when their SiteInstances are deleted
|
| }
|
|
|
| -static SiteInstance* CreateSiteInstance(
|
| +static SiteInstanceImpl* CreateSiteInstance(
|
| content::RenderProcessHostFactory* factory, const GURL& url) {
|
| - SiteInstance* instance = SiteInstance::CreateSiteInstanceForURL(NULL, url);
|
| + SiteInstanceImpl* instance =
|
| + reinterpret_cast<SiteInstanceImpl*>(
|
| + content::SiteInstance::CreateSiteInstanceForURL(NULL, url));
|
| instance->set_render_process_host_factory(factory);
|
| return instance;
|
| }
|
| @@ -522,14 +533,14 @@
|
| hosts.push_back(new MockRenderProcessHost(NULL));
|
|
|
| // Create some extension instances and make sure they share a process.
|
| - scoped_refptr<SiteInstance> extension1_instance(
|
| + scoped_refptr<content::SiteInstance> extension1_instance(
|
| CreateSiteInstance(&rph_factory,
|
| - GURL(kPrivilegedScheme + std::string("://foo/bar"))));
|
| + GURL(kPrivilegedScheme + std::string("://foo/bar"))));
|
| set_privileged_process_id(extension1_instance->GetProcess()->GetID());
|
|
|
| - scoped_refptr<SiteInstance> extension2_instance(
|
| + scoped_refptr<content::SiteInstance> extension2_instance(
|
| CreateSiteInstance(&rph_factory,
|
| - GURL(kPrivilegedScheme + std::string("://baz/bar"))));
|
| + GURL(kPrivilegedScheme + std::string("://baz/bar"))));
|
|
|
| scoped_ptr<content::RenderProcessHost> extension_host(
|
| extension1_instance->GetProcess());
|
| @@ -537,11 +548,13 @@
|
| extension2_instance->GetProcess());
|
|
|
| // Create some WebUI instances and make sure they share a process.
|
| - scoped_refptr<SiteInstance> webui1_instance(CreateSiteInstance(&rph_factory,
|
| + scoped_refptr<content::SiteInstance> webui1_instance(CreateSiteInstance(
|
| + &rph_factory,
|
| GURL(chrome::kChromeUIScheme + std::string("://newtab"))));
|
| policy->GrantWebUIBindings(webui1_instance->GetProcess()->GetID());
|
|
|
| - scoped_refptr<SiteInstance> webui2_instance(CreateSiteInstance(&rph_factory,
|
| + scoped_refptr<content::SiteInstance> webui2_instance(CreateSiteInstance(
|
| + &rph_factory,
|
| GURL(chrome::kChromeUIScheme + std::string("://history"))));
|
|
|
| scoped_ptr<content::RenderProcessHost> dom_host(
|
| @@ -564,14 +577,14 @@
|
| TEST_F(SiteInstanceTest, HasWrongProcessForURL) {
|
| scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
|
| scoped_ptr<content::RenderProcessHost> host;
|
| - scoped_refptr<SiteInstance> instance(
|
| - SiteInstance::CreateSiteInstance(browser_context.get()));
|
| + scoped_refptr<content::SiteInstance> instance(
|
| + content::SiteInstance::CreateSiteInstance(browser_context.get()));
|
|
|
| - EXPECT_FALSE(instance->has_site());
|
| - EXPECT_TRUE(instance->site().is_empty());
|
| + EXPECT_FALSE(instance->HasSite());
|
| + EXPECT_TRUE(instance->GetSite().is_empty());
|
|
|
| instance->SetSite(GURL("http://evernote.com/"));
|
| - EXPECT_TRUE(instance->has_site());
|
| + EXPECT_TRUE(instance->HasSite());
|
|
|
| // Check prior to "assigning" a process to the instance, which is expected
|
| // to return false due to not being attached to any process yet.
|
|
|