| 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/stl_util-inl.h" | 5 #include "base/stl_util-inl.h" |
| 6 #include "base/string16.h" | 6 #include "base/string16.h" |
| 7 #include "chrome/common/chrome_constants.h" | 7 #include "chrome/common/chrome_constants.h" |
| 8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/testing_profile.h" | 10 #include "chrome/test/testing_profile.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 int browsingDeleteCounter = 0; | 130 int browsingDeleteCounter = 0; |
| 131 const GURL url("test:foo"); | 131 const GURL url("test:foo"); |
| 132 | 132 |
| 133 // Ensure that instances are deleted when their NavigationEntries are gone. | 133 // Ensure that instances are deleted when their NavigationEntries are gone. |
| 134 TestSiteInstance* instance = | 134 TestSiteInstance* instance = |
| 135 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter, | 135 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter, |
| 136 &browsingDeleteCounter); | 136 &browsingDeleteCounter); |
| 137 EXPECT_EQ(0, siteDeleteCounter); | 137 EXPECT_EQ(0, siteDeleteCounter); |
| 138 | 138 |
| 139 NavigationEntry* e1 = new NavigationEntry(instance, 0, url, GURL(), | 139 NavigationEntry* e1 = new NavigationEntry(instance, 0, url, GURL(), |
| 140 string16(), | 140 base::i18n::String16WithDirection(), |
| 141 PageTransition::LINK); | 141 PageTransition::LINK); |
| 142 | 142 |
| 143 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. | 143 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. |
| 144 e1->set_site_instance(instance); | 144 e1->set_site_instance(instance); |
| 145 EXPECT_EQ(0, siteDeleteCounter); | 145 EXPECT_EQ(0, siteDeleteCounter); |
| 146 | 146 |
| 147 // Add a second reference | 147 // Add a second reference |
| 148 NavigationEntry* e2 = new NavigationEntry(instance, 0, url, | 148 NavigationEntry* e2 = new NavigationEntry(instance, 0, url, GURL(), |
| 149 GURL(), string16(), | 149 base::i18n::String16WithDirection(), |
| 150 PageTransition::LINK); | 150 PageTransition::LINK); |
| 151 | 151 |
| 152 // Now delete both entries and be sure the SiteInstance goes away. | 152 // Now delete both entries and be sure the SiteInstance goes away. |
| 153 delete e1; | 153 delete e1; |
| 154 EXPECT_EQ(0, siteDeleteCounter); | 154 EXPECT_EQ(0, siteDeleteCounter); |
| 155 EXPECT_EQ(0, browsingDeleteCounter); | 155 EXPECT_EQ(0, browsingDeleteCounter); |
| 156 delete e2; | 156 delete e2; |
| 157 EXPECT_EQ(1, siteDeleteCounter); | 157 EXPECT_EQ(1, siteDeleteCounter); |
| 158 // instance is now deleted | 158 // instance is now deleted |
| 159 EXPECT_EQ(1, browsingDeleteCounter); | 159 EXPECT_EQ(1, browsingDeleteCounter); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 190 const GURL url("test:foo"); | 190 const GURL url("test:foo"); |
| 191 | 191 |
| 192 SiteInstance* instance1 = | 192 SiteInstance* instance1 = |
| 193 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1, | 193 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1, |
| 194 &browsingDeleteCounter); | 194 &browsingDeleteCounter); |
| 195 SiteInstance* instance2 = | 195 SiteInstance* instance2 = |
| 196 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, | 196 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, |
| 197 &browsingDeleteCounter); | 197 &browsingDeleteCounter); |
| 198 | 198 |
| 199 NavigationEntry* e1 = new NavigationEntry(instance1, 0, url, GURL(), | 199 NavigationEntry* e1 = new NavigationEntry(instance1, 0, url, GURL(), |
| 200 string16(), | 200 base::i18n::String16WithDirection(), |
| 201 PageTransition::LINK); | 201 PageTransition::LINK); |
| 202 // Clone the entry | 202 // Clone the entry |
| 203 NavigationEntry* e2 = new NavigationEntry(*e1); | 203 NavigationEntry* e2 = new NavigationEntry(*e1); |
| 204 | 204 |
| 205 // Should be able to change the SiteInstance of the cloned entry. | 205 // Should be able to change the SiteInstance of the cloned entry. |
| 206 e2->set_site_instance(instance2); | 206 e2->set_site_instance(instance2); |
| 207 | 207 |
| 208 // The first SiteInstance should go away after deleting e1, since e2 should | 208 // The first SiteInstance should go away after deleting e1, since e2 should |
| 209 // no longer be referencing it. | 209 // no longer be referencing it. |
| 210 delete e1; | 210 delete e1; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 GURL("chrome-extension://baz/bar"))); | 569 GURL("chrome-extension://baz/bar"))); |
| 570 EXPECT_EQ(s5a, s5b); | 570 EXPECT_EQ(s5a, s5b); |
| 571 | 571 |
| 572 // The derived profiles with the different sites. | 572 // The derived profiles with the different sites. |
| 573 scoped_refptr<SiteInstance> s6a(instance1->GetSiteInstanceForURL( | 573 scoped_refptr<SiteInstance> s6a(instance1->GetSiteInstanceForURL( |
| 574 GURL("chrome-extension://baz/bar"))); | 574 GURL("chrome-extension://baz/bar"))); |
| 575 scoped_refptr<SiteInstance> s6b(instance3->GetSiteInstanceForURL( | 575 scoped_refptr<SiteInstance> s6b(instance3->GetSiteInstanceForURL( |
| 576 GURL("chrome-extension://foo/boo"))); | 576 GURL("chrome-extension://foo/boo"))); |
| 577 EXPECT_NE(s6a, s6b); | 577 EXPECT_NE(s6a, s6b); |
| 578 } | 578 } |
| OLD | NEW |