Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: net/base/cookie_monster_store_test.cc

Issue 7860039: Re-land http://codereview.chromium.org/7831056/ and http://codereview.chromium.org/7833042/ . (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/cookie_monster_store_test.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cookie_monster_store_test.cc
===================================================================
--- net/base/cookie_monster_store_test.cc (revision 100345)
+++ net/base/cookie_monster_store_test.cc (working copy)
@@ -25,11 +25,13 @@
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,7 +80,18 @@
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);
EXPECT_TRUE(pc.IsValid());
@@ -92,15 +105,12 @@
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() {}
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;
}
« no previous file with comments | « net/base/cookie_monster_store_test.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698