summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 17:30:16 +0000
committerrdsmith@google.com <rdsmith@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 17:30:16 +0000
commit70d2cf46df412888fd1f1fdb1535c2bc80cbf58c (patch)
tree8bc8df0742c149148624622125608f1fb2c821e7 /net
parentfc6b9756a51541f7c45e8edfa1ba23a3fd9d4af6 (diff)
downloadchromium_src-70d2cf46df412888fd1f1fdb1535c2bc80cbf58c.zip
chromium_src-70d2cf46df412888fd1f1fdb1535c2bc80cbf58c.tar.gz
chromium_src-70d2cf46df412888fd1f1fdb1535c2bc80cbf58c.tar.bz2
Fix poorly performancing implementation of MockSimplePersistentCookieStore
BUG=57686 TEST=net_unittests CookieMonsterTest.* on Linux, running original valgrind test and confirming that it completed. Review URL: http://codereview.chromium.org/3752004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_monster_store_test.h43
-rw-r--r--net/data/valgrind/net_unittests.gtest.txt3
2 files changed, 18 insertions, 28 deletions
diff --git a/net/base/cookie_monster_store_test.h b/net/base/cookie_monster_store_test.h
index c54e1c1..8a21930 100644
--- a/net/base/cookie_monster_store_test.h
+++ b/net/base/cookie_monster_store_test.h
@@ -149,51 +149,44 @@ static void AddCookieToList(
// Add/Update/Delete and regurgitate it when Load is called.
class MockSimplePersistentCookieStore
: public net::CookieMonster::PersistentCookieStore {
- public:
- typedef std::vector<net::CookieMonster::CanonicalCookie>
- CanonicalCookieVector;
+ private:
+ typedef std::map<int64, net::CookieMonster::CanonicalCookie>
+ CanonicalCookieMap;
+ public:
virtual bool Load(
std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies) {
- for (CanonicalCookieVector::const_iterator it = cookies_.begin();
+ for (CanonicalCookieMap::const_iterator it = cookies_.begin();
it != cookies_.end(); it++)
- out_cookies->push_back(new net::CookieMonster::CanonicalCookie(*it));
+ out_cookies->push_back(
+ new net::CookieMonster::CanonicalCookie(it->second));
return true;
}
virtual void AddCookie(
const net::CookieMonster::CanonicalCookie& cookie) {
- for (CanonicalCookieVector::const_iterator it = cookies_.begin();
- it != cookies_.end(); it++) {
- // Caller must assure creation dates unique.
- EXPECT_NE(cookie.CreationDate().ToInternalValue(),
- it->CreationDate().ToInternalValue());
- }
- cookies_.push_back(cookie); // Copies.
+ int64 creation_time = cookie.CreationDate().ToInternalValue();
+ EXPECT_TRUE(cookies_.find(creation_time) == cookies_.end());
+ cookies_[creation_time] = cookie;
}
virtual void UpdateCookieAccessTime(
const net::CookieMonster::CanonicalCookie& cookie) {
- for (CanonicalCookieVector::iterator it = cookies_.begin();
- it != cookies_.end(); it++) {
- if (it->CreationDate() == cookie.CreationDate())
- it->SetLastAccessDate(base::Time::Now());
- }
+ int64 creation_time = cookie.CreationDate().ToInternalValue();
+ ASSERT_TRUE(cookies_.find(creation_time) != cookies_.end());
+ cookies_[creation_time].SetLastAccessDate(base::Time::Now());
}
virtual void DeleteCookie(
const net::CookieMonster::CanonicalCookie& cookie) {
- for (CanonicalCookieVector::iterator it = cookies_.begin();
- it != cookies_.end(); it++) {
- if (it->CreationDate() == cookie.CreationDate()) {
- cookies_.erase(it);
- return;
- }
- }
+ int64 creation_time = cookie.CreationDate().ToInternalValue();
+ CanonicalCookieMap::iterator it = cookies_.find(creation_time);
+ ASSERT_TRUE(it != cookies_.end());
+ cookies_.erase(it);
}
private:
- std::vector<net::CookieMonster::CanonicalCookie> cookies_;
+ CanonicalCookieMap cookies_;
};
// Helper function for creating a CookieMonster backed by a
diff --git a/net/data/valgrind/net_unittests.gtest.txt b/net/data/valgrind/net_unittests.gtest.txt
index a75689b..0af617c 100644
--- a/net/data/valgrind/net_unittests.gtest.txt
+++ b/net/data/valgrind/net_unittests.gtest.txt
@@ -4,6 +4,3 @@ KeygenHandlerTest.*ConcurrencyTest
# Fails Valgrind with varying stack traces. http://crbug.com/43179
SpdyNetworkTransactionTest.PostWithEarlySynReply
-
-# Hangs (or takes forever under Valgrind). http://crbug.com/57686
-CookieMonsterTest.GarbageCollectionTriggers