Each unique origin should be isolated from all the other origins. url::Origin tries to enforce that in its definition of the equality operator:
bool operator==(const Origin& other) const {
return IsSameOriginWith(other);
}
bool Origin::IsSameOriginWith(const Origin& other) const {
if (unique_ || other.unique_)
return false;
return tuple_.Equals(other.tuple_) && suborigin_ == other.suborigin_;
}
On the other hand the notion of origin uniqueness is absent from the definition of less-than operator:
bool Origin::operator<(const Origin& other) const {
return tuple_ < other.tuple_ ||
(tuple_.Equals(other.tuple_) && suborigin_ < other.suborigin_);
}
This means that the following test will fail:
std::set<url::Origin> set;
url::Origin unique_origin;
url::Origin another_unique_origin;
EXPECT_TRUE(unique_origin.unique());
EXPECT_TRUE(another_unique_origin.unique());
set.insert(unique_origin);
EXPECT_FALSE(base::ContainsKey(set, another_unique_origin)); // UNEXPECTED BEHAVIOR
This makes it difficult to use std::set to track which renderer processes committed which origins (e.g. see the draft CL at https://chromium-review.googlesource.com/c/chromium/src/+/666317).
Comment 1 by lukasza@chromium.org
, Sep 25 2017