summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 11:30:15 +0000
committermkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 11:30:15 +0000
commit9b464b9ca9cebbad516d537a742c2ea9c351a860 (patch)
tree89ed6c1451b2674d83d9802fd611b000b378426d /net
parent9e5154ebd5a3d9bb06cbc8306a4fd555385cb967 (diff)
downloadchromium_src-9b464b9ca9cebbad516d537a742c2ea9c351a860.zip
chromium_src-9b464b9ca9cebbad516d537a742c2ea9c351a860.tar.gz
chromium_src-9b464b9ca9cebbad516d537a742c2ea9c351a860.tar.bz2
Cleanup: Standardizing argument order for CanonicalCookie constructors.
Also took the opportunity to clarify the flow of CreateMonsterFromStoreForGC by dropping one of the `for` loops. BUG=79723 TEST=Compile, run tests, hope nothing breaks. Review URL: http://codereview.chromium.org/6882007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82095 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_monster.cc53
-rw-r--r--net/base/cookie_monster.h26
-rw-r--r--net/base/cookie_monster_store_test.cc28
3 files changed, 56 insertions, 51 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index 46d21b5..eeb129e 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -1215,11 +1215,10 @@ bool CookieMonster::SetCookieWithCreationTimeAndOptions(
scoped_ptr<CanonicalCookie> cc;
Time cookie_expires = CanonExpiration(pc, creation_time, options);
- cc.reset(new CanonicalCookie(url, pc.Name(),
- pc.Value(), cookie_domain, cookie_path,
- pc.IsSecure(), pc.IsHttpOnly(), creation_time,
- creation_time, !cookie_expires.is_null(),
- cookie_expires));
+ cc.reset(new CanonicalCookie(url, pc.Name(), pc.Value(), cookie_domain,
+ cookie_path, creation_time, cookie_expires,
+ creation_time, pc.IsSecure(), pc.IsHttpOnly(),
+ !cookie_expires.is_null()));
if (!cc.get()) {
VLOG(kVlogSetCookies) << "WARNING: Failed to allocate CanonicalCookie";
@@ -1910,9 +1909,9 @@ void CookieMonster::ParsedCookie::SetupAttributes() {
}
CookieMonster::CanonicalCookie::CanonicalCookie()
- : has_expires_(false),
- secure_(false),
- httponly_(false) {
+ : secure_(false),
+ httponly_(false),
+ has_expires_(false) {
}
CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
@@ -1920,23 +1919,23 @@ CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
const std::string& value,
const std::string& domain,
const std::string& path,
- bool secure,
- bool httponly,
const base::Time& creation,
+ const base::Time& expiration,
const base::Time& last_access,
- bool has_expires,
- const base::Time& expires)
+ bool secure,
+ bool httponly,
+ bool has_expires)
: source_(GetCookieSourceFromURL(url)),
name_(name),
value_(value),
domain_(domain),
path_(path),
creation_date_(creation),
+ expiry_date_(expiration),
last_access_date_(last_access),
- expiry_date_(expires),
- has_expires_(has_expires),
secure_(secure),
- httponly_(httponly) {
+ httponly_(httponly),
+ has_expires_(has_expires) {
}
CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
@@ -1947,9 +1946,9 @@ CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
path_(CanonPath(url, pc)),
creation_date_(Time::Now()),
last_access_date_(Time()),
- has_expires_(pc.HasExpires()),
secure_(pc.IsSecure()),
- httponly_(pc.IsHttpOnly()) {
+ httponly_(pc.IsHttpOnly()),
+ has_expires_(pc.HasExpires()) {
if (has_expires_)
expiry_date_ = CanonExpiration(pc, creation_date_, CookieOptions());
@@ -1984,10 +1983,15 @@ std::string CookieMonster::CanonicalCookie::GetCookieSourceFromURL(
}
CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
- const GURL& url, const std::string& name, const std::string& value,
- const std::string& domain, const std::string& path,
- const base::Time& creation_time, const base::Time& expiration_time,
- bool secure, bool http_only) {
+ const GURL& url,
+ const std::string& name,
+ const std::string& value,
+ const std::string& domain,
+ const std::string& path,
+ const base::Time& creation,
+ const base::Time& expiration,
+ bool secure,
+ bool http_only) {
// Expect valid attribute tokens and values, as defined by the ParsedCookie
// logic, otherwise don't create the cookie.
std::string parsed_name = ParsedCookie::ParseTokenString(name);
@@ -2021,10 +2025,9 @@ CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
cookie_path = std::string(canon_path.data() + canon_path_component.begin,
canon_path_component.len);
- return new CanonicalCookie(url, parsed_name,
- parsed_value, cookie_domain, cookie_path, secure,
- http_only, creation_time, creation_time,
- !expiration_time.is_null(), expiration_time);
+ return new CanonicalCookie(url, parsed_name, parsed_value, cookie_domain,
+ cookie_path, creation, expiration, creation,
+ secure, http_only, !expiration.is_null());
}
bool CookieMonster::CanonicalCookie::IsOnPath(
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h
index 92cc4f8..e150e25 100644
--- a/net/base/cookie_monster.h
+++ b/net/base/cookie_monster.h
@@ -539,12 +539,12 @@ class CookieMonster::CanonicalCookie {
const std::string& value,
const std::string& domain,
const std::string& path,
- bool secure,
- bool httponly,
const base::Time& creation,
+ const base::Time& expiration,
const base::Time& last_access,
- bool has_expires,
- const base::Time& expires);
+ bool secure,
+ bool httponly,
+ bool has_expires);
// This constructor does canonicalization but not validation.
// The result of this constructor should not be relied on in contexts
@@ -558,11 +558,15 @@ class CookieMonster::CanonicalCookie {
// Creates a canonical cookie from unparsed attribute values.
// Canonicalizes and validates inputs. May return NULL if an attribute
// value is invalid.
- static CanonicalCookie* Create(
- const GURL& url, const std::string& name, const std::string& value,
- const std::string& domain, const std::string& path,
- const base::Time& creation_time, const base::Time& expiration_time,
- bool secure, bool http_only);
+ static CanonicalCookie* Create(const GURL& url,
+ const std::string& name,
+ const std::string& value,
+ const std::string& domain,
+ const std::string& path,
+ const base::Time& creation,
+ const base::Time& expiration,
+ bool secure,
+ bool http_only);
const std::string& Source() const { return source_; }
const std::string& Name() const { return name_; }
@@ -626,11 +630,11 @@ class CookieMonster::CanonicalCookie {
std::string domain_;
std::string path_;
base::Time creation_date_;
- base::Time last_access_date_;
base::Time expiry_date_;
- bool has_expires_;
+ base::Time last_access_date_;
bool secure_;
bool httponly_;
+ bool has_expires_;
};
class CookieMonster::Delegate
diff --git a/net/base/cookie_monster_store_test.cc b/net/base/cookie_monster_store_test.cc
index b975c28..3fcaa29 100644
--- a/net/base/cookie_monster_store_test.cc
+++ b/net/base/cookie_monster_store_test.cc
@@ -95,10 +95,9 @@ void AddCookieToList(
scoped_ptr<CookieMonster::CanonicalCookie> cookie(
new CookieMonster::CanonicalCookie(
GURL(), pc.Name(), pc.Value(), key, cookie_path,
+ creation_time, creation_time, cookie_expires,
pc.IsSecure(), pc.IsHttpOnly(),
- creation_time, creation_time,
- !cookie_expires.is_null(),
- cookie_expires));
+ !cookie_expires.is_null()));
out_list->push_back(cookie.release());
}
@@ -156,19 +155,18 @@ CookieMonster* CreateMonsterFromStoreForGC(
scoped_refptr<MockSimplePersistentCookieStore> store(
new MockSimplePersistentCookieStore);
// Must expire to be persistent
- for (int i = 0; i < num_old_cookies; i++) {
- CookieMonster::CanonicalCookie cc(
- GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", false,
- false, past_creation + base::TimeDelta::FromMicroseconds(i),
- current - base::TimeDelta::FromDays(days_old),
- true, current + base::TimeDelta::FromDays(30));
- store->AddCookie(cc);
- }
- for (int i = num_old_cookies; i < num_cookies; i++) {
+ for (int i = 0; i < num_cookies; i++) {
+ base::Time creation_time =
+ past_creation + base::TimeDelta::FromMicroseconds(i);
+ base::Time expiration_time = current + base::TimeDelta::FromDays(30);
+ base::Time last_access_time =
+ (i < num_old_cookies) ? current - base::TimeDelta::FromDays(days_old) :
+ current;
+
CookieMonster::CanonicalCookie cc(
- GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", false,
- false, past_creation + base::TimeDelta::FromMicroseconds(i), current,
- true, current + base::TimeDelta::FromDays(30));
+ GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path",
+ creation_time, expiration_time, last_access_time,
+ false, false, true);
store->AddCookie(cc);
}