diff options
author | ben <ben@chromium.org> | 2016-03-08 09:48:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 17:50:03 +0000 |
commit | 66696d139202c1e760c6e004c36c96394b0f00e2 (patch) | |
tree | 0fd51697e151572cd17b1653dbb39cb51c114f60 /mojo/shell | |
parent | e7f273b439ec3c4921aa1378ba36344b5b06aff9 (diff) | |
download | chromium_src-66696d139202c1e760c6e004c36c96394b0f00e2.zip chromium_src-66696d139202c1e760c6e004c36c96394b0f00e2.tar.gz chromium_src-66696d139202c1e760c6e004c36c96394b0f00e2.tar.bz2 |
Eliminate CapabilityFilter parameter from CreateInstance, instead reading it from the associated manifest.
BUG=
Review URL: https://codereview.chromium.org/1775813002
Cr-Commit-Position: refs/heads/master@{#379853}
Diffstat (limited to 'mojo/shell')
-rw-r--r-- | mojo/shell/public/interfaces/shell.mojom | 1 | ||||
-rw-r--r-- | mojo/shell/shell.cc | 31 | ||||
-rw-r--r-- | mojo/shell/tests/lifecycle/exe_manifest.json | 2 | ||||
-rw-r--r-- | mojo/shell/tests/lifecycle/lifecycle_unittest.cc | 16 | ||||
-rw-r--r-- | mojo/shell/tests/shell/BUILD.gn | 7 | ||||
-rw-r--r-- | mojo/shell/tests/shell/driver.cc | 9 | ||||
-rw-r--r-- | mojo/shell/tests/shell/target_manifest.json | 5 |
7 files changed, 42 insertions, 29 deletions
diff --git a/mojo/shell/public/interfaces/shell.mojom b/mojo/shell/public/interfaces/shell.mojom index 1076127..f29df88 100644 --- a/mojo/shell/public/interfaces/shell.mojom +++ b/mojo/shell/public/interfaces/shell.mojom @@ -67,7 +67,6 @@ interface Shell { // creation. CreateInstance(ShellClientFactory factory, Identity target, - CapabilityFilter filter, PIDReceiver& pid_receiver) => (ConnectResult result); // The listener is removed when the |listener| pipe is closed. diff --git a/mojo/shell/shell.cc b/mojo/shell/shell.cc index 277379f..087c0be 100644 --- a/mojo/shell/shell.cc +++ b/mojo/shell/shell.cc @@ -213,9 +213,31 @@ class Shell::Instance : public mojom::Connector, // mojom::Shell implementation: void CreateInstance(mojom::ShellClientFactoryPtr factory, mojom::IdentityPtr target, - mojom::CapabilityFilterPtr filter, mojom::PIDReceiverRequest pid_receiver, const CreateInstanceCallback& callback) override { + // We need to bounce through the package manager to load the + // CapabilityFilter. + std::string name = target->name; + shell_->shell_resolver_->ResolveMojoName(name, base::Bind( + &mojo::shell::Shell::Instance::OnResolvedNameForCreateInstance, + weak_factory_.GetWeakPtr(), base::Passed(std::move(factory)), + base::Passed(std::move(target)), base::Passed(std::move(pid_receiver)), + callback)); + } + void AddInstanceListener(mojom::InstanceListenerPtr listener) override { + // TODO(beng): this should only track the instances matching this user, and + // root. + shell_->AddInstanceListener(std::move(listener)); + } + + void OnResolvedNameForCreateInstance(mojom::ShellClientFactoryPtr factory, + mojom::IdentityPtr target, + mojom::PIDReceiverRequest pid_receiver, + const CreateInstanceCallback& callback, + const String& resolved_name, + const String& resolved_instance, + mojom::CapabilityFilterPtr filter, + const String& file_url) { if (!base::IsValidGUID(target->user_id)) callback.Run(mojom::ConnectResult::INVALID_ARGUMENT); @@ -228,7 +250,7 @@ class Shell::Instance : public mojom::Connector, mojom::ShellClientRequest request; Instance* instance = shell_->CreateInstance( - target_id, filter->filter.To<CapabilityFilter>(), &request); + target_id, filter->filter.To<CapabilityFilter>(), &request); instance->pid_receiver_binding_.Bind(std::move(pid_receiver)); instance->factory_ = std::move(factory); instance->factory_->CreateShellClient(std::move(request), target->name); @@ -238,11 +260,6 @@ class Shell::Instance : public mojom::Connector, // created instance is identified by |name| and may be subsequently reached // by client code using this identity. } - void AddInstanceListener(mojom::InstanceListenerPtr listener) override { - // TODO(beng): this should only track the instances matching this user, and - // root. - shell_->AddInstanceListener(std::move(listener)); - } uint32_t GenerateUniqueID() const { static uint32_t id = mojom::kInvalidInstanceID; diff --git a/mojo/shell/tests/lifecycle/exe_manifest.json b/mojo/shell/tests/lifecycle/exe_manifest.json index 0308da76..2e6d580 100644 --- a/mojo/shell/tests/lifecycle/exe_manifest.json +++ b/mojo/shell/tests/lifecycle/exe_manifest.json @@ -1,5 +1,5 @@ { "name": "exe:lifecycle_unittest_exe", "display_name": "Lifecycle Unittest Exe", - "capabilities": {} + "capabilities": { "*": ["*"] } } diff --git a/mojo/shell/tests/lifecycle/lifecycle_unittest.cc b/mojo/shell/tests/lifecycle/lifecycle_unittest.cc index e85d08b..a9829f8 100644 --- a/mojo/shell/tests/lifecycle/lifecycle_unittest.cc +++ b/mojo/shell/tests/lifecycle/lifecycle_unittest.cc @@ -203,12 +203,6 @@ class LifecycleTest : public mojo::test::ShellTest { mojo::ScopedMessagePipeHandle pipe = mojo::edk::CreateParentMessagePipe(primordial_pipe_token); - mojo::shell::mojom::CapabilityFilterPtr filter( - mojo::shell::mojom::CapabilityFilter::New()); - mojo::Array<mojo::String> test_interfaces; - test_interfaces.push_back("*"); - filter->filter.insert("*", std::move(test_interfaces)); - mojo::shell::mojom::ShellPtr shell; connector()->ConnectToInterface("mojo:shell", &shell); @@ -216,12 +210,10 @@ class LifecycleTest : public mojo::test::ShellTest { factory.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClientFactory>( std::move(pipe), 0u)); base::RunLoop loop; - mojo::shell::mojom::IdentityPtr target(mojo::shell::mojom::Identity::New()); - target->name = kTestExeName; - target->user_id = mojom::kInheritUserID; - target->instance = ""; - shell->CreateInstance(std::move(factory), std::move(target), - std::move(filter), std::move(request), + mojo::Identity target(kTestExeName, mojom::kInheritUserID); + shell->CreateInstance(std::move(factory), + mojo::shell::mojom::Identity::From(target), + std::move(request), base::Bind(&LifecycleTest::OnConnectionCompleted, base::Unretained(this), &loop)); loop.Run(); diff --git a/mojo/shell/tests/shell/BUILD.gn b/mojo/shell/tests/shell/BUILD.gn index 6742da1..fc2c25a 100644 --- a/mojo/shell/tests/shell/BUILD.gn +++ b/mojo/shell/tests/shell/BUILD.gn @@ -76,8 +76,15 @@ executable("shell_unittest_target") { deps = [ ":interfaces", + ":target_manifest", "//base", "//mojo/shell/public/cpp", "//mojo/shell/runner/child:test_native_main", ] } + +mojo_application_manifest("target_manifest") { + type = "exe" + application_name = "shell_unittest_target" + source = "target_manifest.json" +} diff --git a/mojo/shell/tests/shell/driver.cc b/mojo/shell/tests/shell/driver.cc index 68254f8..7d9c8a7 100644 --- a/mojo/shell/tests/shell/driver.cc +++ b/mojo/shell/tests/shell/driver.cc @@ -85,13 +85,6 @@ class Driver : public mojo::ShellClient, mojo::ScopedMessagePipeHandle pipe = mojo::edk::CreateParentMessagePipe(primordial_pipe_token); - mojo::shell::mojom::CapabilityFilterPtr filter( - mojo::shell::mojom::CapabilityFilter::New()); - mojo::Array<mojo::String> test_interfaces; - test_interfaces.push_back( - mojo::shell::test::mojom::CreateInstanceTest::Name_); - filter->filter.insert("mojo:shell_unittest", std::move(test_interfaces)); - mojo::shell::mojom::ShellClientFactoryPtr factory; factory.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClientFactory>( std::move(pipe), 0u)); @@ -103,7 +96,7 @@ class Driver : public mojo::ShellClient, target->user_id = mojo::shell::mojom::kInheritUserID; target->instance = ""; shell->CreateInstance(std::move(factory), std::move(target), - std::move(filter), std::move(request), + std::move(request), base::Bind(&Driver::OnConnectionCompleted, base::Unretained(this))); diff --git a/mojo/shell/tests/shell/target_manifest.json b/mojo/shell/tests/shell/target_manifest.json new file mode 100644 index 0000000..68ddc21 --- /dev/null +++ b/mojo/shell/tests/shell/target_manifest.json @@ -0,0 +1,5 @@ +{ + "name": "exe:shell_unittest_target", + "display_name": "Shell Unittest: Target", + "capabilities": { "mojo:shell_unittest": [ "mojo::shell::test::mojom::CreateInstanceTest" ] } +} |