summaryrefslogtreecommitdiffstats
path: root/net/base/cookie_monster.cc
diff options
context:
space:
mode:
authorrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 17:16:37 +0000
committerrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 17:16:37 +0000
commitdcc6432defe5e686ee152926613e14cd0e07e175 (patch)
tree19cf0e577b0167fad903d80744ac1d6940a085b4 /net/base/cookie_monster.cc
parentbc4db526bda153375e72fe583ce32ed125e9b306 (diff)
downloadchromium_src-dcc6432defe5e686ee152926613e14cd0e07e175.zip
chromium_src-dcc6432defe5e686ee152926613e14cd0e07e175.tar.gz
chromium_src-dcc6432defe5e686ee152926613e14cd0e07e175.tar.bz2
More cleanup relating to the domain now being part of the CanonicalCookie:
* Simplify DeleteCookie(CanonicalCookie) API * Get rid of KeyedCanonicalCookie type; not needed. BUG=8850 TEST=Try bots, net_unittest --gtest_filter=CookieMonsterTest.* (refactor, so tests should all keep passing.) Review URL: http://codereview.chromium.org/3095002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster.cc')
-rw-r--r--net/base/cookie_monster.cc24
1 files changed, 11 insertions, 13 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index bd86772..029d841 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -180,7 +180,7 @@ void CookieMonster::InitStore() {
// Initialize the store and sync in any saved persistent cookies. We don't
// care if it's expired, insert it so it can be garbage collected, removed,
// and sync'd.
- std::vector<KeyedCanonicalCookie> cookies;
+ std::vector<CanonicalCookie*> cookies;
// Reserve space for the maximum amount of cookies a database should have.
// This prevents multiple vector growth / copies as we append cookies.
cookies.reserve(kNumCookiesTotal);
@@ -190,22 +190,22 @@ void CookieMonster::InitStore() {
// that way we don't have to worry about what sections of code are safe
// to call while it's in that state.
std::set<int64> creation_times;
- for (std::vector<KeyedCanonicalCookie>::const_iterator it = cookies.begin();
+ for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin();
it != cookies.end(); ++it) {
- int64 cookie_creation_time = it->second->CreationDate().ToInternalValue();
+ int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue();
if (creation_times.insert(cookie_creation_time).second) {
- InternalInsertCookie(it->first, it->second, false);
+ InternalInsertCookie((*it)->Domain(), *it, false);
} else {
LOG(ERROR) << StringPrintf("Found cookies with duplicate creation "
"times in backing store: "
"{name='%s', domain='%s', path='%s'}",
- it->second->Name().c_str(),
- it->first.c_str(),
- it->second->Path().c_str());
+ (*it)->Name().c_str(),
+ (*it)->Domain().c_str(),
+ (*it)->Path().c_str());
// We've been given ownership of the cookie and are throwing it
// away; reclaim the space.
- delete it->second;
+ delete (*it);
}
}
@@ -1031,17 +1031,15 @@ int CookieMonster::DeleteAllForHost(const GURL& url) {
return num_deleted;
}
-bool CookieMonster::DeleteCookie(const std::string& domain,
- const CanonicalCookie& cookie,
- bool sync_to_store) {
+bool CookieMonster::DeleteCanonicalCookie(const CanonicalCookie& cookie) {
AutoLock autolock(lock_);
InitIfNecessary();
- for (CookieMapItPair its = cookies_.equal_range(domain);
+ for (CookieMapItPair its = cookies_.equal_range(cookie.Domain());
its.first != its.second; ++its.first) {
// The creation date acts as our unique index...
if (its.first->second->CreationDate() == cookie.CreationDate()) {
- InternalDeleteCookie(its.first, sync_to_store, DELETE_COOKIE_EXPLICIT);
+ InternalDeleteCookie(its.first, true, DELETE_COOKIE_EXPLICIT);
return true;
}
}