diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 23:45:53 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 23:45:53 +0000 |
commit | c890ed198b2ac1f48bac0f61085644459be65706 (patch) | |
tree | e7b79be00cedaa880c7c83deae9a4b7033adeae3 /net/base/cookie_monster.h | |
parent | 410886f60fe9e48f312f3f6eeb349d52d9e03d72 (diff) | |
download | chromium_src-c890ed198b2ac1f48bac0f61085644459be65706.zip chromium_src-c890ed198b2ac1f48bac0f61085644459be65706.tar.gz chromium_src-c890ed198b2ac1f48bac0f61085644459be65706.tar.bz2 |
Implement a TODO (purge expired cookies in GetAllCookies()) and some small style fixes (function arguments on one line, remove braces on some single-line loop bodies). Remove some code to count how many cookies we garbage collected, since we never do anything with those numbers. Remove some TODOs that we shouldn't do (per deanm).
This is a by-product of my in-progress cookie fixes.
Review URL: http://codereview.chromium.org/8683
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster.h')
-rw-r--r-- | net/base/cookie_monster.h | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h index 11491ff..6db774a 100644 --- a/net/base/cookie_monster.h +++ b/net/base/cookie_monster.h @@ -142,8 +142,8 @@ class CookieMonster { const base::Time& current, std::vector<CanonicalCookie*>* cookies); - int DeleteEquivalentCookies(const std::string& key, - const CanonicalCookie& ecc); + void DeleteAnyEquivalentCookie(const std::string& key, + const CanonicalCookie& ecc); void InternalInsertCookie(const std::string& key, CanonicalCookie* cc, @@ -151,13 +151,33 @@ class CookieMonster { void InternalDeleteCookie(CookieMap::iterator it, bool sync_to_store); - // Enforce cookie maximum limits, purging expired and old cookies if needed + // If the number of cookies for host |key|, or globally, are over preset + // maximums, garbage collects, first for the host and then globally, as + // described by GarbageCollectRange(). The limits can be found as constants + // at the top of the function body. + // + // Returns the number of cookies deleted (useful for debugging). int GarbageCollect(const base::Time& current, const std::string& key); + + // Deletes all expired cookies in |itpair|; + // then, if the number of remaining cookies is greater than |num_max|, + // collects the oldest cookies until (|num_max| - |num_purge|) cookies remain. + // + // Returns the number of cookies deleted. int GarbageCollectRange(const base::Time& current, const CookieMapItPair& itpair, size_t num_max, size_t num_purge); + // Helper for GarbageCollectRange(); can be called directly as well. Deletes + // all expired cookies in |itpair|. If |cookie_its| is non-NULL, it is + // populated with all the non-expired cookies from |itpair|. + // + // Returns the number of cookies deleted. + int GarbageCollectExpired(const base::Time& current, + const CookieMapItPair& itpair, + std::vector<CookieMap::iterator>* cookie_its); + CookieMap cookies_; // Indicates whether the cookie store has been initialized. This happens @@ -235,10 +255,14 @@ class CookieMonster::ParsedCookie { class CookieMonster::CanonicalCookie { public: - CanonicalCookie(const std::string& name, const std::string& value, - const std::string& path, bool secure, - bool httponly, const base::Time& creation, - bool has_expires, const base::Time& expires) + CanonicalCookie(const std::string& name, + const std::string& value, + const std::string& path, + bool secure, + bool httponly, + const base::Time& creation, + bool has_expires, + const base::Time& expires) : name_(name), value_(value), path_(path), |