summaryrefslogtreecommitdiffstats
path: root/net/base/cookie_monster_store_test.cc
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 17:38:38 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 17:38:38 +0000
commit218aa6a199672545356f7fd49c7937b3272fdac6 (patch)
tree6cb100bbc31e79cae1708214b277f0ba97afa7d2 /net/base/cookie_monster_store_test.cc
parent41eccabc09eca87bfedc1f8c7b70370ec1d3b8b5 (diff)
downloadchromium_src-218aa6a199672545356f7fd49c7937b3272fdac6.zip
chromium_src-218aa6a199672545356f7fd49c7937b3272fdac6.tar.gz
chromium_src-218aa6a199672545356f7fd49c7937b3272fdac6.tar.bz2
Third try at committing this.
Patchset 1 is the original patch ( http://codereview.chromium.org/7833042/ ). Patchset 2 is the original patch plus a fix to a memory leak from the initial commit ( http://codereview.chromium.org/7831056/ ) On the first try there was a memory leak in a test. I fixed that, but made a mistake in the commit (the committed code did not correspond to the reviewed code). Both commits were reverted. I then landed a new CL ( http://codereview.chromium.org/7860039/ ) that contained the correct changes combining the first two CLs. This caused an error in heapchecker for which a suppression has subsequently been defined ( http://codereview.chromium.org/7780010 ). In summary, all of this is reviewed, minus some lint fixes. BUG=68657 TEST=net_unittests / DeferredCookieTaskTest.* and CookieMonsterTest.* TBR=estade Review URL: http://codereview.chromium.org/7891008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster_store_test.cc')
-rw-r--r--net/base/cookie_monster_store_test.cc42
1 files changed, 27 insertions, 15 deletions
diff --git a/net/base/cookie_monster_store_test.cc b/net/base/cookie_monster_store_test.cc
index b3a6c13..f8257c3 100644
--- a/net/base/cookie_monster_store_test.cc
+++ b/net/base/cookie_monster_store_test.cc
@@ -25,11 +25,13 @@ void MockPersistentCookieStore::SetLoadExpectation(
load_result_ = result;
}
-bool MockPersistentCookieStore::Load(
- std::vector<CookieMonster::CanonicalCookie*>* out_cookies) {
+bool MockPersistentCookieStore::Load(const LoadedCallback& loaded_callback) {
bool ok = load_return_value_;
- if (ok)
- *out_cookies = load_result_;
+ std::vector<CookieMonster::CanonicalCookie*> out_cookies;
+ if (ok) {
+ out_cookies = load_result_;
+ }
+ loaded_callback.Run(out_cookies);
return ok;
}
@@ -78,6 +80,17 @@ void AddCookieToList(
const std::string& cookie_line,
const base::Time& creation_time,
std::vector<CookieMonster::CanonicalCookie*>* out_list) {
+ scoped_ptr<CookieMonster::CanonicalCookie> cookie(
+ new CookieMonster::CanonicalCookie(
+ BuildCanonicalCookie(key, cookie_line, creation_time)));
+
+ out_list->push_back(cookie.release());
+}
+
+CookieMonster::CanonicalCookie BuildCanonicalCookie(
+ const std::string& key,
+ const std::string& cookie_line,
+ const base::Time& creation_time) {
// Parse the cookie line.
CookieMonster::ParsedCookie pc(cookie_line);
@@ -92,15 +105,12 @@ void AddCookieToList(
CookieMonster::ParseCookieTime(pc.Expires()) : base::Time();
std::string cookie_path = pc.Path();
- scoped_ptr<CookieMonster::CanonicalCookie> cookie(
- new CookieMonster::CanonicalCookie(
- GURL(), pc.Name(), pc.Value(), key, cookie_path,
- pc.MACKey(), pc.MACAlgorithm(),
- creation_time, creation_time, cookie_expires,
- pc.IsSecure(), pc.IsHttpOnly(),
- !cookie_expires.is_null()));
-
- out_list->push_back(cookie.release());
+ return CookieMonster::CanonicalCookie(
+ GURL(), pc.Name(), pc.Value(), key, cookie_path,
+ pc.MACKey(), pc.MACAlgorithm(),
+ creation_time, creation_time, cookie_expires,
+ pc.IsSecure(), pc.IsHttpOnly(),
+ !cookie_expires.is_null());
}
MockSimplePersistentCookieStore::MockSimplePersistentCookieStore() {}
@@ -108,11 +118,13 @@ MockSimplePersistentCookieStore::MockSimplePersistentCookieStore() {}
MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() {}
bool MockSimplePersistentCookieStore::Load(
- std::vector<CookieMonster::CanonicalCookie*>* out_cookies) {
+ const LoadedCallback& loaded_callback) {
+ std::vector<CookieMonster::CanonicalCookie*> out_cookies;
for (CanonicalCookieMap::const_iterator it = cookies_.begin();
it != cookies_.end(); it++)
- out_cookies->push_back(
+ out_cookies.push_back(
new CookieMonster::CanonicalCookie(it->second));
+ loaded_callback.Run(out_cookies);
return true;
}