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

Side by Side Diff: net/cookies/cookie_monster.cc

Issue 2903213004: Refactor transmission of security of source and http_only mods in cookie_monster.cc. (Closed)
Patch Set: Updated documentation comment. Created 3 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 unified diff | Download patch
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Portions of this code based on Mozilla: 5 // Portions of this code based on Mozilla:
6 // (netwerk/cookie/src/nsCookieService.cpp) 6 // (netwerk/cookie/src/nsCookieService.cpp)
7 /* ***** BEGIN LICENSE BLOCK ***** 7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9 * 9 *
10 * The contents of this file are subject to the Mozilla Public License Version 10 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 this->cookie_monster()->ComputeCookieDiff(&old_cookies, &list_, 760 this->cookie_monster()->ComputeCookieDiff(&old_cookies, &list_,
761 &positive_diff, &negative_diff); 761 &positive_diff, &negative_diff);
762 762
763 for (CookieList::const_iterator it = negative_diff.begin(); 763 for (CookieList::const_iterator it = negative_diff.begin();
764 it != negative_diff.end(); ++it) { 764 it != negative_diff.end(); ++it) {
765 this->cookie_monster()->DeleteCanonicalCookie(*it); 765 this->cookie_monster()->DeleteCanonicalCookie(*it);
766 } 766 }
767 767
768 bool result = true; 768 bool result = true;
769 if (positive_diff.size() > 0) 769 if (positive_diff.size() > 0)
770 result = this->cookie_monster()->SetCanonicalCookies(list_); 770 result = this->cookie_monster()->SetAllCookies(list_);
771 771
772 if (!callback_.is_null()) 772 if (!callback_.is_null())
773 callback_.Run(result); 773 callback_.Run(result);
774 } 774 }
775 775
776 // Task class for GetCookiesWithOptions call. 776 // Task class for GetCookiesWithOptions call.
777 class CookieMonster::GetCookiesWithOptionsTask : public CookieMonsterTask { 777 class CookieMonster::GetCookiesWithOptionsTask : public CookieMonsterTask {
778 public: 778 public:
779 GetCookiesWithOptionsTask(CookieMonster* cookie_monster, 779 GetCookiesWithOptionsTask(CookieMonster* cookie_monster,
780 const GURL& url, 780 const GURL& url,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 url::CanonicalizePath(cookie_path.data(), path_component, &canon_path, 1107 url::CanonicalizePath(cookie_path.data(), path_component, &canon_path,
1108 &canon_path_component); 1108 &canon_path_component);
1109 cookie_path = std::string(canon_path.data() + canon_path_component.begin, 1109 cookie_path = std::string(canon_path.data() + canon_path_component.begin,
1110 canon_path_component.len); 1110 canon_path_component.len);
1111 1111
1112 std::unique_ptr<CanonicalCookie> cc(base::MakeUnique<CanonicalCookie>( 1112 std::unique_ptr<CanonicalCookie> cc(base::MakeUnique<CanonicalCookie>(
1113 name, value, cookie_domain, cookie_path, actual_creation_time, 1113 name, value, cookie_domain, cookie_path, actual_creation_time,
1114 expiration_time, last_access_time, secure, http_only, same_site, 1114 expiration_time, last_access_time, secure, http_only, same_site,
1115 priority)); 1115 priority));
1116 1116
1117 CookieOptions options; 1117 return SetCanonicalCookie(std::move(cc), url.SchemeIsCryptographic(), true);
1118 options.set_include_httponly();
1119 options.set_same_site_cookie_mode(
1120 CookieOptions::SameSiteCookieMode::INCLUDE_STRICT_AND_LAX);
1121 return SetCanonicalCookie(std::move(cc), url, options);
1122 } 1118 }
1123 1119
1124 CookieList CookieMonster::GetAllCookies() { 1120 CookieList CookieMonster::GetAllCookies() {
1125 DCHECK(thread_checker_.CalledOnValidThread()); 1121 DCHECK(thread_checker_.CalledOnValidThread());
1126 1122
1127 // This function is being called to scrape the cookie list for management UI 1123 // This function is being called to scrape the cookie list for management UI
1128 // or similar. We shouldn't show expired cookies in this list since it will 1124 // or similar. We shouldn't show expired cookies in this list since it will
1129 // just be confusing to users, and this function is called rarely enough (and 1125 // just be confusing to users, and this function is called rarely enough (and
1130 // is already slow enough) that it's OK to take the time to garbage collect 1126 // is already slow enough) that it's OK to take the time to garbage collect
1131 // the expired cookies now. 1127 // the expired cookies now.
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 // Even if a key is expired, insert it so it can be garbage collected, 1426 // Even if a key is expired, insert it so it can be garbage collected,
1431 // removed, and sync'd. 1427 // removed, and sync'd.
1432 CookieItVector cookies_with_control_chars; 1428 CookieItVector cookies_with_control_chars;
1433 1429
1434 for (auto& cookie : cookies) { 1430 for (auto& cookie : cookies) {
1435 int64_t cookie_creation_time = cookie->CreationDate().ToInternalValue(); 1431 int64_t cookie_creation_time = cookie->CreationDate().ToInternalValue();
1436 1432
1437 if (creation_times_.insert(cookie_creation_time).second) { 1433 if (creation_times_.insert(cookie_creation_time).second) {
1438 CanonicalCookie* cookie_ptr = cookie.get(); 1434 CanonicalCookie* cookie_ptr = cookie.get();
1439 CookieMap::iterator inserted = InternalInsertCookie( 1435 CookieMap::iterator inserted = InternalInsertCookie(
1440 GetKey(cookie_ptr->Domain()), std::move(cookie), GURL(), false); 1436 GetKey(cookie_ptr->Domain()), std::move(cookie), false, false);
mmenke 2017/06/09 18:48:52 These used to get histogrammed, didn't they? Seem
Randy Smith (Not in Mondays) 2017/06/13 20:53:40 As I read the code, the null URL resulted in them
mmenke 2017/06/16 16:19:48 You're right, I missed that...And it seems like a
Randy Smith (Not in Mondays) 2017/06/16 20:53:58 I suspect it wasn't a decision :-{. But I'm tryin
1441 const Time cookie_access_time(cookie_ptr->LastAccessDate()); 1437 const Time cookie_access_time(cookie_ptr->LastAccessDate());
1442 if (earliest_access_time_.is_null() || 1438 if (earliest_access_time_.is_null() ||
1443 cookie_access_time < earliest_access_time_) 1439 cookie_access_time < earliest_access_time_)
1444 earliest_access_time_ = cookie_access_time; 1440 earliest_access_time_ = cookie_access_time;
1445 1441
1446 if (ContainsControlCharacter(cookie_ptr->Name()) || 1442 if (ContainsControlCharacter(cookie_ptr->Name()) ||
1447 ContainsControlCharacter(cookie_ptr->Value())) { 1443 ContainsControlCharacter(cookie_ptr->Value())) {
1448 cookies_with_control_chars.push_back(inserted); 1444 cookies_with_control_chars.push_back(inserted);
1449 } 1445 }
1450 } else { 1446 } else {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 // time if we've been requested to do so. 1640 // time if we've been requested to do so.
1645 if (options.update_access_time()) { 1641 if (options.update_access_time()) {
1646 InternalUpdateCookieAccessTime(cc, current); 1642 InternalUpdateCookieAccessTime(cc, current);
1647 } 1643 }
1648 cookies->push_back(cc); 1644 cookies->push_back(cc);
1649 } 1645 }
1650 } 1646 }
1651 1647
1652 bool CookieMonster::DeleteAnyEquivalentCookie(const std::string& key, 1648 bool CookieMonster::DeleteAnyEquivalentCookie(const std::string& key,
1653 const CanonicalCookie& ecc, 1649 const CanonicalCookie& ecc,
1654 const GURL& source_url, 1650 bool source_secure,
1655 bool skip_httponly, 1651 bool skip_httponly,
1656 bool already_expired) { 1652 bool already_expired) {
1657 DCHECK(thread_checker_.CalledOnValidThread()); 1653 DCHECK(thread_checker_.CalledOnValidThread());
1658 1654
1659 bool found_equivalent_cookie = false; 1655 bool found_equivalent_cookie = false;
1660 bool skipped_httponly = false; 1656 bool skipped_httponly = false;
1661 bool skipped_secure_cookie = false; 1657 bool skipped_secure_cookie = false;
1662 1658
1663 histogram_cookie_delete_equivalent_->Add(COOKIE_DELETE_EQUIVALENT_ATTEMPT); 1659 histogram_cookie_delete_equivalent_->Add(COOKIE_DELETE_EQUIVALENT_ATTEMPT);
1664 1660
1665 for (CookieMapItPair its = cookies_.equal_range(key); 1661 for (CookieMapItPair its = cookies_.equal_range(key);
1666 its.first != its.second;) { 1662 its.first != its.second;) {
1667 CookieMap::iterator curit = its.first; 1663 CookieMap::iterator curit = its.first;
1668 CanonicalCookie* cc = curit->second.get(); 1664 CanonicalCookie* cc = curit->second.get();
1669 ++its.first; 1665 ++its.first;
1670 1666
1671 // If the cookie is being set from an insecure scheme, then if a cookie 1667 // If the cookie is being set from an insecure scheme, then if a cookie
1672 // already exists with the same name and it is Secure, then the cookie 1668 // already exists with the same name and it is Secure, then the cookie
1673 // should *not* be updated if they domain-match and ignoring the path 1669 // should *not* be updated if they domain-match and ignoring the path
1674 // attribute. 1670 // attribute.
1675 // 1671 //
1676 // See: https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone 1672 // See: https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone
1677 if (cc->IsSecure() && !source_url.SchemeIsCryptographic() && 1673 if (cc->IsSecure() && !source_secure &&
1678 ecc.IsEquivalentForSecureCookieMatching(*cc)) { 1674 ecc.IsEquivalentForSecureCookieMatching(*cc)) {
1679 skipped_secure_cookie = true; 1675 skipped_secure_cookie = true;
1680 histogram_cookie_delete_equivalent_->Add( 1676 histogram_cookie_delete_equivalent_->Add(
1681 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE); 1677 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE);
1682 // If the cookie is equivalent to the new cookie and wouldn't have been 1678 // If the cookie is equivalent to the new cookie and wouldn't have been
1683 // skipped for being HTTP-only, record that it is a skipped secure cookie 1679 // skipped for being HTTP-only, record that it is a skipped secure cookie
1684 // that would have been deleted otherwise. 1680 // that would have been deleted otherwise.
1685 if (ecc.IsEquivalent(*cc)) { 1681 if (ecc.IsEquivalent(*cc)) {
1686 found_equivalent_cookie = true; 1682 found_equivalent_cookie = true;
1687 1683
(...skipping 20 matching lines...) Expand all
1708 } 1704 }
1709 found_equivalent_cookie = true; 1705 found_equivalent_cookie = true;
1710 } 1706 }
1711 } 1707 }
1712 return skipped_httponly || skipped_secure_cookie; 1708 return skipped_httponly || skipped_secure_cookie;
1713 } 1709 }
1714 1710
1715 CookieMonster::CookieMap::iterator CookieMonster::InternalInsertCookie( 1711 CookieMonster::CookieMap::iterator CookieMonster::InternalInsertCookie(
1716 const std::string& key, 1712 const std::string& key,
1717 std::unique_ptr<CanonicalCookie> cc, 1713 std::unique_ptr<CanonicalCookie> cc,
1718 const GURL& source_url, 1714 bool source_secure,
1719 bool sync_to_store) { 1715 bool sync_to_store) {
1720 DCHECK(thread_checker_.CalledOnValidThread()); 1716 DCHECK(thread_checker_.CalledOnValidThread());
1721 CanonicalCookie* cc_ptr = cc.get(); 1717 CanonicalCookie* cc_ptr = cc.get();
1722 1718
1723 if ((cc_ptr->IsPersistent() || persist_session_cookies_) && store_.get() && 1719 if ((cc_ptr->IsPersistent() || persist_session_cookies_) && store_.get() &&
1724 sync_to_store) 1720 sync_to_store)
1725 store_->AddCookie(*cc_ptr); 1721 store_->AddCookie(*cc_ptr);
1726 CookieMap::iterator inserted = 1722 CookieMap::iterator inserted =
1727 cookies_.insert(CookieMap::value_type(key, std::move(cc))); 1723 cookies_.insert(CookieMap::value_type(key, std::move(cc)));
1728 if (delegate_.get()) { 1724 if (delegate_.get()) {
1729 delegate_->OnCookieChanged(*cc_ptr, false, 1725 delegate_->OnCookieChanged(*cc_ptr, false,
1730 CookieStore::ChangeCause::INSERTED); 1726 CookieStore::ChangeCause::INSERTED);
1731 } 1727 }
1732 1728
1733 // See InitializeHistograms() for details. 1729 // See InitializeHistograms() for details.
1734 int32_t type_sample = cc_ptr->SameSite() != CookieSameSite::NO_RESTRICTION 1730 int32_t type_sample = cc_ptr->SameSite() != CookieSameSite::NO_RESTRICTION
1735 ? 1 << COOKIE_TYPE_SAME_SITE 1731 ? 1 << COOKIE_TYPE_SAME_SITE
1736 : 0; 1732 : 0;
1737 type_sample |= cc_ptr->IsHttpOnly() ? 1 << COOKIE_TYPE_HTTPONLY : 0; 1733 type_sample |= cc_ptr->IsHttpOnly() ? 1 << COOKIE_TYPE_HTTPONLY : 0;
1738 type_sample |= cc_ptr->IsSecure() ? 1 << COOKIE_TYPE_SECURE : 0; 1734 type_sample |= cc_ptr->IsSecure() ? 1 << COOKIE_TYPE_SECURE : 0;
1739 histogram_cookie_type_->Add(type_sample); 1735 histogram_cookie_type_->Add(type_sample);
1740 1736
1741 // Histogram the type of scheme used on URLs that set cookies. This
1742 // intentionally includes cookies that are set or overwritten by
1743 // http:// URLs, but not cookies that are cleared by http:// URLs, to
1744 // understand if the former behavior can be deprecated for Secure
1745 // cookies.
1746 if (!source_url.is_empty()) {
1747 CookieSource cookie_source_sample;
1748 if (source_url.SchemeIsCryptographic()) {
1749 cookie_source_sample =
1750 cc_ptr->IsSecure()
1751 ? COOKIE_SOURCE_SECURE_COOKIE_CRYPTOGRAPHIC_SCHEME
1752 : COOKIE_SOURCE_NONSECURE_COOKIE_CRYPTOGRAPHIC_SCHEME;
1753 } else {
1754 cookie_source_sample =
1755 cc_ptr->IsSecure()
1756 ? COOKIE_SOURCE_SECURE_COOKIE_NONCRYPTOGRAPHIC_SCHEME
1757 : COOKIE_SOURCE_NONSECURE_COOKIE_NONCRYPTOGRAPHIC_SCHEME;
1758 }
1759 histogram_cookie_source_scheme_->Add(cookie_source_sample);
1760 }
1761
1762 RunCookieChangedCallbacks(*cc_ptr, CookieStore::ChangeCause::INSERTED); 1737 RunCookieChangedCallbacks(*cc_ptr, CookieStore::ChangeCause::INSERTED);
1763 1738
1764 return inserted; 1739 return inserted;
1765 } 1740 }
1766 1741
1767 bool CookieMonster::SetCookieWithCreationTimeAndOptions( 1742 bool CookieMonster::SetCookieWithCreationTimeAndOptions(
1768 const GURL& url, 1743 const GURL& url,
1769 const std::string& cookie_line, 1744 const std::string& cookie_line,
1770 const Time& creation_time_or_null, 1745 const Time& creation_time_or_null,
1771 const CookieOptions& options) { 1746 const CookieOptions& options) {
1772 DCHECK(thread_checker_.CalledOnValidThread()); 1747 DCHECK(thread_checker_.CalledOnValidThread());
1773 1748
1774 VLOG(kVlogSetCookies) << "SetCookie() line: " << cookie_line; 1749 VLOG(kVlogSetCookies) << "SetCookie() line: " << cookie_line;
1775 1750
1776 Time creation_time = creation_time_or_null; 1751 Time creation_time = creation_time_or_null;
1777 if (creation_time.is_null()) { 1752 if (creation_time.is_null()) {
1778 creation_time = CurrentTime(); 1753 creation_time = CurrentTime();
1779 last_time_seen_ = creation_time; 1754 last_time_seen_ = creation_time;
1780 } 1755 }
1781 1756
1782 std::unique_ptr<CanonicalCookie> cc( 1757 std::unique_ptr<CanonicalCookie> cc(
1783 CanonicalCookie::Create(url, cookie_line, creation_time, options)); 1758 CanonicalCookie::Create(url, cookie_line, creation_time, options));
1784 1759
1785 if (!cc.get()) { 1760 if (!cc.get()) {
1786 VLOG(kVlogSetCookies) << "WARNING: Failed to allocate CanonicalCookie"; 1761 VLOG(kVlogSetCookies) << "WARNING: Failed to allocate CanonicalCookie";
1787 return false; 1762 return false;
1788 } 1763 }
1789 return SetCanonicalCookie(std::move(cc), url, options); 1764 return SetCanonicalCookie(std::move(cc), url.SchemeIsCryptographic(),
1765 !options.exclude_httponly());
1790 } 1766 }
1791 1767
1792 bool CookieMonster::SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc, 1768 bool CookieMonster::SetCanonicalCookie(std::unique_ptr<CanonicalCookie> cc,
1793 const GURL& source_url, 1769 bool secure_source,
1794 const CookieOptions& options) { 1770 bool modify_http_only) {
1795 DCHECK(thread_checker_.CalledOnValidThread()); 1771 DCHECK(thread_checker_.CalledOnValidThread());
1796 1772
1797 Time creation_time = cc->CreationDate(); 1773 Time creation_time = cc->CreationDate();
1798 const std::string key(GetKey(cc->Domain())); 1774 const std::string key(GetKey(cc->Domain()));
1799 bool already_expired = cc->IsExpired(creation_time); 1775 bool already_expired = cc->IsExpired(creation_time);
1800 1776
1801 if (DeleteAnyEquivalentCookie(key, *cc, source_url, 1777 if (DeleteAnyEquivalentCookie(key, *cc, secure_source, !modify_http_only,
1802 options.exclude_httponly(), already_expired)) { 1778 already_expired)) {
1803 std::string error; 1779 std::string error;
1804 error = 1780 error =
1805 "SetCookie() not clobbering httponly cookie or secure cookie for " 1781 "SetCookie() not clobbering httponly cookie or secure cookie for "
1806 "insecure scheme"; 1782 "insecure scheme";
1807 1783
1808 VLOG(kVlogSetCookies) << error; 1784 VLOG(kVlogSetCookies) << error;
1809 return false; 1785 return false;
1810 } 1786 }
1811 1787
1812 VLOG(kVlogSetCookies) << "SetCookie() key: " << key 1788 VLOG(kVlogSetCookies) << "SetCookie() key: " << key
1813 << " cc: " << cc->DebugString(); 1789 << " cc: " << cc->DebugString();
1814 1790
1815 // Realize that we might be setting an expired cookie, and the only point 1791 // Realize that we might be setting an expired cookie, and the only point
1816 // was to delete the cookie which we've already done. 1792 // was to delete the cookie which we've already done.
1817 if (!already_expired) { 1793 if (!already_expired) {
1818 // See InitializeHistograms() for details. 1794 // See InitializeHistograms() for details.
1819 if (cc->IsPersistent()) { 1795 if (cc->IsPersistent()) {
1820 histogram_expiration_duration_minutes_->Add( 1796 histogram_expiration_duration_minutes_->Add(
1821 (cc->ExpiryDate() - creation_time).InMinutes()); 1797 (cc->ExpiryDate() - creation_time).InMinutes());
1822 } 1798 }
1823 1799
1824 InternalInsertCookie(key, std::move(cc), source_url, true); 1800 // Histogram the type of scheme used on URLs that set cookies. This
1801 // intentionally includes cookies that are set or overwritten by
1802 // http:// URLs, but not cookies that are cleared by http:// URLs, to
1803 // understand if the former behavior can be deprecated for Secure
1804 // cookies.
1805 CookieSource cookie_source_sample =
1806 (secure_source
1807 ? (cc->IsSecure()
1808 ? COOKIE_SOURCE_SECURE_COOKIE_CRYPTOGRAPHIC_SCHEME
1809 : COOKIE_SOURCE_NONSECURE_COOKIE_CRYPTOGRAPHIC_SCHEME)
1810 : (cc->IsSecure()
1811 ? COOKIE_SOURCE_SECURE_COOKIE_NONCRYPTOGRAPHIC_SCHEME
1812 : COOKIE_SOURCE_NONSECURE_COOKIE_NONCRYPTOGRAPHIC_SCHEME));
1813 histogram_cookie_source_scheme_->Add(cookie_source_sample);
1814
1815 InternalInsertCookie(key, std::move(cc), secure_source, true);
1825 } else { 1816 } else {
1826 VLOG(kVlogSetCookies) << "SetCookie() not storing already expired cookie."; 1817 VLOG(kVlogSetCookies) << "SetCookie() not storing already expired cookie.";
1827 } 1818 }
1828 1819
1829 // We assume that hopefully setting a cookie will be less common than 1820 // We assume that hopefully setting a cookie will be less common than
1830 // querying a cookie. Since setting a cookie can put us over our limits, 1821 // querying a cookie. Since setting a cookie can put us over our limits,
1831 // make sure that we garbage collect... We can also make the assumption that 1822 // make sure that we garbage collect... We can also make the assumption that
1832 // if a cookie was set, in the common case it will be used soon after, 1823 // if a cookie was set, in the common case it will be used soon after,
1833 // and we will purge the expired cookies in GetCookies(). 1824 // and we will purge the expired cookies in GetCookies().
1834 GarbageCollect(creation_time, key); 1825 GarbageCollect(creation_time, key);
1835 1826
1836 return true; 1827 return true;
1837 } 1828 }
1838 1829
1839 bool CookieMonster::SetCanonicalCookies(const CookieList& list) { 1830 bool CookieMonster::SetAllCookies(const CookieList& list) {
1840 DCHECK(thread_checker_.CalledOnValidThread()); 1831 DCHECK(thread_checker_.CalledOnValidThread());
1832 for (const auto& cookie : list) {
1833 const std::string key(GetKey(cookie.Domain()));
1834 Time creation_time = cookie.CreationDate();
1835 bool already_expired = cookie.IsExpired(creation_time);
1841 1836
1842 CookieOptions options; 1837 bool result =
1843 options.set_include_httponly(); 1838 DeleteAnyEquivalentCookie(key, cookie, false, false, already_expired);
1839 DCHECK(!result);
1844 1840
1845 for (const auto& cookie : list) { 1841 if (already_expired)
1846 // Use an empty GURL. This method does not support setting secure cookies. 1842 continue;
1847 if (!SetCanonicalCookie(base::MakeUnique<CanonicalCookie>(cookie), GURL(), 1843
1848 options)) { 1844 if (cookie.IsPersistent()) {
1849 return false; 1845 histogram_expiration_duration_minutes_->Add(
1846 (cookie.ExpiryDate() - creation_time).InMinutes());
mmenke 2017/06/09 18:48:52 It seems to me like this histogram should only be
Randy Smith (Not in Mondays) 2017/06/13 20:53:41 I am attempting to faithfully replicate the behavi
1850 } 1847 }
1848
1849 InternalInsertCookie(key, base::MakeUnique<CanonicalCookie>(cookie), false,
1850 true);
mmenke 2017/06/09 18:48:52 So you're also removing these from the histogram?
Randy Smith (Not in Mondays) 2017/06/13 20:53:40 Yes, modulo I believe I'm not actually changing be
1851 } 1851 }
1852 1852
1853 // TODO(rdsmith): If this function always returns the same value, it
1854 // shouldn't have a return value. But it should also be deleted (see
1855 // https://codereview.chromium.org/2882063002/#msg64), which would
1856 // solve the return value problem.
1853 return true; 1857 return true;
1854 } 1858 }
1855 1859
1856 void CookieMonster::InternalUpdateCookieAccessTime(CanonicalCookie* cc, 1860 void CookieMonster::InternalUpdateCookieAccessTime(CanonicalCookie* cc,
1857 const Time& current) { 1861 const Time& current) {
1858 DCHECK(thread_checker_.CalledOnValidThread()); 1862 DCHECK(thread_checker_.CalledOnValidThread());
1859 1863
1860 // Based off the Mozilla code. When a cookie has been accessed recently, 1864 // Based off the Mozilla code. When a cookie has been accessed recently,
1861 // don't bother updating its access time again. This reduces the number of 1865 // don't bother updating its access time again. This reduces the number of
1862 // updates we do during pageload, which in turn reduces the chance our storage 1866 // updates we do during pageload, which in turn reduces the chance our storage
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 it != hook_map_.end(); ++it) { 2418 it != hook_map_.end(); ++it) {
2415 std::pair<GURL, std::string> key = it->first; 2419 std::pair<GURL, std::string> key = it->first;
2416 if (cookie.IncludeForRequestURL(key.first, opts) && 2420 if (cookie.IncludeForRequestURL(key.first, opts) &&
2417 cookie.Name() == key.second) { 2421 cookie.Name() == key.second) {
2418 it->second->Notify(cookie, cause); 2422 it->second->Notify(cookie, cause);
2419 } 2423 }
2420 } 2424 }
2421 } 2425 }
2422 2426
2423 } // namespace net 2427 } // namespace net
OLDNEW
« 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