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

Side by Side Diff: services/service_manager/public/interfaces/connector.mojom

Issue 2804373002: Eliminate Connector::Connect(), Connection, etc. (Closed)
Patch Set: . Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 module service_manager.mojom; 5 module service_manager.mojom;
6 6
7 import "services/service_manager/public/interfaces/interface_provider.mojom"; 7 import "services/service_manager/public/interfaces/interface_provider.mojom";
8 8
9 // TODO(beng): Determine who (if anyone) uses kRootUserID.
9 const string kRootUserID = "505C0EE9-3013-43C0-82B0-A84F50CF8D84"; 10 const string kRootUserID = "505C0EE9-3013-43C0-82B0-A84F50CF8D84";
10 const string kInheritUserID = "D26290E4-4485-4EAE-81A2-66D1EEB40A9D"; 11 const string kInheritUserID = "D26290E4-4485-4EAE-81A2-66D1EEB40A9D";
11 12
12 const uint32 kInvalidInstanceID = 0; 13 const uint32 kInvalidInstanceID = 0;
13 14
15 // TODO(beng): Evalute the utility of this enum. There are some inconsistencies
16 // in its use with BindInterface/StartService.
14 enum ConnectResult { 17 enum ConnectResult {
15 // The connection was established successfully. 18 // The operation was established successfully.
16 SUCCEEDED, 19 SUCCEEDED,
17 20
18 // The name or user id supplied was malformed, or the service specified by 21 // The name or user id supplied was malformed, or the service specified by
19 // |name| could not be loaded. 22 // |name| could not be loaded.
20 INVALID_ARGUMENT, 23 INVALID_ARGUMENT,
21 24
22 // The connection was blocked by policy. Either connections to |name| are 25 // Policy prevented the successful completion of this operation. Either
23 // forbidden from this app by the CapabilityFilter, or the service attempted 26 // requests to bind to |name| are forbidden from the calling service by its
24 // to connect using a user id other than its own, |kInheritUserID| or 27 // manifest, or the service attempted to connect using a user id other than
25 // |kRootUserID|. 28 // its own, |kInheritUserID| or |kRootUserID|.
26 ACCESS_DENIED 29 ACCESS_DENIED
27 }; 30 };
28 31
29 // A collection of metadata that disambiguates instances in the service manager. 32 // A collection of metadata that disambiguates instances in the service manager.
30 struct Identity { 33 struct Identity {
31 // A service: or exe: name identifying a service. 34 // A name identifying a service.
32 string name; 35 string name;
33 36
34 // The user id of the target service instance to connect to. If no such 37 // The user id of the target service instance to bind to. If no such instance
35 // instance exists, the service manager may start one. This user id will be 38 // exists, the service manager may start one. This user id will be passed to
36 // passed to the new instance via Initialize(). 39 // the new instance via Initialize().
37 // 40 //
38 // When connecting to other services, services must generally pass 41 // When binding to other services, services must generally pass kInheritUserID
39 // kInheritUserID for this value, and the service manager will either connect 42 // for this value, and the service manager will either bind to an existing
40 // to an existing instance matching the caller's user id, create a new 43 // instance matching the caller's user id, create a new instance matching the
41 // instance matching the caller's user id, or connect to an existing instance 44 // caller's user id, or bind to an existing instance running as kRootUserID.
42 // running as kRootUserID. By default, services do not have the ability to set 45 // By default, services do not have the ability to set arbitrary values to
43 // arbitrary values to this field, and doing so will result in a connection 46 // this field, and doing so will result in an error response.
44 // error on the remote service provider.
45 // 47 //
46 // A service with the ability to launch other services with arbitrary user ids 48 // A service with the ability to launch other services with arbitrary user ids
47 // (e.g. a login service) may set this value to something meaningful to it. 49 // (e.g. a login service) may set this value. The user id string is a valid
48 // The user id string is a valid guid of the form 50 // guid of the form "%08X-%04X-%04X-%04X-%012llX", and (aside from the root
49 // "%08X-%04X-%04X-%04X-%012llX", and (aside from the root user whose 51 // user whose guid is defined above) intended to be not-guessable.
50 // guid is defined above) intended to be not-guessable.
51 // 52 //
52 // When a service is initialized or receives a connection from another 53 // When a service is initialized or receives a bind request from another
53 // service, this value is always the resolved user id, never |kInheritUserID|. 54 // service, this value is always the resolved user id, never |kInheritUserID|.
54 string user_id; 55 string user_id;
55 56
56 // A service may spawn multiple instances with the same (name, user_id) 57 // A service may spawn multiple instances with the same (name, user_id)
57 // pair, provided they are started with unique values of this field. 58 // pair, provided they are started with unique values of this field.
58 // TODO(beng): enforce the emptiness of this parameter unless the client bears 59 // TODO(beng): enforce the emptiness of this parameter unless the client bears
59 // the appropriate capability. 60 // the appropriate capability.
60 string instance; 61 string instance;
61 }; 62 };
62 63
63 // Implemented by an object in the service manager associated with a specific 64 // Implemented by an object in the service manager associated with a specific
64 // instance. Tells the service manager the PID for a process launched by the 65 // instance. Tells the service manager the PID for a process launched by the
65 // client. See |ClientProcessConnection|. 66 // client. See |ClientProcessConnection|.
66 interface PIDReceiver { 67 interface PIDReceiver {
67 SetPID(uint32 pid); 68 SetPID(uint32 pid);
68 }; 69 };
69 70
70 // Encapsulates establishing connections with other Services. 71 // An interface that allows the holder to start other services & bind to
72 // interfaces exposed by them.
71 interface Connector { 73 interface Connector {
72 // Typically, the service manager will start a process for a service the first 74 // Asks the service manager to route a request to bind an implementation of
73 // time it receives a connection request for it. This struct allows a client 75 // the interface to a named service instance.
74 // to start the process itself and provide the service manager the pipes it 76 //
75 // needs to communicate with it. When this function is called, the client owns 77 // A service's ability to bind interfaces exposed by another is controlled by
76 // the lifetime of the child process it started, not the service manager. The 78 // policy set out in each service's manifest. See
77 // service manager binds the |service| pipe, and when it closes destroys the 79 // //services/service_manager/README.md for more information on manifests.
78 // associated instance but the process stays alive. 80 // If policy prevents the requesting service from binding the specified
81 // interface, the request pipe will be closed.
79 // 82 //
80 // Parameters: 83 // Parameters:
81 // 84 //
85 // target
86 // The identity of the service instance to route the request to. If no
87 // instance exists, the service will be started.
88 //
89 // interface_name
90 // The name of the interface to be bound. If the target service does not
91 // expose an interface of this name, the request pipe will be closed.
92 //
93 // interface_pipe
94 // A message pipe endpoint encapsulating a request for an interface named
95 // |interface_name|.
96 //
97 // Response parameters:
98 //
99 // result
100 // Indicates the result of the BindInterface() operation.
101 //
102 // identity
103 // The fully resolved identity of the instance in the service manager, with
104 // a resolved user id. Typically the client passes |kInheritUserID| as the
105 // user id to BindInterface(), which will be resolved by the service
106 // manager into a concrete user id.
107 //
108 BindInterface(Identity target,
109 string interface_name,
110 handle<message_pipe> interface_pipe) =>
111 (ConnectResult result, Identity user_id);
112
113 // Asks the service manager to create an instance for a service. No action is
114 // taken if an instance is already present. If the service is not yet running,
115 // it will be initialized and its OnStart() method will be called. A process
116 // may be allocated.
117 //
118 // Parameters:
119 //
120 // target
121 // The identity of the service to start.
122 //
123 // Response parameters:
124 //
125 // result
126 // Indicates the result of the StartService() operation.
127 //
128 // identity
129 // The fully resolved identity of the instance in the service manager, with
130 // a resolved user id. Typically the client passes |kInheritUserID| as the
131 // user id to BindInterface(), which will be resolved by the service
132 // manager into a concrete user id.
133 //
134 StartService(Identity target) => (ConnectResult result, Identity identity);
135
136 // Typically, the service manager will start a process for a service the first
137 // time it receives a bind interface request for it, or when StartService() is
138 // called. This struct allows a client to start the process itself and provide
139 // the service manager the pipes it needs to communicate with it. When this
140 // function is called, the client owns the lifetime of the child process it
141 // started, not the service manager. The service manager binds the |service|
142 // pipe, and when it closes destroys the associated instance but the process
143 // stays alive.
144 //
145 // Parameters:
146 //
147 // target
148 // The identity of the service to create the instance for.
149 //
82 // service 150 // service
83 // A pipe to an implementation of Service that the service manager can use 151 // A pipe to an implementation of Service that the service manager can use
84 // to communicate with the service. 152 // to communicate with the service.
85 // 153 //
86 // pid_receiver_request 154 // pid_receiver_request
87 // Allows the client process launcher to tell the service manager the PID of 155 // Allows the client process launcher to tell the service manager the PID of
88 // the process it created (the pid isn't supplied directly here as the 156 // the process it created (the pid isn't supplied directly here as the
89 // process may not have been launched by the time Connect() is called.) 157 // process may not have been launched by the time BindInterface() is
158 // called.)
90 // 159 //
91 StartService(Identity name, 160 StartServiceWithProcess(Identity target,
92 handle<message_pipe> service, 161 handle<message_pipe> service,
93 PIDReceiver& pid_receiver_request); 162 PIDReceiver& pid_receiver_request) =>
94 163 (ConnectResult result, Identity identity);
95 // Requests a connection with another service. The service originating the
96 // request is referred to as the "source" and the one receiving the "target".
97 //
98 // The connection is embodied by a pair of message pipes binding the
99 // InterfaceProvider interface, which allows both the source and target
100 // services to export interfaces to one another. The interfaces bound via
101 // these InterfaceProviders are brokered by the service manager according to
102 // the security policy defined by each service in its manifest.
103 //
104 // If the target service is not running, the service manager will run it,
105 // calling its OnStart() method before completing the connection.
106 //
107 // Parameters:
108 //
109 // target
110 // Identifies the target service instance to connect to.
111 //
112 // remote_interfaces
113 // Allows the source service access to interface implementations exposed by
114 // the target service. The interfaces accessible via this InterfaceProvider
115 // are filtered by the security policy described by the source and target
116 // service manifests.
117 //
118 // Response parameters:
119 //
120 // result
121 // Indicates the result of the Connect() operation.
122 //
123 // user_id
124 // The user id the service manager ran the target service as. Typically a
125 // client passes |kInheritUserID| as the user id to Connect(), which is
126 // resolved by the service manager into a valid user id returned through
127 // this callback.
128 //
129 Connect(Identity target, InterfaceProvider&? remote_interfaces) =>
130 (ConnectResult result, string user_id);
131
132 // Variant of Connect() above. Will (gradually) replace it. Think of this like
133 // a combination of Connect() and InterfaceProvider::GetInteface() - requests
134 // a connection to a service and binds an interface in one step.
135 // TODO(beng): Update this comment once the implementation is complete.
136 BindInterface(Identity target,
137 string interface_name,
138 handle<message_pipe> interface_pipe) =>
139 (ConnectResult result, string user_id);
140 164
141 // Clones this Connector so it can be passed to another thread. 165 // Clones this Connector so it can be passed to another thread.
142 Clone(Connector& request); 166 Clone(Connector& request);
143 }; 167 };
OLDNEW
« no previous file with comments | « services/service_manager/public/cpp/service_test.h ('k') | services/service_manager/public/interfaces/service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698