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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/mojo/service_registry.mojom.dart

Issue 1998433002: Dart: Adds Interface and InterfaceRequest interfaces. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 7 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 library service_registry_mojom; 5 library service_registry_mojom;
6 import 'dart:async'; 6 import 'dart:async';
7 import 'package:mojo/bindings.dart' as bindings; 7 import 'package:mojo/bindings.dart' as bindings;
8 import 'package:mojo/core.dart' as core; 8 import 'package:mojo/core.dart' as core;
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer; 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
10 import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom ; 10 import 'package:mojo/mojo/service_provider.mojom.dart' as service_provider_mojom ;
11 11
12 12
13 13
14 class _ServiceRegistryAddServicesParams extends bindings.Struct { 14 class _ServiceRegistryAddServicesParams extends bindings.Struct {
15 static const List<bindings.StructDataHeader> kVersions = const [ 15 static const List<bindings.StructDataHeader> kVersions = const [
16 const bindings.StructDataHeader(24, 0) 16 const bindings.StructDataHeader(24, 0)
17 ]; 17 ];
18 List<String> interfaceNames = null; 18 List<String> interfaceNames = null;
19 Object serviceProvider = null; 19 service_provider_mojom.ServiceProviderInterface serviceProvider = null;
20 20
21 _ServiceRegistryAddServicesParams() : super(kVersions.last.size); 21 _ServiceRegistryAddServicesParams() : super(kVersions.last.size);
22 22
23 static _ServiceRegistryAddServicesParams deserialize(bindings.Message message) { 23 static _ServiceRegistryAddServicesParams deserialize(bindings.Message message) {
24 var decoder = new bindings.Decoder(message); 24 var decoder = new bindings.Decoder(message);
25 var result = decode(decoder); 25 var result = decode(decoder);
26 if (decoder.excessHandles != null) { 26 if (decoder.excessHandles != null) {
27 decoder.excessHandles.forEach((h) => h.close()); 27 decoder.excessHandles.forEach((h) => h.close());
28 } 28 }
29 return result; 29 return result;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 118 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) =>
119 responseFactory(null); 119 responseFactory(null);
120 120
121 dynamic getAllTypeDefinitions([Function responseFactory]) => 121 dynamic getAllTypeDefinitions([Function responseFactory]) =>
122 responseFactory(null); 122 responseFactory(null);
123 } 123 }
124 124
125 abstract class ServiceRegistry { 125 abstract class ServiceRegistry {
126 static const String serviceName = "mojo::ServiceRegistry"; 126 static const String serviceName = "mojo::ServiceRegistry";
127 void addServices(List<String> interfaceNames, Object serviceProvider); 127
128 static service_describer.ServiceDescription _cachedServiceDescription;
129 static service_describer.ServiceDescription get serviceDescription {
130 if (_cachedServiceDescription == null) {
131 _cachedServiceDescription = new _ServiceRegistryServiceDescription();
132 }
133 return _cachedServiceDescription;
134 }
135
136 static ServiceRegistryProxy connectToService(
137 bindings.ServiceConnector s, String url, [String serviceName]) {
138 ServiceRegistryProxy p = new ServiceRegistryProxy.unbound();
139 String name = serviceName ?? ServiceRegistry.serviceName;
140 if ((name == null) || name.isEmpty) {
141 throw new core.MojoApiError(
142 "If an interface has no ServiceName, then one must be provided.");
143 }
144 s.connectToService(url, p, name);
145 return p;
146 }
147 void addServices(List<String> interfaceNames, service_provider_mojom.ServicePr oviderInterface serviceProvider);
148 }
149
150 abstract class ServiceRegistryInterface
151 implements bindings.MojoInterface<ServiceRegistry>,
152 ServiceRegistry {
153 factory ServiceRegistryInterface([ServiceRegistry impl]) =>
154 new ServiceRegistryStub.unbound(impl);
155 factory ServiceRegistryInterface.fromEndpoint(
156 core.MojoMessagePipeEndpoint endpoint,
157 [ServiceRegistry impl]) =>
158 new ServiceRegistryStub.fromEndpoint(endpoint, impl);
159 }
160
161 abstract class ServiceRegistryInterfaceRequest
162 implements bindings.MojoInterface<ServiceRegistry>,
163 ServiceRegistry {
164 factory ServiceRegistryInterfaceRequest() =>
165 new ServiceRegistryProxy.unbound();
128 } 166 }
129 167
130 class _ServiceRegistryProxyControl 168 class _ServiceRegistryProxyControl
131 extends bindings.ProxyMessageHandler 169 extends bindings.ProxyMessageHandler
132 implements bindings.ProxyControl { 170 implements bindings.ProxyControl<ServiceRegistry> {
133 _ServiceRegistryProxyControl.fromEndpoint( 171 _ServiceRegistryProxyControl.fromEndpoint(
134 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 172 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
135 173
136 _ServiceRegistryProxyControl.fromHandle( 174 _ServiceRegistryProxyControl.fromHandle(
137 core.MojoHandle handle) : super.fromHandle(handle); 175 core.MojoHandle handle) : super.fromHandle(handle);
138 176
139 _ServiceRegistryProxyControl.unbound() : super.unbound(); 177 _ServiceRegistryProxyControl.unbound() : super.unbound();
140 178
141 service_describer.ServiceDescription get serviceDescription =>
142 new _ServiceRegistryServiceDescription();
143
144 String get serviceName => ServiceRegistry.serviceName; 179 String get serviceName => ServiceRegistry.serviceName;
145 180
146 void handleResponse(bindings.ServiceMessage message) { 181 void handleResponse(bindings.ServiceMessage message) {
147 switch (message.header.type) { 182 switch (message.header.type) {
148 default: 183 default:
149 proxyError("Unexpected message type: ${message.header.type}"); 184 proxyError("Unexpected message type: ${message.header.type}");
150 close(immediate: true); 185 close(immediate: true);
151 break; 186 break;
152 } 187 }
153 } 188 }
154 189
190 ServiceRegistry get impl => null;
191 set impl(ServiceRegistry _) {
192 throw new core.MojoApiError("The impl of a Proxy cannot be set.");
193 }
194
155 @override 195 @override
156 String toString() { 196 String toString() {
157 var superString = super.toString(); 197 var superString = super.toString();
158 return "_ServiceRegistryProxyControl($superString)"; 198 return "_ServiceRegistryProxyControl($superString)";
159 } 199 }
160 } 200 }
161 201
162 class ServiceRegistryProxy 202 class ServiceRegistryProxy
163 extends bindings.Proxy 203 extends bindings.Proxy<ServiceRegistry>
164 implements ServiceRegistry { 204 implements ServiceRegistry,
205 ServiceRegistryInterface,
206 ServiceRegistryInterfaceRequest {
165 ServiceRegistryProxy.fromEndpoint( 207 ServiceRegistryProxy.fromEndpoint(
166 core.MojoMessagePipeEndpoint endpoint) 208 core.MojoMessagePipeEndpoint endpoint)
167 : super(new _ServiceRegistryProxyControl.fromEndpoint(endpoint)); 209 : super(new _ServiceRegistryProxyControl.fromEndpoint(endpoint));
168 210
169 ServiceRegistryProxy.fromHandle(core.MojoHandle handle) 211 ServiceRegistryProxy.fromHandle(core.MojoHandle handle)
170 : super(new _ServiceRegistryProxyControl.fromHandle(handle)); 212 : super(new _ServiceRegistryProxyControl.fromHandle(handle));
171 213
172 ServiceRegistryProxy.unbound() 214 ServiceRegistryProxy.unbound()
173 : super(new _ServiceRegistryProxyControl.unbound()); 215 : super(new _ServiceRegistryProxyControl.unbound());
174 216
175 static ServiceRegistryProxy newFromEndpoint( 217 static ServiceRegistryProxy newFromEndpoint(
176 core.MojoMessagePipeEndpoint endpoint) { 218 core.MojoMessagePipeEndpoint endpoint) {
177 assert(endpoint.setDescription("For ServiceRegistryProxy")); 219 assert(endpoint.setDescription("For ServiceRegistryProxy"));
178 return new ServiceRegistryProxy.fromEndpoint(endpoint); 220 return new ServiceRegistryProxy.fromEndpoint(endpoint);
179 } 221 }
180 222
181 factory ServiceRegistryProxy.connectToService(
182 bindings.ServiceConnector s, String url, [String serviceName]) {
183 ServiceRegistryProxy p = new ServiceRegistryProxy.unbound();
184 s.connectToService(url, p, serviceName);
185 return p;
186 }
187 223
188 224 void addServices(List<String> interfaceNames, service_provider_mojom.ServicePr oviderInterface serviceProvider) {
189 void addServices(List<String> interfaceNames, Object serviceProvider) {
190 if (!ctrl.isBound) { 225 if (!ctrl.isBound) {
191 ctrl.proxyError("The Proxy is closed."); 226 ctrl.proxyError("The Proxy is closed.");
192 return; 227 return;
193 } 228 }
194 var params = new _ServiceRegistryAddServicesParams(); 229 var params = new _ServiceRegistryAddServicesParams();
195 params.interfaceNames = interfaceNames; 230 params.interfaceNames = interfaceNames;
196 params.serviceProvider = serviceProvider; 231 params.serviceProvider = serviceProvider;
197 ctrl.sendMessage(params, 232 ctrl.sendMessage(params,
198 _serviceRegistryMethodAddServicesName); 233 _serviceRegistryMethodAddServicesName);
199 } 234 }
(...skipping 11 matching lines...) Expand all
211 } 246 }
212 247
213 _ServiceRegistryStubControl.fromHandle( 248 _ServiceRegistryStubControl.fromHandle(
214 core.MojoHandle handle, [ServiceRegistry impl]) 249 core.MojoHandle handle, [ServiceRegistry impl])
215 : super.fromHandle(handle, autoBegin: impl != null) { 250 : super.fromHandle(handle, autoBegin: impl != null) {
216 _impl = impl; 251 _impl = impl;
217 } 252 }
218 253
219 _ServiceRegistryStubControl.unbound([this._impl]) : super.unbound(); 254 _ServiceRegistryStubControl.unbound([this._impl]) : super.unbound();
220 255
256 String get serviceName => ServiceRegistry.serviceName;
257
221 258
222 259
223 dynamic handleMessage(bindings.ServiceMessage message) { 260 dynamic handleMessage(bindings.ServiceMessage message) {
224 if (bindings.ControlMessageHandler.isControlMessage(message)) { 261 if (bindings.ControlMessageHandler.isControlMessage(message)) {
225 return bindings.ControlMessageHandler.handleMessage(this, 262 return bindings.ControlMessageHandler.handleMessage(this,
226 0, 263 0,
227 message); 264 message);
228 } 265 }
229 if (_impl == null) { 266 if (_impl == null) {
230 throw new core.MojoApiError("$this has no implementation set"); 267 throw new core.MojoApiError("$this has no implementation set");
(...skipping 30 matching lines...) Expand all
261 } 298 }
262 } 299 }
263 300
264 @override 301 @override
265 String toString() { 302 String toString() {
266 var superString = super.toString(); 303 var superString = super.toString();
267 return "_ServiceRegistryStubControl($superString)"; 304 return "_ServiceRegistryStubControl($superString)";
268 } 305 }
269 306
270 int get version => 0; 307 int get version => 0;
271
272 static service_describer.ServiceDescription _cachedServiceDescription;
273 static service_describer.ServiceDescription get serviceDescription {
274 if (_cachedServiceDescription == null) {
275 _cachedServiceDescription = new _ServiceRegistryServiceDescription();
276 }
277 return _cachedServiceDescription;
278 }
279 } 308 }
280 309
281 class ServiceRegistryStub 310 class ServiceRegistryStub
282 extends bindings.Stub<ServiceRegistry> 311 extends bindings.Stub<ServiceRegistry>
283 implements ServiceRegistry { 312 implements ServiceRegistry,
313 ServiceRegistryInterface,
314 ServiceRegistryInterfaceRequest {
315 ServiceRegistryStub.unbound([ServiceRegistry impl])
316 : super(new _ServiceRegistryStubControl.unbound(impl));
317
284 ServiceRegistryStub.fromEndpoint( 318 ServiceRegistryStub.fromEndpoint(
285 core.MojoMessagePipeEndpoint endpoint, [ServiceRegistry impl]) 319 core.MojoMessagePipeEndpoint endpoint, [ServiceRegistry impl])
286 : super(new _ServiceRegistryStubControl.fromEndpoint(endpoint, impl)); 320 : super(new _ServiceRegistryStubControl.fromEndpoint(endpoint, impl));
287 321
288 ServiceRegistryStub.fromHandle( 322 ServiceRegistryStub.fromHandle(
289 core.MojoHandle handle, [ServiceRegistry impl]) 323 core.MojoHandle handle, [ServiceRegistry impl])
290 : super(new _ServiceRegistryStubControl.fromHandle(handle, impl)); 324 : super(new _ServiceRegistryStubControl.fromHandle(handle, impl));
291 325
292 ServiceRegistryStub.unbound([ServiceRegistry impl])
293 : super(new _ServiceRegistryStubControl.unbound(impl));
294
295 static ServiceRegistryStub newFromEndpoint( 326 static ServiceRegistryStub newFromEndpoint(
296 core.MojoMessagePipeEndpoint endpoint) { 327 core.MojoMessagePipeEndpoint endpoint) {
297 assert(endpoint.setDescription("For ServiceRegistryStub")); 328 assert(endpoint.setDescription("For ServiceRegistryStub"));
298 return new ServiceRegistryStub.fromEndpoint(endpoint); 329 return new ServiceRegistryStub.fromEndpoint(endpoint);
299 } 330 }
300 331
301 static service_describer.ServiceDescription get serviceDescription =>
302 _ServiceRegistryStubControl.serviceDescription;
303 332
304 333 void addServices(List<String> interfaceNames, service_provider_mojom.ServicePr oviderInterface serviceProvider) {
305 void addServices(List<String> interfaceNames, Object serviceProvider) {
306 return impl.addServices(interfaceNames, serviceProvider); 334 return impl.addServices(interfaceNames, serviceProvider);
307 } 335 }
308 } 336 }
309 337
310 338
311 339
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698