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

Unified Diff: mojo/shell/identity.cc

Issue 1743473002: Change Mojo URLs to structured names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@18collapse
Patch Set: . Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/identity.h ('k') | mojo/shell/native_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/identity.cc
diff --git a/mojo/shell/identity.cc b/mojo/shell/identity.cc
index c1c10e283717304153ae0e362f32f365b823a141..707615c80b7ab45a21caa812418b72a681ed6a4e 100644
--- a/mojo/shell/identity.cc
+++ b/mojo/shell/identity.cc
@@ -4,38 +4,21 @@
#include "mojo/shell/identity.h"
+#include "mojo/shell/public/cpp/names.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
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& url)
- : Identity(url, url.spec(), mojom::Connector::kUserRoot) {}
+Identity::Identity(const std::string& name)
+ : Identity(name, GetNamePath(name), mojom::Connector::kUserRoot) {}
-Identity::Identity(const GURL& url, const std::string& qualifier,
+Identity::Identity(const std::string& name, const std::string& qualifier,
uint32_t user_id)
- : url_(url),
- qualifier_(qualifier.empty() ? url_.spec() : qualifier),
+ : name_(name),
+ qualifier_(qualifier.empty() ? GetNamePath(name_) : qualifier),
user_id_(user_id) {}
Identity::~Identity() {}
@@ -44,8 +27,8 @@ bool Identity::operator<(const Identity& other) const {
// 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_;
+ if (name_ != other.name_)
+ return name_ < other.name_;
if (qualifier_ != other.qualifier_)
return qualifier_ < other.qualifier_;
return user_id_ < other.user_id_;
@@ -55,18 +38,13 @@ bool Identity::operator==(const Identity& other) const {
// 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.
- return other.url_ == url_ && other.qualifier_ == qualifier_ &&
+ return other.name_ == name_ && other.qualifier_ == qualifier_ &&
other.user_id_ == user_id_;
}
-void Identity::SetFilter(const CapabilityFilter& filter) {
- filter_ = CanonicalizeFilter(filter);
-}
-
Identity CreateShellIdentity() {
- Identity id =
- Identity(GURL("mojo://shell/"), "", mojom::Connector::kUserRoot);
- id.SetFilter(GetPermissiveCapabilityFilter());
+ Identity id = Identity("mojo:shell", "", mojom::Connector::kUserRoot);
+ id.set_filter(GetPermissiveCapabilityFilter());
return id;
}
« no previous file with comments | « mojo/shell/identity.h ('k') | mojo/shell/native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698