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 library input_mojom; | 5 library input_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 | 10 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 dynamic getAllTypeDefinitions([Function responseFactory]) => | 208 dynamic getAllTypeDefinitions([Function responseFactory]) => |
209 responseFactory(null); | 209 responseFactory(null); |
210 } | 210 } |
211 | 211 |
212 abstract class InputClient { | 212 abstract class InputClient { |
213 static const String serviceName = null; | 213 static const String serviceName = null; |
214 dynamic onBackButton([Function responseFactory = null]); | 214 dynamic onBackButton([Function responseFactory = null]); |
215 } | 215 } |
216 | 216 |
217 | 217 |
218 class _InputClientProxyImpl extends bindings.Proxy { | 218 class _InputClientProxyControl extends bindings.ProxyMessageHandler |
219 _InputClientProxyImpl.fromEndpoint( | 219 implements bindings.ProxyControl { |
| 220 _InputClientProxyControl.fromEndpoint( |
220 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 221 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
221 | 222 |
222 _InputClientProxyImpl.fromHandle(core.MojoHandle handle) : | 223 _InputClientProxyControl.fromHandle( |
223 super.fromHandle(handle); | 224 core.MojoHandle handle) : super.fromHandle(handle); |
224 | 225 |
225 _InputClientProxyImpl.unbound() : super.unbound(); | 226 _InputClientProxyControl.unbound() : super.unbound(); |
226 | |
227 static _InputClientProxyImpl newFromEndpoint( | |
228 core.MojoMessagePipeEndpoint endpoint) { | |
229 assert(endpoint.setDescription("For _InputClientProxyImpl")); | |
230 return new _InputClientProxyImpl.fromEndpoint(endpoint); | |
231 } | |
232 | 227 |
233 service_describer.ServiceDescription get serviceDescription => | 228 service_describer.ServiceDescription get serviceDescription => |
234 new _InputClientServiceDescription(); | 229 new _InputClientServiceDescription(); |
235 | 230 |
| 231 String get serviceName => InputClient.serviceName; |
| 232 |
| 233 @override |
236 void handleResponse(bindings.ServiceMessage message) { | 234 void handleResponse(bindings.ServiceMessage message) { |
237 switch (message.header.type) { | 235 switch (message.header.type) { |
238 case _inputClientMethodOnBackButtonName: | 236 case _inputClientMethodOnBackButtonName: |
239 var r = InputClientOnBackButtonResponseParams.deserialize( | 237 var r = InputClientOnBackButtonResponseParams.deserialize( |
240 message.payload); | 238 message.payload); |
241 if (!message.header.hasRequestId) { | 239 if (!message.header.hasRequestId) { |
242 proxyError("Expected a message with a valid request Id."); | 240 proxyError("Expected a message with a valid request Id."); |
243 return; | 241 return; |
244 } | 242 } |
245 Completer c = completerMap[message.header.requestId]; | 243 Completer c = completerMap[message.header.requestId]; |
246 if (c == null) { | 244 if (c == null) { |
247 proxyError( | 245 proxyError( |
248 "Message had unknown request Id: ${message.header.requestId}"); | 246 "Message had unknown request Id: ${message.header.requestId}"); |
249 return; | 247 return; |
250 } | 248 } |
251 completerMap.remove(message.header.requestId); | 249 completerMap.remove(message.header.requestId); |
252 if (c.isCompleted) { | 250 if (c.isCompleted) { |
253 proxyError("Response completer already completed"); | 251 proxyError("Response completer already completed"); |
254 return; | 252 return; |
255 } | 253 } |
256 c.complete(r); | 254 c.complete(r); |
257 break; | 255 break; |
258 default: | 256 default: |
259 proxyError("Unexpected message type: ${message.header.type}"); | 257 proxyError("Unexpected message type: ${message.header.type}"); |
260 close(immediate: true); | 258 close(immediate: true); |
261 break; | 259 break; |
262 } | 260 } |
263 } | 261 } |
264 | 262 |
| 263 @override |
265 String toString() { | 264 String toString() { |
266 var superString = super.toString(); | 265 var superString = super.toString(); |
267 return "_InputClientProxyImpl($superString)"; | 266 return "_InputClientProxyControl($superString)"; |
268 } | 267 } |
269 } | 268 } |
270 | 269 |
271 | 270 |
272 class _InputClientProxyCalls implements InputClient { | 271 class InputClientProxy extends bindings.Proxy |
273 _InputClientProxyImpl _proxyImpl; | 272 implements InputClient { |
| 273 InputClientProxy.fromEndpoint( |
| 274 core.MojoMessagePipeEndpoint endpoint) |
| 275 : super(new _InputClientProxyControl.fromEndpoint(endpoint)); |
274 | 276 |
275 _InputClientProxyCalls(this._proxyImpl); | 277 InputClientProxy.fromHandle(core.MojoHandle handle) |
276 dynamic onBackButton([Function responseFactory = null]) { | 278 : super(new _InputClientProxyControl.fromHandle(handle)); |
277 var params = new _InputClientOnBackButtonParams(); | |
278 return _proxyImpl.sendMessageWithRequestId( | |
279 params, | |
280 _inputClientMethodOnBackButtonName, | |
281 -1, | |
282 bindings.MessageHeader.kMessageExpectsResponse); | |
283 } | |
284 } | |
285 | 279 |
| 280 InputClientProxy.unbound() |
| 281 : super(new _InputClientProxyControl.unbound()); |
286 | 282 |
287 class InputClientProxy implements bindings.ProxyBase { | 283 static InputClientProxy newFromEndpoint( |
288 final bindings.Proxy impl; | 284 core.MojoMessagePipeEndpoint endpoint) { |
289 InputClient ptr; | 285 assert(endpoint.setDescription("For InputClientProxy")); |
290 | 286 return new InputClientProxy.fromEndpoint(endpoint); |
291 InputClientProxy(_InputClientProxyImpl proxyImpl) : | |
292 impl = proxyImpl, | |
293 ptr = new _InputClientProxyCalls(proxyImpl); | |
294 | |
295 InputClientProxy.fromEndpoint( | |
296 core.MojoMessagePipeEndpoint endpoint) : | |
297 impl = new _InputClientProxyImpl.fromEndpoint(endpoint) { | |
298 ptr = new _InputClientProxyCalls(impl); | |
299 } | |
300 | |
301 InputClientProxy.fromHandle(core.MojoHandle handle) : | |
302 impl = new _InputClientProxyImpl.fromHandle(handle) { | |
303 ptr = new _InputClientProxyCalls(impl); | |
304 } | |
305 | |
306 InputClientProxy.unbound() : | |
307 impl = new _InputClientProxyImpl.unbound() { | |
308 ptr = new _InputClientProxyCalls(impl); | |
309 } | 287 } |
310 | 288 |
311 factory InputClientProxy.connectToService( | 289 factory InputClientProxy.connectToService( |
312 bindings.ServiceConnector s, String url, [String serviceName]) { | 290 bindings.ServiceConnector s, String url, [String serviceName]) { |
313 InputClientProxy p = new InputClientProxy.unbound(); | 291 InputClientProxy p = new InputClientProxy.unbound(); |
314 s.connectToService(url, p, serviceName); | 292 s.connectToService(url, p, serviceName); |
315 return p; | 293 return p; |
316 } | 294 } |
317 | 295 |
318 static InputClientProxy newFromEndpoint( | |
319 core.MojoMessagePipeEndpoint endpoint) { | |
320 assert(endpoint.setDescription("For InputClientProxy")); | |
321 return new InputClientProxy.fromEndpoint(endpoint); | |
322 } | |
323 | 296 |
324 String get serviceName => InputClient.serviceName; | 297 dynamic onBackButton([Function responseFactory = null]) { |
325 | 298 var params = new _InputClientOnBackButtonParams(); |
326 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 299 return ctrl.sendMessageWithRequestId( |
327 | 300 params, |
328 Future responseOrError(Future f) => impl.responseOrError(f); | 301 _inputClientMethodOnBackButtonName, |
329 | 302 -1, |
330 Future get errorFuture => impl.errorFuture; | 303 bindings.MessageHeader.kMessageExpectsResponse); |
331 | |
332 int get version => impl.version; | |
333 | |
334 Future<int> queryVersion() => impl.queryVersion(); | |
335 | |
336 void requireVersion(int requiredVersion) { | |
337 impl.requireVersion(requiredVersion); | |
338 } | |
339 | |
340 String toString() { | |
341 return "InputClientProxy($impl)"; | |
342 } | 304 } |
343 } | 305 } |
344 | 306 |
345 | 307 |
346 class InputClientStub extends bindings.Stub { | 308 class InputClientStub extends bindings.Stub { |
347 InputClient _impl; | 309 InputClient _impl; |
348 | 310 |
349 InputClientStub.fromEndpoint( | 311 InputClientStub.fromEndpoint( |
350 core.MojoMessagePipeEndpoint endpoint, [InputClient impl]) | 312 core.MojoMessagePipeEndpoint endpoint, [InputClient impl]) |
351 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 313 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 dynamic getAllTypeDefinitions([Function responseFactory]) => | 418 dynamic getAllTypeDefinitions([Function responseFactory]) => |
457 responseFactory(null); | 419 responseFactory(null); |
458 } | 420 } |
459 | 421 |
460 abstract class InputService { | 422 abstract class InputService { |
461 static const String serviceName = "input::InputService"; | 423 static const String serviceName = "input::InputService"; |
462 void setClient(Object client); | 424 void setClient(Object client); |
463 } | 425 } |
464 | 426 |
465 | 427 |
466 class _InputServiceProxyImpl extends bindings.Proxy { | 428 class _InputServiceProxyControl extends bindings.ProxyMessageHandler |
467 _InputServiceProxyImpl.fromEndpoint( | 429 implements bindings.ProxyControl { |
| 430 _InputServiceProxyControl.fromEndpoint( |
468 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 431 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
469 | 432 |
470 _InputServiceProxyImpl.fromHandle(core.MojoHandle handle) : | 433 _InputServiceProxyControl.fromHandle( |
471 super.fromHandle(handle); | 434 core.MojoHandle handle) : super.fromHandle(handle); |
472 | 435 |
473 _InputServiceProxyImpl.unbound() : super.unbound(); | 436 _InputServiceProxyControl.unbound() : super.unbound(); |
474 | |
475 static _InputServiceProxyImpl newFromEndpoint( | |
476 core.MojoMessagePipeEndpoint endpoint) { | |
477 assert(endpoint.setDescription("For _InputServiceProxyImpl")); | |
478 return new _InputServiceProxyImpl.fromEndpoint(endpoint); | |
479 } | |
480 | 437 |
481 service_describer.ServiceDescription get serviceDescription => | 438 service_describer.ServiceDescription get serviceDescription => |
482 new _InputServiceServiceDescription(); | 439 new _InputServiceServiceDescription(); |
483 | 440 |
| 441 String get serviceName => InputService.serviceName; |
| 442 |
| 443 @override |
484 void handleResponse(bindings.ServiceMessage message) { | 444 void handleResponse(bindings.ServiceMessage message) { |
485 switch (message.header.type) { | 445 switch (message.header.type) { |
486 default: | 446 default: |
487 proxyError("Unexpected message type: ${message.header.type}"); | 447 proxyError("Unexpected message type: ${message.header.type}"); |
488 close(immediate: true); | 448 close(immediate: true); |
489 break; | 449 break; |
490 } | 450 } |
491 } | 451 } |
492 | 452 |
| 453 @override |
493 String toString() { | 454 String toString() { |
494 var superString = super.toString(); | 455 var superString = super.toString(); |
495 return "_InputServiceProxyImpl($superString)"; | 456 return "_InputServiceProxyControl($superString)"; |
496 } | 457 } |
497 } | 458 } |
498 | 459 |
499 | 460 |
500 class _InputServiceProxyCalls implements InputService { | 461 class InputServiceProxy extends bindings.Proxy |
501 _InputServiceProxyImpl _proxyImpl; | 462 implements InputService { |
| 463 InputServiceProxy.fromEndpoint( |
| 464 core.MojoMessagePipeEndpoint endpoint) |
| 465 : super(new _InputServiceProxyControl.fromEndpoint(endpoint)); |
502 | 466 |
503 _InputServiceProxyCalls(this._proxyImpl); | 467 InputServiceProxy.fromHandle(core.MojoHandle handle) |
504 void setClient(Object client) { | 468 : super(new _InputServiceProxyControl.fromHandle(handle)); |
505 if (!_proxyImpl.isBound) { | |
506 _proxyImpl.proxyError("The Proxy is closed."); | |
507 return; | |
508 } | |
509 var params = new _InputServiceSetClientParams(); | |
510 params.client = client; | |
511 _proxyImpl.sendMessage(params, _inputServiceMethodSetClientName); | |
512 } | |
513 } | |
514 | 469 |
| 470 InputServiceProxy.unbound() |
| 471 : super(new _InputServiceProxyControl.unbound()); |
515 | 472 |
516 class InputServiceProxy implements bindings.ProxyBase { | 473 static InputServiceProxy newFromEndpoint( |
517 final bindings.Proxy impl; | 474 core.MojoMessagePipeEndpoint endpoint) { |
518 InputService ptr; | 475 assert(endpoint.setDescription("For InputServiceProxy")); |
519 | 476 return new InputServiceProxy.fromEndpoint(endpoint); |
520 InputServiceProxy(_InputServiceProxyImpl proxyImpl) : | |
521 impl = proxyImpl, | |
522 ptr = new _InputServiceProxyCalls(proxyImpl); | |
523 | |
524 InputServiceProxy.fromEndpoint( | |
525 core.MojoMessagePipeEndpoint endpoint) : | |
526 impl = new _InputServiceProxyImpl.fromEndpoint(endpoint) { | |
527 ptr = new _InputServiceProxyCalls(impl); | |
528 } | |
529 | |
530 InputServiceProxy.fromHandle(core.MojoHandle handle) : | |
531 impl = new _InputServiceProxyImpl.fromHandle(handle) { | |
532 ptr = new _InputServiceProxyCalls(impl); | |
533 } | |
534 | |
535 InputServiceProxy.unbound() : | |
536 impl = new _InputServiceProxyImpl.unbound() { | |
537 ptr = new _InputServiceProxyCalls(impl); | |
538 } | 477 } |
539 | 478 |
540 factory InputServiceProxy.connectToService( | 479 factory InputServiceProxy.connectToService( |
541 bindings.ServiceConnector s, String url, [String serviceName]) { | 480 bindings.ServiceConnector s, String url, [String serviceName]) { |
542 InputServiceProxy p = new InputServiceProxy.unbound(); | 481 InputServiceProxy p = new InputServiceProxy.unbound(); |
543 s.connectToService(url, p, serviceName); | 482 s.connectToService(url, p, serviceName); |
544 return p; | 483 return p; |
545 } | 484 } |
546 | 485 |
547 static InputServiceProxy newFromEndpoint( | |
548 core.MojoMessagePipeEndpoint endpoint) { | |
549 assert(endpoint.setDescription("For InputServiceProxy")); | |
550 return new InputServiceProxy.fromEndpoint(endpoint); | |
551 } | |
552 | 486 |
553 String get serviceName => InputService.serviceName; | 487 void setClient(Object client) { |
554 | 488 if (!ctrl.isBound) { |
555 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 489 ctrl.proxyError("The Proxy is closed."); |
556 | 490 return; |
557 Future responseOrError(Future f) => impl.responseOrError(f); | 491 } |
558 | 492 var params = new _InputServiceSetClientParams(); |
559 Future get errorFuture => impl.errorFuture; | 493 params.client = client; |
560 | 494 ctrl.sendMessage(params, |
561 int get version => impl.version; | 495 _inputServiceMethodSetClientName); |
562 | |
563 Future<int> queryVersion() => impl.queryVersion(); | |
564 | |
565 void requireVersion(int requiredVersion) { | |
566 impl.requireVersion(requiredVersion); | |
567 } | |
568 | |
569 String toString() { | |
570 return "InputServiceProxy($impl)"; | |
571 } | 496 } |
572 } | 497 } |
573 | 498 |
574 | 499 |
575 class InputServiceStub extends bindings.Stub { | 500 class InputServiceStub extends bindings.Stub { |
576 InputService _impl; | 501 InputService _impl; |
577 | 502 |
578 InputServiceStub.fromEndpoint( | 503 InputServiceStub.fromEndpoint( |
579 core.MojoMessagePipeEndpoint endpoint, [InputService impl]) | 504 core.MojoMessagePipeEndpoint endpoint, [InputService impl]) |
580 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 505 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 static service_describer.ServiceDescription get serviceDescription { | 574 static service_describer.ServiceDescription get serviceDescription { |
650 if (_cachedServiceDescription == null) { | 575 if (_cachedServiceDescription == null) { |
651 _cachedServiceDescription = new _InputServiceServiceDescription(); | 576 _cachedServiceDescription = new _InputServiceServiceDescription(); |
652 } | 577 } |
653 return _cachedServiceDescription; | 578 return _cachedServiceDescription; |
654 } | 579 } |
655 } | 580 } |
656 | 581 |
657 | 582 |
658 | 583 |
OLD | NEW |