| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/navigation_entry.h" | 5 #include "chrome/browser/navigation_entry.h" |
| 6 #include "chrome/browser/render_view_host.h" | 6 #include "chrome/browser/render_view_host.h" |
| 7 #include "chrome/browser/web_contents.h" | 7 #include "chrome/browser/web_contents.h" |
| 8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
| 9 #include "chrome/test/testing_profile.h" | 9 #include "chrome/test/testing_profile.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 int browsingDeleteCounter = 0; | 68 int browsingDeleteCounter = 0; |
| 69 const GURL url("test:foo"); | 69 const GURL url("test:foo"); |
| 70 | 70 |
| 71 // Ensure that instances are deleted when their NavigationEntries are gone. | 71 // Ensure that instances are deleted when their NavigationEntries are gone. |
| 72 TestSiteInstance* instance = | 72 TestSiteInstance* instance = |
| 73 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter, | 73 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter, |
| 74 &browsingDeleteCounter); | 74 &browsingDeleteCounter); |
| 75 EXPECT_EQ(0, siteDeleteCounter); | 75 EXPECT_EQ(0, siteDeleteCounter); |
| 76 | 76 |
| 77 NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, | 77 NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, |
| 78 GURL(), |
| 78 std::wstring(), | 79 std::wstring(), |
| 79 PageTransition::LINK); | 80 PageTransition::LINK); |
| 80 | 81 |
| 81 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. | 82 // Redundantly setting e1's SiteInstance shouldn't affect the ref count. |
| 82 e1->set_site_instance(instance); | 83 e1->set_site_instance(instance); |
| 83 EXPECT_EQ(0, siteDeleteCounter); | 84 EXPECT_EQ(0, siteDeleteCounter); |
| 84 | 85 |
| 85 // Add a second reference | 86 // Add a second reference |
| 86 NavigationEntry* e2 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, | 87 NavigationEntry* e2 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, |
| 87 std::wstring(), | 88 GURL(), std::wstring(), |
| 88 PageTransition::LINK); | 89 PageTransition::LINK); |
| 89 | 90 |
| 90 // Now delete both entries and be sure the SiteInstance goes away. | 91 // Now delete both entries and be sure the SiteInstance goes away. |
| 91 delete e1; | 92 delete e1; |
| 92 EXPECT_EQ(0, siteDeleteCounter); | 93 EXPECT_EQ(0, siteDeleteCounter); |
| 93 EXPECT_EQ(0, browsingDeleteCounter); | 94 EXPECT_EQ(0, browsingDeleteCounter); |
| 94 delete e2; | 95 delete e2; |
| 95 EXPECT_EQ(1, siteDeleteCounter); | 96 EXPECT_EQ(1, siteDeleteCounter); |
| 96 // instance is now deleted | 97 // instance is now deleted |
| 97 EXPECT_EQ(1, browsingDeleteCounter); | 98 EXPECT_EQ(1, browsingDeleteCounter); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 128 const GURL url("test:foo"); | 129 const GURL url("test:foo"); |
| 129 | 130 |
| 130 SiteInstance* instance1 = | 131 SiteInstance* instance1 = |
| 131 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1, | 132 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter1, |
| 132 &browsingDeleteCounter); | 133 &browsingDeleteCounter); |
| 133 SiteInstance* instance2 = | 134 SiteInstance* instance2 = |
| 134 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, | 135 TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, |
| 135 &browsingDeleteCounter); | 136 &browsingDeleteCounter); |
| 136 | 137 |
| 137 NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance1, 0, | 138 NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance1, 0, |
| 138 url, | 139 url, GURL(), |
| 139 std::wstring(), | 140 std::wstring(), |
| 140 PageTransition::LINK); | 141 PageTransition::LINK); |
| 141 // Clone the entry | 142 // Clone the entry |
| 142 NavigationEntry* e2 = new NavigationEntry(*e1); | 143 NavigationEntry* e2 = new NavigationEntry(*e1); |
| 143 | 144 |
| 144 // Should be able to change the SiteInstance of the cloned entry. | 145 // Should be able to change the SiteInstance of the cloned entry. |
| 145 e2->set_site_instance(instance2); | 146 e2->set_site_instance(instance2); |
| 146 | 147 |
| 147 // The first SiteInstance should go away after deleting e1, since e2 should | 148 // The first SiteInstance should go away after deleting e1, since e2 should |
| 148 // no longer be referencing it. | 149 // no longer be referencing it. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 376 |
| 376 // Should be able to see that we don't have SiteInstances. | 377 // Should be able to see that we don't have SiteInstances. |
| 377 EXPECT_FALSE(browsing_instance->HasSiteInstance( | 378 EXPECT_FALSE(browsing_instance->HasSiteInstance( |
| 378 GURL("https://www.google.com"))); // not visited before | 379 GURL("https://www.google.com"))); // not visited before |
| 379 EXPECT_FALSE(browsing_instance3->HasSiteInstance( | 380 EXPECT_FALSE(browsing_instance3->HasSiteInstance( |
| 380 GURL("http://www.yahoo.com"))); // different BI, different profile | 381 GURL("http://www.yahoo.com"))); // different BI, different profile |
| 381 | 382 |
| 382 // browsing_instances will be deleted when their SiteInstances are deleted | 383 // browsing_instances will be deleted when their SiteInstances are deleted |
| 383 } | 384 } |
| 384 | 385 |
| OLD | NEW |