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

Unified Diff: net/cookies/cookie_monster.cc

Issue 2974363002: Simplify CookieMonster::SetAllCookies{,Async}() implementation. (Closed)
Patch Set: Sync'd to p485987 Created 3 years, 5 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/cookies/cookie_monster.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_monster.cc
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index 2666d590ca1e9939a5ae1752276138f67b0d61d5..90fa716cd6315a0d91b89113737af55b35a1030b 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -1488,46 +1488,20 @@ void CookieMonster::SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc,
void CookieMonster::SetAllCookies(CookieList list,
SetCookiesCallback callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- CookieList positive_diff;
- CookieList negative_diff;
- CookieList old_cookies;
- old_cookies.reserve(cookies_.size());
- for (const auto& cookie : cookies_)
- old_cookies.push_back(*cookie.second.get());
-
- ComputeCookieDiff(&old_cookies, &list, &positive_diff, &negative_diff);
mmenke 2017/07/12 18:56:35 Is ComputeCookieDiff still used? I'd check it mys
Randy Smith (Not in Mondays) 2017/07/12 20:07:08 Used by test code in order to test it, which I thi
-
- for (const auto& cookie_to_delete : negative_diff) {
- for (CookieMapItPair its =
- cookies_.equal_range(GetKey(cookie_to_delete.Domain()));
- its.first != its.second; ++its.first) {
- // The creation date acts as the unique index...
- if (its.first->second->CreationDate() ==
- cookie_to_delete.CreationDate()) {
- // TODO(rdsmith): DELETE_COOKIE_CANONICAL is incorrect and should
- // be changed.
- InternalDeleteCookie(its.first, true, DELETE_COOKIE_CANONICAL);
- break;
- }
- }
- }
-
- if (positive_diff.size() == 0) {
- ConditionalCookieCallback(std::move(callback), true);
- return;
+ // Nuke the existing store.
+ for (auto prev_it = cookies_.begin(), next_it = prev_it;
+ next_it != cookies_.end(); prev_it = next_it) {
mmenke 2017/07/12 18:56:35 I think this can just be: while (!cookies_.empty(
Randy Smith (Not in Mondays) 2017/07/12 20:07:08 You're right, that's quite a bit nicer. Done.
+ ++next_it;
+ // TODO(rdsmith): The CANONICAL is a lie.
+ InternalDeleteCookie(prev_it, true, DELETE_COOKIE_CANONICAL);
}
+ // Set all passed in cookies.
for (const auto& cookie : list) {
const std::string key(GetKey(cookie.Domain()));
Time creation_time = cookie.CreationDate();
- bool already_expired = cookie.IsExpired(creation_time);
-
- bool result =
- DeleteAnyEquivalentCookie(key, cookie, true, false, already_expired);
- DCHECK(!result);
-
- if (already_expired)
+ if (cookie.IsExpired(creation_time))
continue;
if (cookie.IsPersistent()) {
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698