summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-15 23:44:14 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-15 23:44:14 +0000
commit2ed62e2e06281783050df600a7f933557be055a5 (patch)
treebd0d2a4f8bd739388cb8bd1d8fb0b1a0302b4b8e /chrome/browser
parenta9f4d90f8a1643ccc27aba95cf60c4531b3db7b9 (diff)
downloadchromium_src-2ed62e2e06281783050df600a7f933557be055a5.zip
chromium_src-2ed62e2e06281783050df600a7f933557be055a5.tar.gz
chromium_src-2ed62e2e06281783050df600a7f933557be055a5.tar.bz2
Try again to fix the memory problems in NavigationController. The previous one
issued a DCHECK when I manlually deleted the NavigationController because the tabs were still there. Calling destroy fixes this, although I have to manually NULL out some test pointers to prevent double-frees. Review URL: http://codereview.chromium.org/3070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/navigation_controller_unittest.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc
index 5f9d85e..0f9b2ff 100644
--- a/chrome/browser/navigation_controller_unittest.cc
+++ b/chrome/browser/navigation_controller_unittest.cc
@@ -35,7 +35,8 @@ const TabContentsType kTestContentsType2 =
static_cast<TabContentsType>(TAB_CONTENTS_NUM_TYPES + 2);
// Tests can set this to set the site instance for all the test contents. This
-// refcounted pointer will be automatically derefed on cleanup.
+// refcounted pointer will NOT be derefed on cleanup (the tests do this
+// themselves).
static SiteInstance* site_instance;
// TestContents ----------------------------------------------------------------
@@ -129,10 +130,7 @@ class NavigationControllerTest : public testing::Test,
}
virtual void TearDown() {
- if (site_instance) {
- site_instance->Release();
- site_instance = NULL;
- }
+ site_instance = NULL;
// Make sure contents is valid. NavigationControllerHistoryTest ends up
// resetting this before TearDown is invoked.
@@ -1219,6 +1217,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
// SiteInstance for the entries created initially.
TEST_F(NavigationControllerTest, RestoreNavigate) {
site_instance = SiteInstance::CreateSiteInstance(profile);
+ site_instance->AddRef();
// Create a NavigationController with a restored set of tabs.
GURL url("test1:foo");
@@ -1253,6 +1252,11 @@ TEST_F(NavigationControllerTest, RestoreNavigate) {
EXPECT_FALSE(controller->GetPendingEntry());
EXPECT_EQ(site_instance,
controller->GetLastCommittedEntry()->site_instance());
+
+ // Clean up the navigation controller.
+ ClearContents();
+ controller->Destroy();
+ site_instance->Release();
}
// Make sure that the page type and stuff is correct after an interstitial.