Chromium Code Reviews| Index: mojo/shell/identity.cc |
| diff --git a/mojo/shell/identity.cc b/mojo/shell/identity.cc |
| index b3d045094ae16f63fa3c8b11a7726b8bad9a60b5..b7f094c479936522f76dc7b0175ca3b6d2fcae64 100644 |
| --- a/mojo/shell/identity.cc |
| +++ b/mojo/shell/identity.cc |
| @@ -8,21 +8,53 @@ |
| namespace mojo { |
| namespace shell { |
| +namespace { |
| + |
| +// It's valid to specify mojo: URLs in the filter either as mojo:foo or |
| +// mojo://foo/ - but we store the filter in the latter form. |
| +CapabilityFilter CanonicalizeFilter(const CapabilityFilter& filter) { |
| + CapabilityFilter canonicalized; |
| + for (CapabilityFilter::const_iterator it = filter.begin(); |
| + it != filter.end(); |
| + ++it) { |
| + if (it->first == "*") |
| + canonicalized[it->first] = it->second; |
| + else |
| + canonicalized[GURL(it->first).spec()] = it->second; |
| + } |
| + return canonicalized; |
| +} |
| + |
| +} // namespace |
| Identity::Identity() {} |
| -Identity::Identity(const GURL& in_url, const std::string& in_qualifier) |
| - : url(GetBaseURLAndQuery(in_url, nullptr)), |
| - qualifier(in_qualifier.empty() ? url.spec() : in_qualifier) {} |
| +Identity::Identity(const GURL& url) |
| + : url_(GetBaseURLAndQuery(url, nullptr)), |
| + qualifier_(GetBaseURLAndQuery(url, nullptr).spec()) {} |
|
yzshen1
2015/09/18 21:44:04
nit: it seems safe to use |url_| instead of |GetBa
|
| + |
| +Identity::Identity(const GURL& url, const std::string& qualifier) |
| + : url_(GetBaseURLAndQuery(url, nullptr)), |
| + qualifier_(qualifier.empty() ? GetBaseURLAndQuery(url, nullptr).spec() |
| + : qualifier) {} |
| + |
| +Identity::Identity(const GURL& url, |
| + const std::string& qualifier, |
| + CapabilityFilter filter) |
| + : url_(GetBaseURLAndQuery(url, nullptr)), |
| + qualifier_(qualifier.empty() ? GetBaseURLAndQuery(url, nullptr).spec() |
| + : qualifier), |
| + filter_(CanonicalizeFilter(filter)) {} |
| -// explicit |
| -Identity::Identity(const GURL& in_url) |
| - : url(GetBaseURLAndQuery(in_url, nullptr)), qualifier(url.spec()) {} |
| +Identity::~Identity() {} |
| bool Identity::operator<(const Identity& other) const { |
| - if (url != other.url) |
| - return url < other.url; |
| - return qualifier < other.qualifier; |
| + // We specifically don't include filter in the equivalence check because we |
| + // don't quite know how this should work yet. |
| + // TODO(beng): figure out how it should work. |
| + if (url_ != other.url_) |
| + return url_ < other.url_; |
| + return qualifier_ < other.qualifier_; |
| } |
| } // namespace shell |