diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-08-01 12:59:39 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-08-04 12:40:43 +0000 |
commit | 28b1110370900897ab652cb420c371fab8857ad4 (patch) | |
tree | 41b32127d23b0df4f2add2a27e12dc87bddb260e /chromium/net/cookies | |
parent | 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (diff) | |
download | qtwebengine-chromium-28b1110370900897ab652cb420c371fab8857ad4.tar.gz |
BASELINE: Update Chromium to 53.0.2785.41
Also adds a few extra files for extensions.
Change-Id: Iccdd55d98660903331cf8b7b29188da781830af4
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/net/cookies')
-rw-r--r-- | chromium/net/cookies/canonical_cookie.cc | 18 | ||||
-rw-r--r-- | chromium/net/cookies/canonical_cookie.h | 14 | ||||
-rw-r--r-- | chromium/net/cookies/canonical_cookie_unittest.cc | 134 | ||||
-rw-r--r-- | chromium/net/cookies/cookie_monster.cc | 143 | ||||
-rw-r--r-- | chromium/net/cookies/cookie_monster_perftest.cc | 7 | ||||
-rw-r--r-- | chromium/net/cookies/cookie_monster_store_test.cc | 11 | ||||
-rw-r--r-- | chromium/net/cookies/cookie_monster_unittest.cc | 206 | ||||
-rw-r--r-- | chromium/net/cookies/cookie_store.cc | 2 |
8 files changed, 283 insertions, 252 deletions
diff --git a/chromium/net/cookies/canonical_cookie.cc b/chromium/net/cookies/canonical_cookie.cc index 1572cc1e793..407c9ff20a4 100644 --- a/chromium/net/cookies/canonical_cookie.cc +++ b/chromium/net/cookies/canonical_cookie.cc @@ -310,6 +310,24 @@ std::unique_ptr<CanonicalCookie> CanonicalCookie::Create( expiration, creation, secure, http_only, same_site, priority)); } +// static +std::unique_ptr<CanonicalCookie> CanonicalCookie::Create( + const std::string& name, + const std::string& value, + const std::string& domain, + const std::string& path, + const base::Time& creation, + const base::Time& expiration, + const base::Time& last_access, + bool secure, + bool http_only, + CookieSameSite same_site, + CookiePriority priority) { + return base::WrapUnique(new CanonicalCookie( + GURL(), name, value, domain, path, creation, expiration, last_access, + secure, http_only, same_site, priority)); +} + bool CanonicalCookie::IsOnPath(const std::string& url_path) const { // A zero length would be unsafe for our trailing '/' checks, and diff --git a/chromium/net/cookies/canonical_cookie.h b/chromium/net/cookies/canonical_cookie.h index 254e1173574..00a2dd8d862 100644 --- a/chromium/net/cookies/canonical_cookie.h +++ b/chromium/net/cookies/canonical_cookie.h @@ -72,6 +72,20 @@ class NET_EXPORT CanonicalCookie { bool enforce_strict_secure, CookiePriority priority); + // Creates a canonical cookie from unparsed attribute values. + // It does not do any validation. + static std::unique_ptr<CanonicalCookie> Create(const std::string& name, + const std::string& value, + const std::string& domain, + const std::string& path, + const base::Time& creation, + const base::Time& expiration, + const base::Time& last_access, + bool secure, + bool http_only, + CookieSameSite same_site, + CookiePriority priority); + const GURL& Source() const { return source_; } const std::string& Name() const { return name_; } const std::string& Value() const { return value_; } diff --git a/chromium/net/cookies/canonical_cookie_unittest.cc b/chromium/net/cookies/canonical_cookie_unittest.cc index 9bdfc16fd5c..21902c0076e 100644 --- a/chromium/net/cookies/canonical_cookie_unittest.cc +++ b/chromium/net/cookies/canonical_cookie_unittest.cc @@ -179,86 +179,83 @@ TEST(CanonicalCookieTest, IsEquivalent) { std::string cookie_domain = ".www.example.com"; std::string cookie_path = "/"; base::Time creation_time = base::Time::Now(); - base::Time last_access_time = creation_time; base::Time expiration_time = creation_time + base::TimeDelta::FromDays(2); bool secure(false); bool httponly(false); CookieSameSite same_site(CookieSameSite::NO_RESTRICTION); // Test that a cookie is equivalent to itself. - std::unique_ptr<CanonicalCookie> cookie(new CanonicalCookie( + std::unique_ptr<CanonicalCookie> cookie(CanonicalCookie::Create( url, cookie_name, cookie_value, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, httponly, same_site, + expiration_time, secure, httponly, same_site, false, COOKIE_PRIORITY_MEDIUM)); EXPECT_TRUE(cookie->IsEquivalent(*cookie)); // Test that two identical cookies are equivalent. - std::unique_ptr<CanonicalCookie> other_cookie(new CanonicalCookie( + std::unique_ptr<CanonicalCookie> other_cookie(CanonicalCookie::Create( url, cookie_name, cookie_value, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, httponly, same_site, + expiration_time, secure, httponly, same_site, false, COOKIE_PRIORITY_MEDIUM)); EXPECT_TRUE(cookie->IsEquivalent(*other_cookie)); // Tests that use different variations of attribute values that // DON'T affect cookie equivalence. - other_cookie.reset( - new CanonicalCookie(url, cookie_name, "2", cookie_domain, cookie_path, - creation_time, expiration_time, last_access_time, - secure, httponly, same_site, COOKIE_PRIORITY_HIGH)); + other_cookie = + CanonicalCookie::Create(url, cookie_name, "2", cookie_domain, cookie_path, + creation_time, expiration_time, secure, httponly, + same_site, false, COOKIE_PRIORITY_HIGH); EXPECT_TRUE(cookie->IsEquivalent(*other_cookie)); base::Time other_creation_time = creation_time + base::TimeDelta::FromMinutes(2); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, "2", cookie_domain, cookie_path, other_creation_time, - expiration_time, last_access_time, secure, httponly, same_site, - COOKIE_PRIORITY_MEDIUM)); + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_TRUE(cookie->IsEquivalent(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_name, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, true, httponly, same_site, - COOKIE_PRIORITY_LOW)); + expiration_time, true, httponly, same_site, false, COOKIE_PRIORITY_LOW); EXPECT_TRUE(cookie->IsEquivalent(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_name, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, true, same_site, - COOKIE_PRIORITY_LOW)); + expiration_time, secure, true, same_site, false, COOKIE_PRIORITY_LOW); EXPECT_TRUE(cookie->IsEquivalent(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_name, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, httponly, - CookieSameSite::STRICT_MODE, COOKIE_PRIORITY_LOW)); + expiration_time, secure, httponly, CookieSameSite::STRICT_MODE, false, + COOKIE_PRIORITY_LOW); EXPECT_TRUE(cookie->IsEquivalent(*other_cookie)); // Tests that use different variations of attribute values that // DO affect cookie equivalence. - other_cookie.reset( - new CanonicalCookie(url, "B", cookie_value, cookie_domain, cookie_path, - creation_time, expiration_time, last_access_time, - secure, httponly, same_site, COOKIE_PRIORITY_MEDIUM)); + other_cookie = CanonicalCookie::Create( + url, "B", cookie_value, cookie_domain, cookie_path, creation_time, + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_FALSE(cookie->IsEquivalent(*other_cookie)); - other_cookie.reset(new CanonicalCookie( - url, cookie_name, cookie_value, "www.example.com", cookie_path, - creation_time, expiration_time, last_access_time, secure, httponly, - same_site, COOKIE_PRIORITY_MEDIUM)); + other_cookie = CanonicalCookie::Create( + url, cookie_name, cookie_value, std::string(), cookie_path, creation_time, + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_TRUE(cookie->IsDomainCookie()); EXPECT_FALSE(other_cookie->IsDomainCookie()); EXPECT_FALSE(cookie->IsEquivalent(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_value, ".example.com", cookie_path, - creation_time, expiration_time, last_access_time, secure, httponly, - same_site, COOKIE_PRIORITY_MEDIUM)); + creation_time, expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_FALSE(cookie->IsEquivalent(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_value, cookie_domain, "/test/0", creation_time, - expiration_time, last_access_time, secure, httponly, same_site, - COOKIE_PRIORITY_MEDIUM)); + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_FALSE(cookie->IsEquivalent(*other_cookie)); } @@ -269,23 +266,22 @@ TEST(CanonicalCookieTest, IsEquivalentForSecureCookieMatching) { std::string cookie_domain = ".www.example.com"; std::string cookie_path = "/"; base::Time creation_time = base::Time::Now(); - base::Time last_access_time = creation_time; base::Time expiration_time = creation_time + base::TimeDelta::FromDays(2); bool secure(false); bool httponly(false); CookieSameSite same_site(CookieSameSite::NO_RESTRICTION); // Test that a cookie is equivalent to itself. - std::unique_ptr<CanonicalCookie> cookie(new CanonicalCookie( + std::unique_ptr<CanonicalCookie> cookie(CanonicalCookie::Create( url, cookie_name, cookie_value, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, httponly, same_site, + expiration_time, secure, httponly, same_site, false, COOKIE_PRIORITY_MEDIUM)); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*cookie)); // Test that two identical cookies are equivalent. - std::unique_ptr<CanonicalCookie> other_cookie(new CanonicalCookie( + std::unique_ptr<CanonicalCookie> other_cookie(CanonicalCookie::Create( url, cookie_name, cookie_value, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, httponly, same_site, + expiration_time, secure, httponly, same_site, false, COOKIE_PRIORITY_MEDIUM)); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); @@ -295,68 +291,66 @@ TEST(CanonicalCookieTest, IsEquivalentForSecureCookieMatching) { // * Should return true even if paths differ. // * Should return true if the domains "domain-match" (but are not // identical). - other_cookie.reset( - new CanonicalCookie(url, cookie_name, "2", cookie_domain, cookie_path, - creation_time, expiration_time, last_access_time, - secure, httponly, same_site, COOKIE_PRIORITY_HIGH)); + other_cookie = + CanonicalCookie::Create(url, cookie_name, "2", cookie_domain, cookie_path, + creation_time, expiration_time, secure, httponly, + same_site, false, COOKIE_PRIORITY_HIGH); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); base::Time other_creation_time = creation_time + base::TimeDelta::FromMinutes(2); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, "2", cookie_domain, cookie_path, other_creation_time, - expiration_time, last_access_time, secure, httponly, same_site, - COOKIE_PRIORITY_MEDIUM)); + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_name, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, true, httponly, same_site, - COOKIE_PRIORITY_LOW)); + expiration_time, true, httponly, same_site, false, COOKIE_PRIORITY_LOW); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_name, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, true, same_site, - COOKIE_PRIORITY_LOW)); + expiration_time, secure, true, same_site, false, COOKIE_PRIORITY_LOW); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_name, cookie_domain, cookie_path, creation_time, - expiration_time, last_access_time, secure, httponly, - CookieSameSite::STRICT_MODE, COOKIE_PRIORITY_LOW)); + expiration_time, secure, httponly, CookieSameSite::STRICT_MODE, false, + COOKIE_PRIORITY_LOW); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); // The following 3 tests' expected results differ from their IsEquivalent // counterparts above. - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_value, cookie_domain, "/test/0", creation_time, - expiration_time, last_access_time, secure, httponly, same_site, - COOKIE_PRIORITY_MEDIUM)); + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); - other_cookie.reset(new CanonicalCookie( - url, cookie_name, cookie_value, "www.example.com", cookie_path, - creation_time, expiration_time, last_access_time, secure, httponly, - same_site, COOKIE_PRIORITY_MEDIUM)); + other_cookie = CanonicalCookie::Create( + url, cookie_name, cookie_value, std::string(), cookie_path, creation_time, + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_TRUE(cookie->IsDomainCookie()); EXPECT_FALSE(other_cookie->IsDomainCookie()); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); - other_cookie.reset(new CanonicalCookie( + other_cookie = CanonicalCookie::Create( url, cookie_name, cookie_value, ".example.com", cookie_path, - creation_time, expiration_time, last_access_time, secure, httponly, - same_site, COOKIE_PRIORITY_MEDIUM)); + creation_time, expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_TRUE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); // Tests that use different variations of attribute values that // DO affect cookie equivalence. Note that unlike the IsEquivalent tests // above, this does *not* include tests for differing paths or domains that // "domain-match". - other_cookie.reset( - new CanonicalCookie(url, "B", cookie_value, cookie_domain, cookie_path, - creation_time, expiration_time, last_access_time, - secure, httponly, same_site, COOKIE_PRIORITY_MEDIUM)); + other_cookie = CanonicalCookie::Create( + url, "B", cookie_value, cookie_domain, cookie_path, creation_time, + expiration_time, secure, httponly, same_site, false, + COOKIE_PRIORITY_MEDIUM); EXPECT_FALSE(cookie->IsEquivalentForSecureCookieMatching(*other_cookie)); } diff --git a/chromium/net/cookies/cookie_monster.cc b/chromium/net/cookies/cookie_monster.cc index 3d7124d502e..684a9653a1c 100644 --- a/chromium/net/cookies/cookie_monster.cc +++ b/chromium/net/cookies/cookie_monster.cc @@ -309,53 +309,27 @@ void RunAsync(scoped_refptr<base::TaskRunner> proxy, proxy->PostTask(FROM_HERE, base::Bind(callback, cookie, removed)); } -size_t CountProtectedSecureCookiesAtPriority( - CookiePriority priority, - CookieMonster::CookieItVector* cookies) { - size_t num_protected_secure_cookies = 0; - for (const auto& cookie : *cookies) { - if (!cookie->second->IsSecure()) - continue; - // 1) At low-priority, only low-priority secure cookies are protected as - // part of the quota. - // 2) At medium-priority, only medium-priority secure cookies are protected - // as part of the quota (low-priority secure cookies may be deleted). - // 3) At high-priority, medium-priority and high-priority secure cookies are - // protected as part of the quota (low-priority secure cookies may be - // deleted). - CookiePriority cookie_priority = cookie->second->Priority(); - switch (cookie_priority) { - case COOKIE_PRIORITY_LOW: - if (priority == COOKIE_PRIORITY_LOW) - num_protected_secure_cookies++; - break; - case COOKIE_PRIORITY_MEDIUM: - case COOKIE_PRIORITY_HIGH: - if (cookie_priority <= priority) - num_protected_secure_cookies++; - break; - } - } - - return num_protected_secure_cookies; -} - bool IsCookieEligibleForEviction(CookiePriority current_priority_level, bool protect_secure_cookies, const CanonicalCookie* cookie) { - if (!cookie->IsSecure() || !protect_secure_cookies) - return cookie->Priority() <= current_priority_level; - - // Special consideration has to be given for low-priority secure cookies since - // they are given lower prority than non-secure medium-priority and non-secure - // high-priority cookies. Thus, low-priority secure cookies may be evicted at - // a medium and high value of |current_priority_level|. Put another way, - // low-priority secure cookies are only protected when the current priority - // level is low. - if (current_priority_level == COOKIE_PRIORITY_LOW) - return false; + if (cookie->Priority() == current_priority_level && protect_secure_cookies) + return !cookie->IsSecure(); + + return cookie->Priority() == current_priority_level; +} - return cookie->Priority() == COOKIE_PRIORITY_LOW; +size_t CountCookiesForPossibleDeletion( + CookiePriority priority, + const CookieMonster::CookieItVector* cookies, + bool protect_secure_cookies) { + size_t cookies_count = 0U; + for (const auto& cookie : *cookies) { + if (cookie->second->Priority() == priority) { + if (!protect_secure_cookies || cookie->second->IsSecure()) + cookies_count++; + } + } + return cookies_count; } } // namespace @@ -1249,7 +1223,7 @@ void CookieMonster::DeleteCookie(const GURL& url, FindCookiesForHostAndDomain(url, options, &cookies); std::set<CanonicalCookie*> matching_cookies; - for (const auto& cookie : cookies) { + for (auto* cookie : cookies) { if (cookie->Name() != cookie_name) continue; if (!cookie->IsOnPath(url.path())) @@ -1928,10 +1902,6 @@ size_t CookieMonster::GarbageCollect(const Time& current, // Sort the cookies by access date, from least-recent to most-recent. std::sort(cookie_its->begin(), cookie_its->end(), LRACookieSorter); - size_t additional_quota_low = kDomainCookiesQuotaLow; - size_t additional_quota_medium = kDomainCookiesQuotaMedium; - size_t additional_quota_high = kDomainCookiesQuotaHigh; - // Remove all but the kDomainCookiesQuotaLow most-recently accessed // cookies with low-priority. Then, if cookies still need to be removed, // bump the quota and remove low- and medium-priority. Then, if cookies @@ -1969,26 +1939,24 @@ size_t CookieMonster::GarbageCollect(const Time& current, if (!enforce_strict_secure && purge_round.protect_secure_cookies) continue; - // Only adjust the quota if the round is executing, otherwise it is - // necesary to delay quota adjustments until a later round. This is - // because if the high priority, non-secure round is skipped, its quota - // should not count until the later high priority, full round later. - size_t* additional_quota = nullptr; + // Adjust quota according to the priority of cookies. Each round should + // protect certain number of cookies in order to avoid starvation. + // For example, when each round starts to remove cookies, the number of + // cookies of that priority are counted and a decision whether they + // should be deleted or not is made. If yes, some number of cookies of + // that priority are deleted considering the quota. switch (purge_round.priority) { case COOKIE_PRIORITY_LOW: - additional_quota = &additional_quota_low; + quota = kDomainCookiesQuotaLow; break; case COOKIE_PRIORITY_MEDIUM: - additional_quota = &additional_quota_medium; + quota = kDomainCookiesQuotaMedium; break; case COOKIE_PRIORITY_HIGH: - additional_quota = &additional_quota_high; + quota = kDomainCookiesQuotaHigh; break; } - quota += *additional_quota; - *additional_quota = 0u; size_t just_deleted = 0u; - // Purge up to |purge_goal| for all cookies at the given priority. This // path will always execute if strict secure cookies is disabled since // |purge_goal| must be positive because of the for-loop guard. If @@ -2058,45 +2026,44 @@ size_t CookieMonster::PurgeLeastRecentMatches(CookieItVector* cookies, bool protect_secure_cookies) { DCHECK(thread_checker_.CalledOnValidThread()); - // Find the first protected cookie by walking down from the end of the list - // cookie list (most-recently accessed) until |to_protect| cookies that match - // |priority| are found. - // - // If |protect_secure_cookies| is true, do a first pass that counts eligible - // secure cookies at the specified priority as protected. + // 1. Count number of the cookies at |priority| + size_t cookies_count_possibly_to_be_deleted = CountCookiesForPossibleDeletion( + priority, cookies, false /* count all cookies */); + + // 2. If |cookies_count_possibly_to_be_deleted| at |priority| is less than or + // equal |to_protect|, skip round in order to preserve the quota. This + // involves secure and non-secure cookies at |priority|. + if (cookies_count_possibly_to_be_deleted <= to_protect) + return 0u; + + // 3. Calculate number of secure cookies at |priority| + // and number of cookies at |priority| that can possibly be deleted. + // It is guaranteed we do not delete more than |purge_goal| even if + // |cookies_count_possibly_to_be_deleted| is higher. + size_t secure_cookies = 0u; if (protect_secure_cookies) { - to_protect -= std::min( - to_protect, CountProtectedSecureCookiesAtPriority(priority, cookies)); - } - - size_t protection_boundary = cookies->size(); - while (to_protect > 0 && protection_boundary > 0) { - protection_boundary--; - if (cookies->at(protection_boundary)->second->Priority() <= priority) - to_protect--; + secure_cookies = CountCookiesForPossibleDeletion( + priority, cookies, protect_secure_cookies /* count secure cookies */); + cookies_count_possibly_to_be_deleted -= + std::max(secure_cookies, to_protect - secure_cookies); + } else { + cookies_count_possibly_to_be_deleted -= to_protect; } - // Now, walk up from the beginning of the list (least-recently accessed) until - // |purge_goal| cookies are removed, or the iterator hits - // |protection_boundary|. - size_t removed = 0; - size_t current = 0; - while (removed < purge_goal && current < protection_boundary) { + size_t removed = 0u; + size_t current = 0u; + while ((removed < purge_goal && current < cookies->size()) && + cookies_count_possibly_to_be_deleted > 0) { const CanonicalCookie* current_cookie = cookies->at(current)->second; - // Only delete the current cookie if the priority is less than or equal to - // the current level. If it is equal to the current level, and secure - // cookies are protected, only delete it if it is not secure. + // Only delete the current cookie if the priority is equal to + // the current level. if (IsCookieEligibleForEviction(priority, protect_secure_cookies, current_cookie)) { InternalDeleteCookie(cookies->at(current), true, DELETE_COOKIE_EVICTED_DOMAIN); cookies->erase(cookies->begin() + current); removed++; - - // The call to 'erase' above shifts the contents of the vector, but - // doesn't shift |protection_boundary|. Decrement that here to ensure that - // the correct set of cookies is protected. - protection_boundary--; + cookies_count_possibly_to_be_deleted--; } else { current++; } diff --git a/chromium/net/cookies/cookie_monster_perftest.cc b/chromium/net/cookies/cookie_monster_perftest.cc index c56bef6783f..983f5ee2e54 100644 --- a/chromium/net/cookies/cookie_monster_perftest.cc +++ b/chromium/net/cookies/cookie_monster_perftest.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" +#include "base/run_loop.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/test/perf_time_logger.h" @@ -49,7 +50,7 @@ class BaseCallback { // Therefore, callbacks will actually always complete synchronously. If the // tests get more advanced we need to add other means of signaling // completion. - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(has_run_); has_run_ = false; } @@ -149,7 +150,7 @@ TEST_F(CookieMonsterTest, TestAddCookiesOnSingleHost) { base::PerfTimeLogger timer3("Cookie_monster_deleteall_single_host"); cm->DeleteAllAsync(CookieMonster::DeleteCallback()); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); timer3.Done(); } @@ -182,7 +183,7 @@ TEST_F(CookieMonsterTest, TestAddCookieOnManyHosts) { base::PerfTimeLogger timer3("Cookie_monster_deleteall_many_hosts"); cm->DeleteAllAsync(CookieMonster::DeleteCallback()); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); timer3.Done(); } diff --git a/chromium/net/cookies/cookie_monster_store_test.cc b/chromium/net/cookies/cookie_monster_store_test.cc index 9d825900029..5257356e089 100644 --- a/chromium/net/cookies/cookie_monster_store_test.cc +++ b/chromium/net/cookies/cookie_monster_store_test.cc @@ -252,11 +252,12 @@ std::unique_ptr<CookieMonster> CreateMonsterFromStoreForGC( ? current - base::TimeDelta::FromDays(days_old) : current; - CanonicalCookie cc(GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), - "/path", creation_time, expiration_time, - last_access_time, secure, false, - CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT); - store->AddCookie(cc); + std::unique_ptr<CanonicalCookie> cc(CanonicalCookie::Create( + GURL(base::StringPrintf("http://h%05d.izzle/", i)), "a", "1", + std::string(), "/path", creation_time, expiration_time, secure, false, + CookieSameSite::DEFAULT_MODE, false, COOKIE_PRIORITY_DEFAULT)); + cc->SetLastAccessDate(last_access_time); + store->AddCookie(*cc); } return base::WrapUnique(new CookieMonster(store.get(), nullptr)); diff --git a/chromium/net/cookies/cookie_monster_unittest.cc b/chromium/net/cookies/cookie_monster_unittest.cc index ab74c667f19..cd7ab02c868 100644 --- a/chromium/net/cookies/cookie_monster_unittest.cc +++ b/chromium/net/cookies/cookie_monster_unittest.cc @@ -13,9 +13,9 @@ #include "base/location.h" #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_samples.h" +#include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" @@ -565,15 +565,15 @@ class CookieMonsterTestBase : public CookieStoreTest<T> { TestPriorityCookieCase(cm.get(), "10HN 171MN", 0U, 140U, 10U, 150U, 0U); // Round 1 => 10L; round2 => 21M; round 3 => none. TestPriorityCookieCase(cm.get(), "141MN 40LN", 30U, 120U, 0U, 150U, 0U); - // Round 1 => none; round2 => none; round 3 => 31H. - TestPriorityCookieCase(cm.get(), "101HN 80MN", 0U, 80U, 70U, 150U, 0U); + // Round 1 => none; round2 => 30M; round 3 => 1H. + TestPriorityCookieCase(cm.get(), "101HN 80MN", 0U, 50U, 100U, 150U, 0U); // For {low, medium} priorities right on quota, different orders. - // Round 1 => 1L; round 2 => none, round3 => 30L. - TestPriorityCookieCase(cm.get(), "31LN 50MN 100HN", 0U, 50U, 100U, 150U, + // Round 1 => 1L; round 2 => none, round3 => 30H. + TestPriorityCookieCase(cm.get(), "31LN 50MN 100HN", 30U, 50U, 70U, 150U, 0U); - // Round 1 => none; round 2 => 1M, round3 => 30M. - TestPriorityCookieCase(cm.get(), "51MN 100HN 30LN", 30U, 20U, 100U, 150U, + // Round 1 => none; round 2 => 1M, round3 => 30H. + TestPriorityCookieCase(cm.get(), "51MN 100HN 30LN", 30U, 50U, 70U, 150U, 0U); // Round 1 => none; round 2 => none; round3 => 31H. TestPriorityCookieCase(cm.get(), "101HN 50MN 30LN", 30U, 50U, 70U, 150U, @@ -586,45 +586,21 @@ class CookieMonsterTestBase : public CookieStoreTest<T> { // Round 1 => 10L; round 2 => 10M; round 3 => 11H. TestPriorityCookieCase(cm.get(), "21HN 60MN 40LN 60HN", 30U, 50U, 70U, 150U, 0U); - // Round 1 => 10L; round 2 => 11M, 10L; round 3 => none. - TestPriorityCookieCase(cm.get(), "11HN 10MN 20LN 110MN 20LN 10HN", 20U, - 109U, 21U, 150U, 0U); - // Round 1 => none; round 2 => none; round 3 => 11L, 10M, 10H. - TestPriorityCookieCase(cm.get(), "11LN 10MN 140HN 10MN 10LN", 10U, 10U, - 130U, 150U, 0U); - // Round 1 => none; round 2 => 1M; round 3 => 10L, 10M, 10H. - TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 60MN 90HN", 0U, 60U, 90U, + // Round 1 => 10L; round 2 => 21M; round 3 => 0H. + TestPriorityCookieCase(cm.get(), "11HN 10MN 20LN 110MN 20LN 10HN", 30U, 99U, + 21U, 150U, 0U); + // Round 1 => none; round 2 => none; round 3 => 31H. + TestPriorityCookieCase(cm.get(), "11LN 10MN 140HN 10MN 10LN", 21U, 20U, + 109U, 150U, 0U); + // Round 1 => none; round 2 => 21M; round 3 => 10H. + TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 60MN 90HN", 10U, 50U, 90U, 150U, 0U); - // Round 1 => none; round 2 => 10L, 21M; round 3 => none. - TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 90MN 60HN", 0U, 80U, 70U, + // Round 1 => none; round 2 => 31M; round 3 => none. + TestPriorityCookieCase(cm.get(), "11MN 10HN 10LN 90MN 60HN", 10U, 70U, 70U, 150U, 0U); - // TODO(jww): According to - // https://tools.ietf.org/html/draft-west-cookie-priority#section-3, it - // seems that quotas are a mechanism for preventing another application on - // the same doman from DoS'ing an application by constantly evicting *all* - // lower priority cookies. - // - // Unfortunately, this has never strictly worked in our implementation. Take - // the following test as an example: - // TestPriorityCookieCase(cm.get(), "50LN 131HN", 30U, 0U, 120U, 150U, 0U); - // - // According to this theory, we would expect eviction to proceed as: - // Round 1 => 20L; round 2 => 0; round 3 => 11H - // thus resulting in 30L and 120H at the end. - // - // However, what happens in practice is that the cookies left are 19L and - // 131H. This is because the quotas are accumulated over the rounds and what - // priority they apply to is lost information. Since in the last round all - // that is known is a total quota, and the low-priority cookies are least - // recently accessed, they are evicted first to get down to 150 cookies. - // - // We should address this and uncomment the test below when it is fixed. - // - // See https://crbug.com/609550 - // // Round 1 => 20L; round 2 => 0; round 3 => 11H - // TestPriorityCookieCase(cm.get(), "50LN 131HN", 30U, 0U, 120U, 150U, 0U); + TestPriorityCookieCase(cm.get(), "50LN 131HN", 30U, 0U, 120U, 150U, 0U); // Round 1 => 20L; round 2 => 0; round 3 => 11H TestPriorityCookieCase(cm.get(), "131HN 50LN", 30U, 0U, 120U, 150U, 0U); // Round 1 => 20L; round 2 => none; round 3 => 11H. @@ -643,8 +619,11 @@ class CookieMonsterTestBase : public CookieStoreTest<T> { // Each test case adds 181 cookies, so 31 cookies are evicted. // Cookie same priority, repeated for each priority. + // Round 1 => 31L; round2 => none; round 3 => none. TestPriorityCookieCase(cm.get(), "181LS", 150U, 0U, 0U, 0U, 150U); + // Round 1 => none; round2 => 31M; round 3 => none. TestPriorityCookieCase(cm.get(), "181MS", 0U, 150U, 0U, 0U, 150U); + // Round 1 => none; round2 => none; round 3 => 31H. TestPriorityCookieCase(cm.get(), "181HS", 0U, 0U, 150U, 0U, 150U); // Pairwise scenarios. @@ -652,15 +631,15 @@ class CookieMonsterTestBase : public CookieStoreTest<T> { TestPriorityCookieCase(cm.get(), "10HS 171MS", 0U, 140U, 10U, 0U, 150U); // Round 1 => 10L; round2 => 21M; round 3 => none. TestPriorityCookieCase(cm.get(), "141MS 40LS", 30U, 120U, 0U, 0U, 150U); - // Round 1 => none; round2 => none; round 3 => 31H. - TestPriorityCookieCase(cm.get(), "101HS 80MS", 0U, 80U, 70U, 0U, 150U); + // Round 1 => none; round2 => 30M; round 3 => 1H. + TestPriorityCookieCase(cm.get(), "101HS 80MS", 0U, 50U, 100U, 0U, 150U); // For {low, medium} priorities right on quota, different orders. - // Round 1 => 1L; round 2 => none, round3 => 30L. - TestPriorityCookieCase(cm.get(), "31LS 50MS 100HS", 0U, 50U, 100U, 0U, + // Round 1 => 1L; round 2 => none, round3 => 30H. + TestPriorityCookieCase(cm.get(), "31LS 50MS 100HS", 30U, 50U, 70U, 0U, 150U); - // Round 1 => none; round 2 => 1M, round3 => 30M. - TestPriorityCookieCase(cm.get(), "51MS 100HS 30LS", 30U, 20U, 100U, 0U, + // Round 1 => none; round 2 => 1M, round3 => 30H. + TestPriorityCookieCase(cm.get(), "51MS 100HS 30LS", 30U, 50U, 70U, 0U, 150U); // Round 1 => none; round 2 => none; round3 => 31H. TestPriorityCookieCase(cm.get(), "101HS 50MS 30LS", 30U, 50U, 70U, 0U, @@ -673,17 +652,17 @@ class CookieMonsterTestBase : public CookieStoreTest<T> { // Round 1 => 10L; round 2 => 10M; round 3 => 11H. TestPriorityCookieCase(cm.get(), "21HS 60MS 40LS 60HS", 30U, 50U, 70U, 0U, 150U); - // Round 1 => 10L; round 2 => 11M, 10L; round 3 => none. - TestPriorityCookieCase(cm.get(), "11HS 10MS 20LS 110MS 20LS 10HS", 20U, - 109U, 21U, 0U, 150U); - // Round 1 => none; round 2 => none; round 3 => 11L, 10M, 10H. - TestPriorityCookieCase(cm.get(), "11LS 10MS 140HS 10MS 10LS", 10U, 10U, - 130U, 0U, 150U); - // Round 1 => none; round 2 => 1M; round 3 => 10L, 10M, 10H. - TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 60MS 90HS", 0U, 60U, 90U, + // Round 1 => 10L; round 2 => 21M; round 3 => none. + TestPriorityCookieCase(cm.get(), "11HS 10MS 20LS 110MS 20LS 10HS", 30U, 99U, + 21U, 0U, 150U); + // Round 1 => none; round 2 => none; round 3 => 31H. + TestPriorityCookieCase(cm.get(), "11LS 10MS 140HS 10MS 10LS", 21U, 20U, + 109U, 0U, 150U); + // Round 1 => none; round 2 => 21M; round 3 => 10H. + TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 60MS 90HS", 10U, 50U, 90U, 0U, 150U); - // Round 1 => none; round 2 => 10L, 21M; round 3 => none. - TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 90MS 60HS", 0U, 80U, 70U, + // Round 1 => none; round 2 => 31M; round 3 => none. + TestPriorityCookieCase(cm.get(), "11MS 10HS 10LS 90MS 60HS", 10U, 70U, 70U, 0U, 150U); } @@ -699,44 +678,101 @@ class CookieMonsterTestBase : public CookieStoreTest<T> { // secure cookies take priority, so the non-secure cookie is removed, along // with 30 secure cookies. Repeated for each priority, and with the // non-secure cookie as older and newer. + // Round 1 => 1LN; round 2 => 30LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "1LN 180LS", 150U, 0U, 0U, 0U, 150U); + // Round 1 => none; round 2 => none; round 3 => 1MN. + // Round 4 => none; round 5 => 30MS; round 6 => none. TestPriorityCookieCase(cm.get(), "1MN 180MS", 0U, 150U, 0U, 0U, 150U); + // Round 1 => none; round 2 => none; round 3 => none. + // Round 4 => 1HN; round 5 => none; round 6 => 30HS. TestPriorityCookieCase(cm.get(), "1HN 180HS", 0U, 0U, 150U, 0U, 150U); + // Round 1 => 1LN; round 2 => 30LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "180LS 1LN", 150U, 0U, 0U, 0U, 150U); + // Round 1 => none; round 2 => none; round 3 => 1MN. + // Round 4 => none; round 5 => 30MS; round 6 => none. TestPriorityCookieCase(cm.get(), "180MS 1MN", 0U, 150U, 0U, 0U, 150U); + // Round 1 => none; round 2 => none; round 3 => none. + // Round 4 => 1HN; round 5 => none; round 6 => 30HS. TestPriorityCookieCase(cm.get(), "180HS 1HN", 0U, 0U, 150U, 0U, 150U); // Low-priority secure cookies are removed before higher priority non-secure // cookies. + // Round 1 => none; round 2 => 31LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "180LS 1MN", 149U, 1U, 0U, 1U, 149U); + // Round 1 => none; round 2 => 31LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "180LS 1HN", 149U, 0U, 1U, 1U, 149U); + // Round 1 => none; round 2 => 31LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "1MN 180LS", 149U, 1U, 0U, 1U, 149U); + // Round 1 => none; round 2 => 31LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "1HN 180LS", 149U, 0U, 1U, 1U, 149U); // Higher-priority non-secure cookies are removed before any secure cookie - // with greater than low-priority. - TestPriorityCookieCase(cm.get(), "180MS 1HN", 0U, 150U, 0U, 0U, 150U); - TestPriorityCookieCase(cm.get(), "1HN 180MS", 0U, 150U, 0U, 0U, 150U); + // with greater than low-priority. Is it true? How about the quota? + // Round 1 => none; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => 31MS; round 6 => none. + TestPriorityCookieCase(cm.get(), "180MS 1HN", 0U, 149U, 1U, 1U, 149U); + // Round 1 => none; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => 31MS; round 6 => none. + TestPriorityCookieCase(cm.get(), "1HN 180MS", 0U, 149U, 1U, 1U, 149U); // Pairwise: + // Round 1 => 31LN; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "1LS 180LN", 150U, 0U, 0U, 149U, 1U); + // Round 1 => 31LN; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "100LS 81LN", 150U, 0U, 0U, 50U, 100U); + // Round 1 => 31LN; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "150LS 31LN", 150U, 0U, 0U, 0U, 150U); - TestPriorityCookieCase(cm.get(), "1LS 180HN", 0U, 0U, 150U, 150U, 0U); + // Round 1 => none; round 2 => none; round 3 => none. + // Round 4 => 31HN; round 5 => none; round 6 => none. + TestPriorityCookieCase(cm.get(), "1LS 180HN", 1U, 0U, 149U, 149U, 1U); + // Round 1 => none; round 2 => 31LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "100LS 81HN", 69U, 0U, 81U, 81U, 69U); + // Round 1 => none; round 2 => 31LS; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "150LS 31HN", 119U, 0U, 31U, 31U, 119U); // Quota calculations inside non-secure/secure blocks remain in place: - // Round 1 => 20LS; round 2 => none; round 3 => 11HN. + // Round 1 => none; round 2 => 20LS; round 3 => none. + // Round 4 => 11HN; round 5 => none; round 6 => none. TestPriorityCookieCase(cm.get(), "50HN 50LS 81HS", 30U, 0U, 120U, 39U, 111U); - // Round 1 => none; round 2 => 10LS, 21MN; round 3 => none. - TestPriorityCookieCase(cm.get(), "11MS 10HN 10LS 90MN 60HN", 0U, 80U, 70U, - 139U, 11U); + // Round 1 => none; round 2 => none; round 3 => 31MN. + // Round 4 => none; round 5 => none; round 6 => none. + TestPriorityCookieCase(cm.get(), "11MS 10HN 10LS 90MN 60HN", 10U, 70U, 70U, + 129U, 21U); + // Round 1 => 31LN; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. + TestPriorityCookieCase(cm.get(), "40LS 40LN 101HS", 49U, 0U, 101U, 9U, + 141U); // Multiple GC rounds end up with consistent behavior: - TestPriorityCookieCase(cm.get(), "100HS 100LN 100MN", 0, 76U, 100U, 76U, - 100U); + // GC is started as soon as there are 181 cookies in the store. + // On each major round it tries to preserve the quota for each priority. + // It is not aware about more cookies going in. + // 1 GC notices there are 181 cookies - 100HS 81LN 0MN + // Round 1 => 31LN; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. + // 2 GC notices there are 181 cookies - 100HS 69LN 12MN + // Round 1 => 31LN; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => none. + // 3 GC notices there are 181 cookies - 100HS 38LN 43MN + // Round 1 => 8LN; round 2 => none; round 3 => none. + // Round 4 => none; round 5 => none; round 6 => 23HS. + // 4 GC notcies there are 181 cookies - 77HS 30LN 74MN + // Round 1 => none; round 2 => none; round 3 => 24MN. + // Round 4 => none; round 5 => none; round 6 => 7HS. + TestPriorityCookieCase(cm.get(), "100HS 100LN 100MN", 30U, 76U, 70U, 106U, + 70U); } // Function for creating a CM with a number of cookies in it, @@ -2499,14 +2535,14 @@ TEST_F(CookieMonsterTest, FlushStore) { // Before initialization, FlushStore() should just run the callback. cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get())); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(0, store->flush_count()); ASSERT_EQ(1, counter->callback_count()); // NULL callback is safe. cm->FlushStore(base::Closure()); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(0, store->flush_count()); ASSERT_EQ(1, counter->callback_count()); @@ -2514,14 +2550,14 @@ TEST_F(CookieMonsterTest, FlushStore) { // After initialization, FlushStore() should delegate to the store. GetAllCookies(cm.get()); // Force init. cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get())); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(1, store->flush_count()); ASSERT_EQ(2, counter->callback_count()); // NULL callback is still safe. cm->FlushStore(base::Closure()); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(2, store->flush_count()); ASSERT_EQ(2, counter->callback_count()); @@ -2530,12 +2566,12 @@ TEST_F(CookieMonsterTest, FlushStore) { cm.reset(new CookieMonster(nullptr, nullptr)); GetAllCookies(cm.get()); // Force init. cm->FlushStore(base::Closure()); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(2, counter->callback_count()); cm->FlushStore(base::Bind(&CallbackCounter::Callback, counter.get())); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); ASSERT_EQ(3, counter->callback_count()); } @@ -3333,19 +3369,19 @@ TEST_F(CookieMonsterNotificationTest, NoNotifyWithNoCookie) { monster()->AddCallbackForCookie( test_url_, "abc", base::Bind(&RecordCookieChanges, &cookies, nullptr))); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(0U, cookies.size()); } TEST_F(CookieMonsterNotificationTest, NoNotifyWithInitialCookie) { std::vector<CanonicalCookie> cookies; SetCookie(monster(), test_url_, "abc=def"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); std::unique_ptr<CookieStore::CookieChangedSubscription> sub( monster()->AddCallbackForCookie( test_url_, "abc", base::Bind(&RecordCookieChanges, &cookies, nullptr))); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(0U, cookies.size()); } @@ -3357,7 +3393,7 @@ TEST_F(CookieMonsterNotificationTest, NotifyOnSet) { test_url_, "abc", base::Bind(&RecordCookieChanges, &cookies, &removes))); SetCookie(monster(), test_url_, "abc=def"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, removes.size()); @@ -3374,12 +3410,12 @@ TEST_F(CookieMonsterNotificationTest, NotifyOnDelete) { test_url_, "abc", base::Bind(&RecordCookieChanges, &cookies, &removes))); SetCookie(monster(), test_url_, "abc=def"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(1U, cookies.size()); EXPECT_EQ(1U, removes.size()); DeleteCookie(monster(), test_url_, "abc"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(2U, cookies.size()); EXPECT_EQ(2U, removes.size()); @@ -3396,13 +3432,13 @@ TEST_F(CookieMonsterNotificationTest, NotifyOnUpdate) { test_url_, "abc", base::Bind(&RecordCookieChanges, &cookies, &removes))); SetCookie(monster(), test_url_, "abc=def"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(1U, cookies.size()); // Replacing an existing cookie is actually a two-phase delete + set // operation, so we get an extra notification. SetCookie(monster(), test_url_, "abc=ghi"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(3U, cookies.size()); EXPECT_EQ(3U, removes.size()); @@ -3428,11 +3464,11 @@ TEST_F(CookieMonsterNotificationTest, MultipleNotifies) { test_url_, "def", base::Bind(&RecordCookieChanges, &cookies1, nullptr))); SetCookie(monster(), test_url_, "abc=def"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(1U, cookies0.size()); EXPECT_EQ(0U, cookies1.size()); SetCookie(monster(), test_url_, "def=abc"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(1U, cookies0.size()); EXPECT_EQ(1U, cookies1.size()); } @@ -3449,7 +3485,7 @@ TEST_F(CookieMonsterNotificationTest, MultipleSameNotifies) { test_url_, "abc", base::Bind(&RecordCookieChanges, &cookies1, nullptr))); SetCookie(monster(), test_url_, "abc=def"); - base::MessageLoop::current()->RunUntilIdle(); + base::RunLoop().RunUntilIdle(); EXPECT_EQ(1U, cookies0.size()); EXPECT_EQ(1U, cookies0.size()); } diff --git a/chromium/net/cookies/cookie_store.cc b/chromium/net/cookies/cookie_store.cc index cb9acc8b41d..1f1b7b96460 100644 --- a/chromium/net/cookies/cookie_store.cc +++ b/chromium/net/cookies/cookie_store.cc @@ -31,7 +31,7 @@ std::string CookieStore::BuildCookieLine( std::string CookieStore::BuildCookieLine( const std::vector<CanonicalCookie*>& cookies) { std::string cookie_line; - for (const auto& cookie : cookies) { + for (auto* cookie : cookies) { if (!cookie_line.empty()) cookie_line += "; "; // In Mozilla, if you set a cookie like "AAA", it will have an empty token |