diff options
author | rdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-18 17:34:28 +0000 |
---|---|---|
committer | rdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-18 17:34:28 +0000 |
commit | 9c2addffef686c093b78e50770efae3c199ea3ff (patch) | |
tree | 5b7bbe82a1c1aed66ea72411dc4d78fd42bb1a1f | |
parent | 70d2cf46df412888fd1f1fdb1535c2bc80cbf58c (diff) | |
download | chromium_src-9c2addffef686c093b78e50770efae3c199ea3ff.zip chromium_src-9c2addffef686c093b78e50770efae3c199ea3ff.tar.gz chromium_src-9c2addffef686c093b78e50770efae3c199ea3ff.tar.bz2 |
Don't rely on "access_time < Time::Now()" to indicate "all cookies".
The interface to CookieMonster::GarbageCollectDeleteList() was
signalling "delete all cookies in list" by specifying "delete all
cookies in list with last access time before Now()". This was failing
to work properly when the system clock wasn't updated frequently
enough (== flaky test) and is also vulnerable to changes in systems
clocks. That semantic is now explicitly signalled by a null time.
BUG=58197
TEST=net_unittests CookieMonsterTest.* on Win/Linux and CookieMonsterTest.TestHostGarbageCollection (flaky test) repeatedly on Windows.
Review URL: http://codereview.chromium.org/3780004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62943 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/cookie_monster.cc | 5 | ||||
-rw-r--r-- | net/base/cookie_monster.h | 3 | ||||
-rw-r--r-- | net/base/cookie_monster_unittest.cc | 9 |
3 files changed, 6 insertions, 11 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index 1e3b2d9..de00016 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -996,7 +996,8 @@ int CookieMonster::GarbageCollectDeleteList( int num_deleted = 0; for (std::vector<CookieMap::iterator>::iterator it = cookie_its.begin(); it != cookie_its.end(); it++) { - if ((*it)->second->LastAccessDate() < keep_accessed_after) { + if (keep_accessed_after.is_null() || + (*it)->second->LastAccessDate() < keep_accessed_after) { histogram_evicted_last_access_minutes_->Add( (current - (*it)->second->LastAccessDate()).InMinutes()); InternalDeleteCookie((*it), true, cause); @@ -1042,7 +1043,7 @@ int CookieMonster::GarbageCollect(const Time& current, num_deleted += GarbageCollectDeleteList( current, - Time::Now(), + Time(), DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE, cookie_its); } diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h index 2f18283..cdb508e 100644 --- a/net/base/cookie_monster.h +++ b/net/base/cookie_monster.h @@ -390,7 +390,8 @@ class CookieMonster : public CookieStore { // Helper for GarbageCollect(). Deletes all cookies in the list // that were accessed before |keep_accessed_after|, using DeletionCause - // |cause|. Returns the number of cookies deleted. + // |cause|. If |keep_accessed_after| is null, deletes all cookies in the + // list. Returns the number of cookies deleted. int GarbageCollectDeleteList(const base::Time& current, const base::Time& keep_accessed_after, DeletionCause cause, diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc index 747f4fc..f4cca57 100644 --- a/net/base/cookie_monster_unittest.cc +++ b/net/base/cookie_monster_unittest.cc @@ -1106,14 +1106,7 @@ static void TestHostGarbageCollectHelper( } } -// Flaky on Win only. http://crbug.com/58197 -#if defined(OS_WIN) -#define MAYBE_TestHostGarbageCollection FLAKY_TestHostGarbageCollection -#else -#define MAYBE_TestHostGarbageCollection TestHostGarbageCollection -#endif - -TEST(CookieMonsterTest, MAYBE_TestHostGarbageCollection) { +TEST(CookieMonsterTest, TestHostGarbageCollection) { TestHostGarbageCollectHelper( CookieMonster::kDomainMaxCookies, CookieMonster::kDomainPurgeCookies, CookieMonster::EKS_KEEP_RECENT_AND_PURGE_ETLDP1); |