diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-09 02:24:18 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-09 02:24:18 +0000 |
commit | d36cba48e5d038505c0ad48ef54d734792312a91 (patch) | |
tree | cf455e4e336403703e48d67dd4ec4ad0aefbd093 /net/base/cookie_monster_unittest.cc | |
parent | 575fdd3b09c42c0a25fe2a7c3e7b6b94dd78e95a (diff) | |
download | chromium_src-d36cba48e5d038505c0ad48ef54d734792312a91.zip chromium_src-d36cba48e5d038505c0ad48ef54d734792312a91.tar.gz chromium_src-d36cba48e5d038505c0ad48ef54d734792312a91.tar.bz2 |
Revert 100316 - Fix a memory leak in a unit test.
In the DeferredDeleteCanonicalCookie test, we were using an existing helper method that initialized a CanonicalCookie on the heap and put a pointer to it in a list. This makes sense for other tests because they provide that list to the CookieMonster, which takes ownership of the list.
In this case, we only needed one cookie, which we pass by reference to the CookieMonster via a method that does not take ownership. Yet, it's enough of a hassle to create the cookie that I used this method.
The result is that no-one deletes the cookie from the heap.
I extracted the existing code that prepared the cookie, so that one can create either a single cookie or a list of them.
BUG=68657
TEST=net_unittests / DeferredDeleteCanonicalCookie
Review URL: http://codereview.chromium.org/7831056
TBR=erikwright@chromium.org
Review URL: http://codereview.chromium.org/7857023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster_unittest.cc')
-rw-r--r-- | net/base/cookie_monster_unittest.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc index a08280a..67f3396 100644 --- a/net/base/cookie_monster_unittest.cc +++ b/net/base/cookie_monster_unittest.cc @@ -1294,19 +1294,18 @@ TEST_F(DeferredCookieTaskTest, DeferredDeleteAllForHostCookies) { TEST_F(DeferredCookieTaskTest, DeferredDeleteCanonicalCookie) { std::vector<CookieMonster::CanonicalCookie*> cookies; - scoped_ptr<CookieMonster::CanonicalCookie> cookie(BuildCanonicalCookie( - "www.google.com", "X=1; path=/", base::Time::Now())); + AddCookieToList("www.google.com", "X=1; path=/", base::Time::Now(), &cookies); MockDeleteCookieCallback delete_cookie_callback; BeginWith(DeleteCanonicalCookieAction( - &cookie_monster(), *cookie, &delete_cookie_callback)); + &cookie_monster(), *cookies[0], &delete_cookie_callback)); WaitForLoadCall(); EXPECT_CALL(delete_cookie_callback, Invoke(false)).WillOnce( DeleteCanonicalCookieAction( - &cookie_monster(), *cookie, &delete_cookie_callback)); + &cookie_monster(), *cookies[0], &delete_cookie_callback)); EXPECT_CALL(delete_cookie_callback, Invoke(false)).WillOnce( QuitCurrentMessageLoop()); |