| Index: net/cookies/canonical_cookie.cc
|
| diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc
|
| index 227c70fbcefa892a5d9428d3dc676a7ea0d56625..5932c23a8818ef4cf6e0f60983f9694d246c8b78 100644
|
| --- a/net/cookies/canonical_cookie.cc
|
| +++ b/net/cookies/canonical_cookie.cc
|
| @@ -102,6 +102,21 @@ std::string CanonPathWithString(const GURL& url,
|
| return url_path.substr(0, idx);
|
| }
|
|
|
| +// Compares cookies using name, domain and path, so that "equivalent" cookies
|
| +// (per RFC 2965) are equal to each other.
|
| +int PartialCookieOrdering(const net::CanonicalCookie& a,
|
| + const net::CanonicalCookie& b) {
|
| + int diff = a.Name().compare(b.Name());
|
| + if (diff != 0)
|
| + return diff;
|
| +
|
| + diff = a.Domain().compare(b.Domain());
|
| + if (diff != 0)
|
| + return diff;
|
| +
|
| + return a.Path().compare(b.Path());
|
| +}
|
| +
|
| } // namespace
|
|
|
| CanonicalCookie::CanonicalCookie()
|
| @@ -410,4 +425,39 @@ std::string CanonicalCookie::DebugString() const {
|
| static_cast<int64>(creation_date_.ToTimeT()));
|
| }
|
|
|
| +bool CanonicalCookie::PartialCompare(const CanonicalCookie& other) const {
|
| + return PartialCookieOrdering(*this, other) < 0;
|
| +}
|
| +
|
| +bool CanonicalCookie::FullCompare(const CanonicalCookie& other) const {
|
| + // Do the partial comparison first.
|
| + int diff = PartialCookieOrdering(*this, other);
|
| + if (diff != 0)
|
| + return diff < 0;
|
| +
|
| + DCHECK(IsEquivalent(other));
|
| +
|
| + // Compare other fields.
|
| + diff = Value().compare(other.Value());
|
| + if (diff != 0)
|
| + return diff < 0;
|
| +
|
| + if (CreationDate() != other.CreationDate())
|
| + return CreationDate() < other.CreationDate();
|
| +
|
| + if (ExpiryDate() != other.ExpiryDate())
|
| + return ExpiryDate() < other.ExpiryDate();
|
| +
|
| + if (LastAccessDate() != other.LastAccessDate())
|
| + return LastAccessDate() < other.LastAccessDate();
|
| +
|
| + if (IsSecure() != other.IsSecure())
|
| + return IsSecure();
|
| +
|
| + if (IsHttpOnly() != other.IsHttpOnly())
|
| + return IsHttpOnly();
|
| +
|
| + return Priority() < other.Priority();
|
| +}
|
| +
|
| } // namespace net
|
|
|