diff options
author | rdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 16:41:04 +0000 |
---|---|---|
committer | rdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 16:41:04 +0000 |
commit | b866a02d3444bcc56199533fa264827ed73601cd (patch) | |
tree | 566b90b57d410207d4701b6d02165b2e3132c54d /net/base/cookie_monster.h | |
parent | 1bcb12b22d6ba77966c4c5b65e9db55ed1916344 (diff) | |
download | chromium_src-b866a02d3444bcc56199533fa264827ed73601cd.zip chromium_src-b866a02d3444bcc56199533fa264827ed73601cd.tar.gz chromium_src-b866a02d3444bcc56199533fa264827ed73601cd.tar.bz2 |
Fixes targeting the unique creation times invariant in the CookieMonster:
* Make sure we don't import cookies with identical creation times.
* DCHECK that duplicate cookie list insertion succeeds (it
silently didn't when there were not unique creation times.)
* Confirm that we eliminate all the duplicats we find on cookie
import.
* Make Methods allowing setting of creation time private.
* Create performance test for import (involved refactoring
backing store mock.)
This change does increase the performance cost on import, and hence adds
to startup time. However, the increase for importing 15000 cookies was only
5 ms, so I think that's acceptable to prevent crashes.
rdsmith-macbookpro:~/tmp $ perfparse base_perf_import.txt new_perf_import.txt
base_perf_import.txt new_perf_import.txt
CookieMonsterTest.TestImport
Cookie_monster_import_from_store 26.36 +/- 0.88 31.38 +/- 1.1
BUG=43188
TEST=net_unittest --gtest_filter=CookieMonsterTest.* (including two new tests.), Linux & Windows
Review URL: http://codereview.chromium.org/3070001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster.h')
-rw-r--r-- | net/base/cookie_monster.h | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h index 544192f..ab479c4 100644 --- a/net/base/cookie_monster.h +++ b/net/base/cookie_monster.h @@ -20,6 +20,7 @@ #include "base/scoped_ptr.h" #include "base/time.h" #include "net/base/cookie_store.h" +#include "testing/gtest/include/gtest/gtest_prod.h" class GURL; @@ -107,18 +108,6 @@ class CookieMonster : public CookieStore { const base::Time& expiration_time, bool secure, bool http_only); - // Exposed for unit testing. - bool SetCookieWithCreationTimeAndOptions(const GURL& url, - const std::string& cookie_line, - const base::Time& creation_time, - const CookieOptions& options); - bool SetCookieWithCreationTime(const GURL& url, - const std::string& cookie_line, - const base::Time& creation_time) { - return SetCookieWithCreationTimeAndOptions(url, cookie_line, creation_time, - CookieOptions()); - } - // Returns all the cookies, for use in management UI, etc. This does not mark // the cookies as having been accessed. CookieList GetAllCookies(); @@ -167,6 +156,14 @@ class CookieMonster : public CookieStore { private: ~CookieMonster(); + // Testing support. + friend class CookieMonsterTest; + FRIEND_TEST(CookieMonsterTest, TestCookieDeleteAllCreatedAfterTimestamp); + FRIEND_TEST(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps); + bool SetCookieWithCreationTime(const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time); + // Called by all non-static functions to ensure that the cookies store has // been initialized. This is not done during creating so it doesn't block // the window showing. @@ -220,6 +217,15 @@ class CookieMonster : public CookieStore { CanonicalCookie* cc, bool sync_to_store); + // Helper function that sets cookies with more control. + // Not exposed as we don't want callers to have the ability + // to specify (potentially duplicate) creation times. + bool SetCookieWithCreationTimeAndOptions(const GURL& url, + const std::string& cookie_line, + const base::Time& creation_time, + const CookieOptions& options); + + // Helper function that sets a canonical cookie, deleting equivalents and // performing garbage collection. bool SetCanonicalCookie(scoped_ptr<CanonicalCookie>* cc, |