OLD | NEW |
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 const string kRootUserID = "505C0EE9-3013-43C0-82B0-A84F50CF8D84"; | 9 const string kRootUserID = "505C0EE9-3013-43C0-82B0-A84F50CF8D84"; |
10 const string kInheritUserID = "D26290E4-4485-4EAE-81A2-66D1EEB40A9D"; | 10 const string kInheritUserID = "D26290E4-4485-4EAE-81A2-66D1EEB40A9D"; |
11 | 11 |
12 const uint32 kInvalidInstanceID = 0; | 12 const uint32 kInvalidInstanceID = 0; |
13 | 13 |
14 enum ConnectResult { | 14 enum ConnectResult { |
15 // The connection was established successfully. | 15 // The connection was established successfully. |
16 SUCCEEDED, | 16 SUCCEEDED, |
17 | 17 |
18 // The name or user id supplied was malformed, or the application specified | 18 // The name or user id supplied was malformed, or the service specified by |
19 // by |name| could not be loaded. | 19 // |name| could not be loaded. |
20 INVALID_ARGUMENT, | 20 INVALID_ARGUMENT, |
21 | 21 |
22 // The connection was blocked by policy. Either connections to |name| are | 22 // The connection was blocked by policy. Either connections to |name| are |
23 // forbidden from this app by the CapabilityFilter, or the application | 23 // forbidden from this app by the CapabilityFilter, or the service attempted |
24 // attempted to connect using a user id other than its own, | 24 // to connect using a user id other than its own, |kInheritUserID| or |
25 // kInheritUserID or kRootUserID. | 25 // |kRootUserID|. |
26 ACCESS_DENIED | 26 ACCESS_DENIED |
27 }; | 27 }; |
28 | 28 |
29 // A collection of metadata that disambiguates instances in the shell. | 29 // A collection of metadata that disambiguates instances in the service manager. |
30 struct Identity { | 30 struct Identity { |
31 // A mojo: or exe: name identifying an application. | 31 // A service: or exe: name identifying a service. |
32 string name; | 32 string name; |
33 | 33 |
34 // The user id of the target application instance to connect to. If no such | 34 // The user id of the target service instance to connect to. If no such |
35 // instance exists, the shell may start one. This user id will be passed to | 35 // instance exists, the service manager may start one. This user id will be |
36 // the new instance via Initialize(). | 36 // passed to the new instance via Initialize(). |
37 // When connecting to other applications, applications must generally pass | 37 // |
38 // kInheritUserID for this value, and the shell will either connect to an | 38 // When connecting to other services, services must generally pass |
39 // existing instance matching the caller's user id, create a new instance | 39 // kInheritUserID for this value, and the service manager will either connect |
40 // matching the caller's user id, or connect to an existing instance running | 40 // to an existing instance matching the caller's user id, create a new |
41 // as kRootUserID. By default, applications do not have the ability to set | 41 // instance matching the caller's user id, or connect to an existing instance |
| 42 // running as kRootUserID. By default, services do not have the ability to set |
42 // arbitrary values to this field, and doing so will result in a connection | 43 // arbitrary values to this field, and doing so will result in a connection |
43 // error on the remote service provider. An application with the ability to | 44 // error on the remote service provider. |
44 // launch applications with arbitrary user ids (e.g. a login app) may set this | 45 // |
45 // value to something meaningful to it. The user id string is a valid guid of | 46 // A service with the ability to launch other services with arbitrary user ids |
46 // the form "%08X-%04X-%04X-%04X-%012llX", and (aside from the root user whose | 47 // (e.g. a login service) may set this value to something meaningful to it. |
| 48 // The user id string is a valid guid of the form |
| 49 // "%08X-%04X-%04X-%04X-%012llX", and (aside from the root user whose |
47 // guid is defined above) intended to be not-guessable. | 50 // guid is defined above) intended to be not-guessable. |
48 // When an application is initialized or receives a connection from another | 51 // |
49 // application, this value is always the resolved user id, never | 52 // When a service is initialized or receives a connection from another |
50 // kInheritUserID. | 53 // service, this value is always the resolved user id, never |kInheritUserID|. |
51 string user_id; | 54 string user_id; |
52 | 55 |
53 // An application may spawn multiple instances with the same name,user_id | 56 // A service may spawn multiple instances with the same (name, user_id) |
54 // pair, provided they are started with unique values of this field. | 57 // pair, provided they are started with unique values of this field. |
55 // TODO(beng): enforce the emptiness of this parameter unless the client bears | 58 // TODO(beng): enforce the emptiness of this parameter unless the client bears |
56 // the appropriate capability. | 59 // the appropriate capability. |
57 string instance; | 60 string instance; |
58 }; | 61 }; |
59 | 62 |
60 // Implemented by an object in the shell associated with a specific instance. | 63 // Implemented by an object in the service manager associated with a specific |
61 // Tells it the PID for a process launched by the client. See | 64 // instance. Tells the service manager the PID for a process launched by the |
62 // ClientProcessConnection. | 65 // client. See |ClientProcessConnection|. |
63 interface PIDReceiver { | 66 interface PIDReceiver { |
64 SetPID(uint32 pid); | 67 SetPID(uint32 pid); |
65 }; | 68 }; |
66 | 69 |
67 // Typically, the shell will start a process for a service the first time it | 70 // Typically, the service manager will start a process for a service the first |
68 // receives a connection request for it. This struct allows a client to start | 71 // time it receives a connection request for it. This struct allows a client to |
69 // the process itself and provide the shell the pipes it needs to communicate | 72 // start the process itself and provide the service manager the pipes it needs |
70 // with it. When an instance of this struct is supplied to Connect(), the client | 73 // to communicate with it. When an instance of this struct is supplied to |
71 // owns the lifetime of the child process, not the shell. The shell binds the | 74 // Connect(), the client owns the lifetime of the child process, not the service |
72 // |service| pipe, and when it closes destroys the associated instance but | 75 // manager. The service manager binds the |service| pipe, and when it closes |
73 // the process stays alive. | 76 // destroys the associated instance but the process stays alive. |
74 struct ClientProcessConnection { | 77 struct ClientProcessConnection { |
75 // Provides the shell the ability to bind a Service from the client process to | 78 // Provides the service manager the ability to bind a Service from the client |
76 // the instance it creates. | 79 // process to the instance it creates. |
77 handle<message_pipe> service; | 80 handle<message_pipe> service; |
78 | 81 |
79 // Allows the client process launcher to tell the shell the PID of the process | 82 // Allows the client process launcher to tell the service manager the PID of |
80 // it created (the pid isn't supplied directly here as the process may not | 83 // the process it created (the pid isn't supplied directly here as the process |
81 // have been launched by the time Connect() is called.) | 84 // may not have been launched by the time Connect() is called.) |
82 handle<message_pipe> pid_receiver_request; | 85 handle<message_pipe> pid_receiver_request; |
83 }; | 86 }; |
84 | 87 |
85 // Encapsulates establishing connections with other Services. | 88 // Encapsulates establishing connections with other Services. |
86 interface Connector { | 89 interface Connector { |
87 // Requests a connection with another application. The application originating | 90 // Requests a connection with another service. The service originating the |
88 // the request is referred to as the "source" and the one receiving the | 91 // request is referred to as the "source" and the one receiving the "target". |
89 // "target". | |
90 // | 92 // |
91 // The connection is embodied by a pair of message pipes binding the | 93 // The connection is embodied by a pair of message pipes binding the |
92 // InterfaceProvider interface, which allows both the source and target | 94 // InterfaceProvider interface, which allows both the source and target |
93 // applications to export interfaces to one another. The interfaces bound via | 95 // services to export interfaces to one another. The interfaces bound via |
94 // these InterfaceProviders are brokered by the shell according to the | 96 // these InterfaceProviders are brokered by the service manager according to |
95 // security policy defined by each application in its manifest . | 97 // the security policy defined by each service in its manifest. |
96 // | 98 // |
97 // If the target application is not running, the shell will run it, calling | 99 // If the target service is not running, the service manager will run it, |
98 // its Initialize() method before completing the connection. | 100 // calling its OnStart() method before completing the connection. |
99 // | 101 // |
100 // Parameters: | 102 // Parameters: |
101 // | 103 // |
102 // target | 104 // target |
103 // Identifies the target application instance to connect to. | 105 // Identifies the target service instance to connect to. |
104 // | 106 // |
105 // remote_interfaces | 107 // remote_interfaces |
106 // Allows the source application access to interface implementations | 108 // Allows the source service access to interface implementations exposed by |
107 // exposed by the target application. The interfaces accessible via this | 109 // the target service. The interfaces accessible via this InterfaceProvider |
108 // InterfaceParameter are filtered by the security policy described by the | 110 // are filtered by the security policy described by the source and target |
109 // source and target application manifests. | 111 // service manifests. |
110 // | 112 // |
111 // client_process_connection | 113 // client_process_connection |
112 // When non-null, supplies control pipes the shell can use to bind a | 114 // When non-null, supplies control pipes the service manager can use to |
113 // process created by the client, instead of creating one itself. | 115 // bind a process created by the client, instead of creating one itself. |
114 // TODO(beng): access to this parameter should be restricted by a | |
115 // capability. | |
116 // | 116 // |
117 // Response parameters: | 117 // Response parameters: |
118 // | 118 // |
119 // result | 119 // result |
120 // Indicates the result of the Connect() operation. | 120 // Indicates the result of the Connect() operation. |
121 // | 121 // |
122 // user_id | 122 // user_id |
123 // The user id the shell ran the target application as. Typically a client | 123 // The user id the service manager ran the target service as. Typically a |
124 // passes kInheritUserID as the user id to Connect() which is resolved by | 124 // client passes |kInheritUserID| as the user id to Connect(), which is |
125 // the shell into a valid user id returned through this callback. | 125 // resolved by the service manager into a valid user id returned through |
| 126 // this callback. |
126 // | 127 // |
127 Connect(Identity target, | 128 Connect(Identity target, |
128 InterfaceProvider&? remote_interfaces, | 129 InterfaceProvider&? remote_interfaces, |
129 ClientProcessConnection? client_process_connection) => | 130 ClientProcessConnection? client_process_connection) => |
130 (ConnectResult result, string user_id); | 131 (ConnectResult result, string user_id); |
131 | 132 |
132 // Clones this Connector so it can be passed to another thread. | 133 // Clones this Connector so it can be passed to another thread. |
133 Clone(Connector& request); | 134 Clone(Connector& request); |
134 }; | 135 }; |
OLD | NEW |