| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 | 550 |
| 551 static SiteInstanceImpl* CreateSiteInstance(BrowserContext* browser_context, | 551 static SiteInstanceImpl* CreateSiteInstance(BrowserContext* browser_context, |
| 552 const GURL& url) { | 552 const GURL& url) { |
| 553 return static_cast<SiteInstanceImpl*>( | 553 return static_cast<SiteInstanceImpl*>( |
| 554 SiteInstance::CreateForURL(browser_context, url)); | 554 SiteInstance::CreateForURL(browser_context, url)); |
| 555 } | 555 } |
| 556 | 556 |
| 557 // Test to ensure that pages that require certain privileges are grouped | 557 // Test to ensure that pages that require certain privileges are grouped |
| 558 // in processes with similar pages. | 558 // in processes with similar pages. |
| 559 TEST_F(SiteInstanceTest, ProcessSharingByType) { | 559 TEST_F(SiteInstanceTest, ProcessSharingByType) { |
| 560 // This test shouldn't run with --site-per-process mode, since it doesn't |
| 561 // allow render process reuse, which this test explicitly exercises. |
| 562 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) |
| 563 return; |
| 564 |
| 560 ChildProcessSecurityPolicyImpl* policy = | 565 ChildProcessSecurityPolicyImpl* policy = |
| 561 ChildProcessSecurityPolicyImpl::GetInstance(); | 566 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 562 | 567 |
| 563 // Make a bunch of mock renderers so that we hit the limit. | 568 // Make a bunch of mock renderers so that we hit the limit. |
| 564 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); | 569 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); |
| 565 ScopedVector<MockRenderProcessHost> hosts; | 570 ScopedVector<MockRenderProcessHost> hosts; |
| 566 for (size_t i = 0; i < kMaxRendererProcessCount; ++i) | 571 for (size_t i = 0; i < kMaxRendererProcessCount; ++i) |
| 567 hosts.push_back(new MockRenderProcessHost(browser_context.get())); | 572 hosts.push_back(new MockRenderProcessHost(browser_context.get())); |
| 568 | 573 |
| 569 // Create some extension instances and make sure they share a process. | 574 // Create some extension instances and make sure they share a process. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 EXPECT_TRUE(instance->GetSiteURL().is_empty()); | 757 EXPECT_TRUE(instance->GetSiteURL().is_empty()); |
| 753 host.reset(instance->GetProcess()); | 758 host.reset(instance->GetProcess()); |
| 754 | 759 |
| 755 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( | 760 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( |
| 756 browser_context.get(), GURL())); | 761 browser_context.get(), GURL())); |
| 757 | 762 |
| 758 DrainMessageLoops(); | 763 DrainMessageLoops(); |
| 759 } | 764 } |
| 760 | 765 |
| 761 } // namespace content | 766 } // namespace content |
| OLD | NEW |