diff options
author | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-20 03:02:34 +0000 |
---|---|---|
committer | marja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-20 03:02:34 +0000 |
commit | 52986e4fa008b6bb5b9c2f9619811a2da9431b07 (patch) | |
tree | 78d85c9a7a13303d4cbf314f6fb422656bee5fd5 /content | |
parent | 174cc2580a9e0a0bbccd35493889008d2a98dcd3 (diff) | |
download | chromium_src-52986e4fa008b6bb5b9c2f9619811a2da9431b07.zip chromium_src-52986e4fa008b6bb5b9c2f9619811a2da9431b07.tar.gz chromium_src-52986e4fa008b6bb5b9c2f9619811a2da9431b07.tar.bz2 |
Fixing a memory leak in DOMStorageTest.SessionOnly.
WebKitContext destroys DOMStorageContext in a delayed way, so
spin the message loop after the test to get it deleted.
BUG=NONE
TEST=DOMStorageTest.SessionOnly & happier memory bots
Review URL: http://codereview.chromium.org/7698003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/in_process_webkit/dom_storage_unittest.cc | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/content/browser/in_process_webkit/dom_storage_unittest.cc b/content/browser/in_process_webkit/dom_storage_unittest.cc index 14f5a30..9c37adc 100644 --- a/content/browser/in_process_webkit/dom_storage_unittest.cc +++ b/content/browser/in_process_webkit/dom_storage_unittest.cc @@ -29,39 +29,44 @@ TEST_F(DOMStorageTest, SessionOnly) { new quota::MockSpecialStoragePolicy; special_storage_policy->AddSessionOnly(session_only_origin); - TestingProfile profile; + // A scope for deleting TestingProfile early enough. + { + TestingProfile profile; - // Create databases for permanent and session-only origins. - FilePath domstorage_dir = profile.GetPath().Append( - DOMStorageContext::kLocalStorageDirectory); - FilePath::StringType session_only_database( - FILE_PATH_LITERAL("http_www.sessiononly.com_0")); - FilePath::StringType permanent_database( - FILE_PATH_LITERAL("http_www.permanent.com_0")); - session_only_database.append(DOMStorageContext::kLocalStorageExtension); - permanent_database.append(DOMStorageContext::kLocalStorageExtension); - FilePath session_only_database_path = - domstorage_dir.Append(session_only_database); - FilePath permanent_database_path = - domstorage_dir.Append(permanent_database); + // Create databases for permanent and session-only origins. + FilePath domstorage_dir = profile.GetPath().Append( + DOMStorageContext::kLocalStorageDirectory); + FilePath::StringType session_only_database( + FILE_PATH_LITERAL("http_www.sessiononly.com_0")); + FilePath::StringType permanent_database( + FILE_PATH_LITERAL("http_www.permanent.com_0")); + session_only_database.append(DOMStorageContext::kLocalStorageExtension); + permanent_database.append(DOMStorageContext::kLocalStorageExtension); + FilePath session_only_database_path = + domstorage_dir.Append(session_only_database); + FilePath permanent_database_path = + domstorage_dir.Append(permanent_database); - ASSERT_TRUE(file_util::CreateDirectory(domstorage_dir)); + ASSERT_TRUE(file_util::CreateDirectory(domstorage_dir)); - ASSERT_EQ(1, file_util::WriteFile(session_only_database_path, ".", 1)); - ASSERT_EQ(1, file_util::WriteFile(permanent_database_path, ".", 1)); + ASSERT_EQ(1, file_util::WriteFile(session_only_database_path, ".", 1)); + ASSERT_EQ(1, file_util::WriteFile(permanent_database_path, ".", 1)); - // Inject MockSpecialStoragePolicy into DOMStorageContext. - profile.GetWebKitContext()->dom_storage_context()->special_storage_policy_ = - special_storage_policy; + // Inject MockSpecialStoragePolicy into DOMStorageContext. + profile.GetWebKitContext()->dom_storage_context()->special_storage_policy_ = + special_storage_policy; - // Tell the WebKitContext explicitly do clean up the session-only - // data. TestingProfile (unlike ProfileImpl) doesn't do it automatically when - // destructed. The deletion is done immediately since we're on the WEBKIT - // thread (created by the test). - profile.GetWebKitContext()->DeleteSessionOnlyData(); + // Tell the WebKitContext explicitly do clean up the session-only + // data. TestingProfile (unlike ProfileImpl) doesn't do it automatically + // when destructed. The deletion is done immediately since we're on the + // WEBKIT thread (created by the test). + profile.GetWebKitContext()->DeleteSessionOnlyData(); - // Expected result: the database file for the permanent storage remains but - // the database for the session only storage was deleted. - EXPECT_FALSE(file_util::PathExists(session_only_database_path)); - EXPECT_TRUE(file_util::PathExists(permanent_database_path)); + // Expected result: the database file for the permanent storage remains but + // the database for the session only storage was deleted. + EXPECT_FALSE(file_util::PathExists(session_only_database_path)); + EXPECT_TRUE(file_util::PathExists(permanent_database_path)); + } + // Run the message loop to ensure that DOMStorageContext gets destroyed. + message_loop_.RunAllPending(); } |