OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
9 #include "content/browser/browsing_instance.h" | 9 #include "content/browser/browsing_instance.h" |
10 #include "content/browser/child_process_security_policy.h" | 10 #include "content/browser/child_process_security_policy.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 const GURL url("test:foo"); | 181 const GURL url("test:foo"); |
182 | 182 |
183 // Ensure that instances are deleted when their NavigationEntries are gone. | 183 // Ensure that instances are deleted when their NavigationEntries are gone. |
184 TestSiteInstance* instance = | 184 TestSiteInstance* instance = |
185 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter, | 185 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter, |
186 &browsingDeleteCounter); | 186 &browsingDeleteCounter); |
187 EXPECT_EQ(0, siteDeleteCounter); | 187 EXPECT_EQ(0, siteDeleteCounter); |
188 | 188 |
189 NavigationEntry* e1 = new NavigationEntry(instance, 0, url, GURL(), | 189 NavigationEntry* e1 = new NavigationEntry(instance, 0, url, GURL(), |
190 string16(), | 190 string16(), |
191 PageTransition::LINK); | 191 content::PAGE_TRANSITION_LINK); |
192 | 192 |
193 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. | 193 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. |
194 e1->set_site_instance(instance); | 194 e1->set_site_instance(instance); |
195 EXPECT_EQ(0, siteDeleteCounter); | 195 EXPECT_EQ(0, siteDeleteCounter); |
196 | 196 |
197 // Add a second reference | 197 // Add a second reference |
198 NavigationEntry* e2 = new NavigationEntry(instance, 0, url, | 198 NavigationEntry* e2 = new NavigationEntry(instance, 0, url, |
199 GURL(), string16(), | 199 GURL(), string16(), |
200 PageTransition::LINK); | 200 content::PAGE_TRANSITION_LINK); |
201 | 201 |
202 // Now delete both entries and be sure the SiteInstance goes away. | 202 // Now delete both entries and be sure the SiteInstance goes away. |
203 delete e1; | 203 delete e1; |
204 EXPECT_EQ(0, siteDeleteCounter); | 204 EXPECT_EQ(0, siteDeleteCounter); |
205 EXPECT_EQ(0, browsingDeleteCounter); | 205 EXPECT_EQ(0, browsingDeleteCounter); |
206 delete e2; | 206 delete e2; |
207 EXPECT_EQ(1, siteDeleteCounter); | 207 EXPECT_EQ(1, siteDeleteCounter); |
208 // instance is now deleted | 208 // instance is now deleted |
209 EXPECT_EQ(1, browsingDeleteCounter); | 209 EXPECT_EQ(1, browsingDeleteCounter); |
210 // browsing_instance is now deleted | 210 // browsing_instance is now deleted |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 SiteInstance* instance1 = | 246 SiteInstance* instance1 = |
247 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1, | 247 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1, |
248 &browsingDeleteCounter); | 248 &browsingDeleteCounter); |
249 SiteInstance* instance2 = | 249 SiteInstance* instance2 = |
250 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, | 250 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, |
251 &browsingDeleteCounter); | 251 &browsingDeleteCounter); |
252 | 252 |
253 NavigationEntry* e1 = new NavigationEntry(instance1, 0, url, GURL(), | 253 NavigationEntry* e1 = new NavigationEntry(instance1, 0, url, GURL(), |
254 string16(), | 254 string16(), |
255 PageTransition::LINK); | 255 content::PAGE_TRANSITION_LINK); |
256 // Clone the entry | 256 // Clone the entry |
257 NavigationEntry* e2 = new NavigationEntry(*e1); | 257 NavigationEntry* e2 = new NavigationEntry(*e1); |
258 | 258 |
259 // Should be able to change the SiteInstance of the cloned entry. | 259 // Should be able to change the SiteInstance of the cloned entry. |
260 e2->set_site_instance(instance2); | 260 e2->set_site_instance(instance2); |
261 | 261 |
262 // The first SiteInstance should go away after deleting e1, since e2 should | 262 // The first SiteInstance should go away after deleting e1, since e2 should |
263 // no longer be referencing it. | 263 // no longer be referencing it. |
264 delete e1; | 264 delete e1; |
265 EXPECT_EQ(1, siteDeleteCounter1); | 265 EXPECT_EQ(1, siteDeleteCounter1); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 // Make sure none of differing privilege processes are mixed. | 556 // Make sure none of differing privilege processes are mixed. |
557 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); | 557 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); |
558 | 558 |
559 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { | 559 for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) { |
560 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); | 560 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); |
561 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); | 561 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); |
562 } | 562 } |
563 | 563 |
564 STLDeleteContainerPointers(hosts.begin(), hosts.end()); | 564 STLDeleteContainerPointers(hosts.begin(), hosts.end()); |
565 } | 565 } |
OLD | NEW |