Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1334)

Unified Diff: net/base/cookie_monster.cc

Issue 2857029: Fix bug in DeleteAllForURL; deletes entire store instead of just (Closed)
Patch Set: Incorporated comments from eroman and mnissler. Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cookie_monster.cc
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index f6d3a54afc908ae55936745c80b773c18afc491d..86d71b841679d4dc89d803c7cd059e3e641f6460 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -901,17 +901,24 @@ int CookieMonster::DeleteAllCreatedAfter(const Time& delete_begin,
return DeleteAllCreatedBetween(delete_begin, Time(), sync_to_store);
}
-int CookieMonster::DeleteAllForURL(const GURL& url,
- bool sync_to_store) {
+int CookieMonster::DeleteAllForHost(const GURL& url) {
AutoLock autolock(lock_);
InitIfNecessary();
- CookieList cookies = InternalGetAllCookiesForURL(url);
+ if (!HasCookieableScheme(url))
+ return 0;
+
+ // We store host cookies in the store by their canonical host name;
+ // domain cookies are stored with a leading ".". So this is a pretty
+ // simple lookup and per-cookie delete.
int num_deleted = 0;
- for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) {
- CookieMap::iterator curit = it;
- ++it;
- InternalDeleteCookie(curit, sync_to_store, kDeleteCookieExplicit);
+ for (CookieMapItPair its = cookies_.equal_range(url.host());
+ its.first != its.second;) {
+ CookieMap::iterator curit = its.first;
+ ++its.first;
+ num_deleted++;
+
+ InternalDeleteCookie(curit, true, kDeleteCookieExplicit);
}
return num_deleted;
}
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698