Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 subframe->SendRendererInitiatedNavigationRequest(kUrl1, false); | 144 subframe->SendRendererInitiatedNavigationRequest(kUrl1, false); |
| 145 subframe->PrepareForCommit(); | 145 subframe->PrepareForCommit(); |
| 146 subframe->SendNavigateWithParams(¶ms); | 146 subframe->SendNavigateWithParams(¶ms); |
| 147 } | 147 } |
| 148 site_instance = SiteInstanceImpl::CreateForURL(browser_context(), kUrl1); | 148 site_instance = SiteInstanceImpl::CreateForURL(browser_context(), kUrl1); |
| 149 site_instance->set_process_reuse_policy( | 149 site_instance->set_process_reuse_policy( |
| 150 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE); | 150 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE); |
| 151 EXPECT_EQ(subframe->GetProcess(), site_instance->GetProcess()); | 151 EXPECT_EQ(subframe->GetProcess(), site_instance->GetProcess()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Check that only new processes that haven't yet hosted any web content are | |
| 155 // allowed to be reused to host a site requiring a dedicated process. | |
| 156 TEST_F(RenderProcessHostUnitTest, CanBecomeDedicatedProcess) { | |
| 157 const GURL kUrl1("http://foo.com"); | |
| 158 | |
| 159 // A process for a SiteInstance that has no site should be able to host any | |
| 160 // site that requires a dedicated process. | |
| 161 EXPECT_FALSE(main_test_rfh()->GetSiteInstance()->HasSite()); | |
| 162 EXPECT_TRUE(main_test_rfh()->GetProcess()->CanBecomeDedicatedProcess()); | |
| 163 { | |
| 164 scoped_refptr<SiteInstanceImpl> site_instance = | |
| 165 SiteInstanceImpl::Create(browser_context()); | |
| 166 EXPECT_FALSE(site_instance->HasSite()); | |
| 167 EXPECT_TRUE(site_instance->GetProcess()->CanBecomeDedicatedProcess()); | |
| 168 } | |
| 169 | |
| 170 // Navigation should mark the process as unable to become a dedicated process | |
| 171 // for arbitrary sites. | |
| 172 NavigateAndCommit(kUrl1); | |
| 173 EXPECT_FALSE(main_test_rfh()->GetProcess()->CanBecomeDedicatedProcess()); | |
| 174 | |
| 175 // A process for a SiteInstance that has been created for a particular site | |
| 176 // is considered unsuitable to host arbitrary sites requiring a dedicated | |
| 177 // process from the point it is created via GetProcess(). | |
| 178 { | |
| 179 scoped_refptr<SiteInstanceImpl> site_instance = | |
| 180 SiteInstanceImpl::CreateForURL(browser_context(), kUrl1); | |
| 181 EXPECT_FALSE(site_instance->GetProcess()->CanBecomeDedicatedProcess()); | |
|
Charlie Reis
2017/06/12 23:08:17
What would happen if kUrl1 was a site requiring a
alexmos
2017/06/14 22:39:05
Yes, I renamed the method and reworded the comment
| |
| 182 } | |
| 183 } | |
| 184 | |
| 154 // Tests that RenderProcessHost will not consider reusing a process that has | 185 // Tests that RenderProcessHost will not consider reusing a process that has |
| 155 // committed an error page. | 186 // committed an error page. |
| 156 TEST_F(RenderProcessHostUnitTest, DoNotReuseError) { | 187 TEST_F(RenderProcessHostUnitTest, DoNotReuseError) { |
| 157 const GURL kUrl1("http://foo.com"); | 188 const GURL kUrl1("http://foo.com"); |
| 158 const GURL kUrl2("http://bar.com"); | 189 const GURL kUrl2("http://bar.com"); |
| 159 | 190 |
| 160 // At first, trying to get a RenderProcessHost with the | 191 // At first, trying to get a RenderProcessHost with the |
| 161 // REUSE_PENDING_OR_COMMITTED_SITE policy should return a new process. | 192 // REUSE_PENDING_OR_COMMITTED_SITE policy should return a new process. |
| 162 scoped_refptr<SiteInstanceImpl> site_instance = | 193 scoped_refptr<SiteInstanceImpl> site_instance = |
| 163 SiteInstanceImpl::CreateForURL(browser_context(), kUrl1); | 194 SiteInstanceImpl::CreateForURL(browser_context(), kUrl1); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 // main RFH, as it was registered with the regular site URL when it committed. | 503 // main RFH, as it was registered with the regular site URL when it committed. |
| 473 main_test_rfh()->PrepareForCommit(); | 504 main_test_rfh()->PrepareForCommit(); |
| 474 main_test_rfh()->SendNavigate(0, true, kUrl); | 505 main_test_rfh()->SendNavigate(0, true, kUrl); |
| 475 site_instance = SiteInstanceImpl::CreateForURL(browser_context(), kUrl); | 506 site_instance = SiteInstanceImpl::CreateForURL(browser_context(), kUrl); |
| 476 site_instance->set_process_reuse_policy( | 507 site_instance->set_process_reuse_policy( |
| 477 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE); | 508 SiteInstanceImpl::ProcessReusePolicy::REUSE_PENDING_OR_COMMITTED_SITE); |
| 478 EXPECT_EQ(main_test_rfh()->GetProcess(), site_instance->GetProcess()); | 509 EXPECT_EQ(main_test_rfh()->GetProcess(), site_instance->GetProcess()); |
| 479 } | 510 } |
| 480 | 511 |
| 481 } // namespace content | 512 } // namespace content |
| OLD | NEW |