summaryrefslogtreecommitdiffstats
path: root/mojo/shell
diff options
context:
space:
mode:
authorben <ben@chromium.org>2016-03-23 20:43:07 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-24 03:44:11 +0000
commit71bb0096a02097ca761be2404e0645315674a77b (patch)
tree42b9d93b77b141c54dc1b4236982fb8c4c135396 /mojo/shell
parent84c58a4bc0d8843ef859253547fa8288e1ec51f6 (diff)
downloadchromium_src-71bb0096a02097ca761be2404e0645315674a77b.zip
chromium_src-71bb0096a02097ca761be2404e0645315674a77b.tar.gz
chromium_src-71bb0096a02097ca761be2404e0645315674a77b.tar.bz2
Simplify resolve.
BUG= Review URL: https://codereview.chromium.org/1828803002 Cr-Commit-Position: refs/heads/master@{#383024}
Diffstat (limited to 'mojo/shell')
-rw-r--r--mojo/shell/public/cpp/lib/names.cc3
-rw-r--r--mojo/shell/public/cpp/names.h3
-rw-r--r--mojo/shell/public/interfaces/shell_resolver.mojom53
-rw-r--r--mojo/shell/shell.cc32
-rw-r--r--mojo/shell/shell.h11
5 files changed, 48 insertions, 54 deletions
diff --git a/mojo/shell/public/cpp/lib/names.cc b/mojo/shell/public/cpp/lib/names.cc
index e669229..971e8aa 100644
--- a/mojo/shell/public/cpp/lib/names.cc
+++ b/mojo/shell/public/cpp/lib/names.cc
@@ -9,6 +9,9 @@
namespace mojo {
+const char kNameType_Mojo[] = "mojo";
+const char kNameType_Exe[] = "exe";
+
bool IsValidName(const std::string& name) {
std::vector<std::string> parts =
base::SplitString(name, ":", base::KEEP_WHITESPACE,
diff --git a/mojo/shell/public/cpp/names.h b/mojo/shell/public/cpp/names.h
index 9fbabf2..86e8999 100644
--- a/mojo/shell/public/cpp/names.h
+++ b/mojo/shell/public/cpp/names.h
@@ -9,6 +9,9 @@
namespace mojo {
+extern const char kNameType_Mojo[];
+extern const char kNameType_Exe[];
+
// Mojo services and applications are identified by structured "names", of the
// form:
//
diff --git a/mojo/shell/public/interfaces/shell_resolver.mojom b/mojo/shell/public/interfaces/shell_resolver.mojom
index 090bf83..0c4e841 100644
--- a/mojo/shell/public/interfaces/shell_resolver.mojom
+++ b/mojo/shell/public/interfaces/shell_resolver.mojom
@@ -6,34 +6,33 @@ module mojo.shell.mojom;
import "mojo/shell/public/interfaces/capabilities.mojom";
+// The result of a Resolve operation via ShellResolver.
+struct ResolveResult {
+ // The mojo: name that was requested to be resolved.
+ string name;
+
+ // The mojo: name of the physical package supplying the requested name. This
+ // could be the same name that was passed, or the name of a package that
+ // contains it.
+ string resolved_name;
+
+ // An additional piece of metadata that identifies what instance |name| should
+ // be run in. It's possible that |name| may provide several services that
+ // should be run as different instances.
+ string qualifier;
+
+ // The set of capabilities provided and required by |name|.
+ CapabilitySpec capabilities;
+
+ // A file URL to the package specified by |name|.
+ // TODO(beng): What if resolved_mojo_name needs to be re-resolved?
+ string package_url;
+};
+
// Implemented exclusively for the Mojo Shell's use in resolving mojo: names
// and reading static manifest information.
interface ShellResolver {
- // Resolves |mojo_name| to the following metadata:
- //
- // resolved_mojo_name
- // another mojo: name of an application implementing mojo::ShellClientFactory
- // that can handle connections to |mojo_name|.
- //
- // qualifier
- // an additional piece of metadata that identifies what instance
- // |resolved_mojo_name| should be run in. It's possible that
- // |resolved_mojo_name| may provide several services that should be run as
- // different instances.
- //
- // mojo_file_url
- // a file URL to the application specified in |resolved_mojo_name|
- // TODO(beng): what if |resolved_mojo_name| needs to be re-resolved??
- //
- // filter
- // the base CapabilityFilter within which an instance of |resolved_mojo_name|
- // must be run for |mojo_name|.
- //
- // If |mojo_name| can't be resolved (i.e. not a mojo: or exe: scheme), then
- // the callback will be run with null |mojo_file_url|, and |filter|.
- ResolveMojoName(string mojo_name) =>
- (string resolved_mojo_name,
- string qualifier,
- CapabilitySpec? capability_spec,
- string? mojo_file_url);
+ // Resolves |mojo_name| and returns a ResolveResult containing metadata from
+ // the catalog that the Shell uses to run an instance of it.
+ ResolveMojoName(string mojo_name) => (ResolveResult result);
};
diff --git a/mojo/shell/shell.cc b/mojo/shell/shell.cc
index 63ee453..ed3f6e4 100644
--- a/mojo/shell/shell.cc
+++ b/mojo/shell/shell.cc
@@ -41,10 +41,7 @@ const char kCapabilityClass_ClientProcess[] = "client_process";
const char kCapabilityClass_InstanceName[] = "instance_name";
const char kCapabilityClass_AllUsers[] = "all_users";
-void EmptyResolverCallback(const String& resolved_name,
- const String& resolved_instance,
- mojom::CapabilitySpecPtr capabilities,
- const String& file_url) {}
+void EmptyResolverCallback(mojom::ResolveResultPtr result) {}
}
@@ -683,14 +680,11 @@ void Shell::OnShellClientFactoryLost(const Identity& which) {
void Shell::OnGotResolvedName(mojom::ShellResolverPtr resolver,
scoped_ptr<ConnectParams> params,
mojom::ShellClientPtr client,
- const String& resolved_name,
- const String& resolved_instance,
- mojom::CapabilitySpecPtr capabilities_ptr,
- const String& file_url) {
+ mojom::ResolveResultPtr result) {
std::string instance_name = params->target().instance();
if (instance_name == GetNamePath(params->target().name()) &&
- resolved_instance != GetNamePath(resolved_name)) {
- instance_name = resolved_instance;
+ result->qualifier != GetNamePath(result->resolved_name)) {
+ instance_name = result->qualifier;
}
Identity target(params->target().name(), params->target().user_id(),
instance_name);
@@ -706,8 +700,8 @@ void Shell::OnGotResolvedName(mojom::ShellResolverPtr resolver,
// |capabilities_ptr| can be null when there is no manifest, e.g. for URL
// types not resolvable by the resolver.
CapabilitySpec capabilities = GetPermissiveCapabilities();
- if (!capabilities_ptr.is_null())
- capabilities = capabilities_ptr.To<CapabilitySpec>();
+ if (!result->capabilities.is_null())
+ capabilities = result->capabilities.To<CapabilitySpec>();
// Clients that request "all_users" class from the shell are allowed to
// field connection requests from any user. They also run with a synthetic
@@ -745,15 +739,17 @@ void Shell::OnGotResolvedName(mojom::ShellResolverPtr resolver,
if (LoadWithLoader(target, &request)) {
instance->StartWithClient(std::move(client));
} else {
- CHECK(!file_url.is_null() && !capabilities_ptr.is_null());
+ CHECK(!result->package_url.is_null() && !result->capabilities.is_null());
- if (target.name() != resolved_name) {
+ if (target.name() != result->resolved_name) {
instance->StartWithClient(std::move(client));
- CreateShellClientWithFactory(
- source, Identity(resolved_name, target.user_id(), instance_name),
- target.name(), std::move(request));
+ Identity factory(result->resolved_name, target.user_id(),
+ instance_name);
+ CreateShellClientWithFactory(source, factory, target.name(),
+ std::move(request));
} else {
- instance->StartWithFilePath(util::UrlToFilePath(file_url.To<GURL>()));
+ instance->StartWithFilePath(
+ util::UrlToFilePath(result->package_url.To<GURL>()));
}
}
}
diff --git a/mojo/shell/shell.h b/mojo/shell/shell.h
index c060518..60c5dadb 100644
--- a/mojo/shell/shell.h
+++ b/mojo/shell/shell.h
@@ -142,18 +142,11 @@ class Shell : public ShellClient {
// |params| are the params passed to Connect().
// |client| if provided is a ShellClientPtr which should be used to manage the
// new application instance. This may be null.
- // |resolved_name| is the mojo: name identifying the physical package
- // application.
- // |file_url| is the resolved file:// URL of the physical package.
- // |capabilities| is the CapabilitySpecPtr the requested application should be
- // run with, from its manifest.
+ // |result| contains the result of the resolve operation.
void OnGotResolvedName(mojom::ShellResolverPtr resolver,
scoped_ptr<ConnectParams> params,
mojom::ShellClientPtr client,
- const String& resolved_name,
- const String& resolved_instance,
- mojom::CapabilitySpecPtr capabilities,
- const String& file_url);
+ mojom::ResolveResultPtr result);
// Tries to load |target| with an Loader. Returns true if one was registered
// and it was loaded, in which case |request| is taken.