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

Unified Diff: services/service_manager/README.md

Issue 2680973006: Mojo EDK: Add safe process connection API (Closed)
Patch Set: . Created 3 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 | « remoting/host/win/wts_session_process_delegate.cc ('k') | services/service_manager/runner/common/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/service_manager/README.md
diff --git a/services/service_manager/README.md b/services/service_manager/README.md
index ce4e213037ad3d53348d1e1eb5ef8e550d794527..bc54399f819f9a1ca728c5851669eccc7f41497b 100644
--- a/services/service_manager/README.md
+++ b/services/service_manager/README.md
@@ -68,7 +68,7 @@ first learns about the service, and OnConnect(), which the Service Manager calls
every time some other service tries to connect to this one.
Services have a link back to the Service Manager too, primarily in the form of
-the service_manager.mojom.Connector interface. The Connector allows services to
+the service_manager.mojom.Connector interface. The Connector allows services to
open connections to other services.
A unique connection from the Service Manager to a service is called an
@@ -140,7 +140,7 @@ Consider this simple application that implements the Service interface:
What does all this do? Building the app target produces two files in the output
directory: Packages/my_service/my_service.library and
Packages/my_service/manifest.json. app.library is a DSO loaded by the Service
-Manager in its own process when another service connects to the
+Manager in its own process when another service connects to the
service:my_service name. This is not the only way (nor even the most likely one)
you can implement a Service, but it's the simplest and easiest to reason about.
@@ -644,29 +644,21 @@ previous section. The connect flow in the service that launches the target
mojo::edk::HandlePassingInformation info;
pair.PrepareToPassClientHandleToChildProcess(&target_command_line, &info);
- std::string token = mojo::edk::GenerateRandomToken();
+ mojo::edk::PendingProcessConnection connection;
+ std::string token;
+ mojo::ScopedMessagePipeHandle pipe = connection.CreateMessagePipe(&token);
target_command_line.AppendSwitchASCII(switches::kPrimordialPipeToken,
token);
- mojo::ScopedMessagePipeHandle pipe =
- mojo::edk::CreateParentMessagePipe(token);
-
- service_manager::mojom::ServiceFactoryPtr factory;
- factory.Bind(
- mojo::InterfacePtrInfo<service_manager::mojom::ServiceFactory>(
- std::move(pipe), 0u));
+ service_manager::Identity target("exe:target",
+ service_manager::mojom::kInheritUserID);
service_manager::mojom::PIDReceiverPtr receiver;
-
- service_manager::Identity target("exe:target",service_manager::mojom::kInheritUserID);
- service_manager::Connector::ConnectParams params(target);
- params.set_client_process_connection(std::move(factory),
- MakeRequest(&receiver));
- std::unique_ptr<service_manager::Connection> connection = connector->Connect(&params);
+ connector->RegisterService(target, std::move(pipe), MakeRequest(&receiver));
base::LaunchOptions options;
options.handles_to_inherit = &info;
base::Process process = base::LaunchProcess(target_command_line, options);
- mojo::edk::ChildProcessLaunched(process.Handle(), pair.PassServerHandle());
+ connection.Connect(process.Handle(), pair.PassServerHandle());
That's a lot. But it boils down to these steps:
1. Creating the message pipe to connect the target process and the Service
« no previous file with comments | « remoting/host/win/wts_session_process_delegate.cc ('k') | services/service_manager/runner/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698