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

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

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 6 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 // WARNING: DO NOT EDIT. This file was generated by a program. 1 // WARNING: DO NOT EDIT. This file was generated by a program.
2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py. 2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py.
3 3
4 library input_connection_mojom; 4 library input_connection_mojom;
5 import 'dart:async'; 5 import 'dart:async';
6 import 'package:mojo/bindings.dart' as bindings; 6 import 'package:mojo/bindings.dart' as bindings;
7 import 'package:mojo/core.dart' as core; 7 import 'package:mojo/core.dart' as core;
8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer; 8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
9 import 'package:mojo_services/mojo/input_events.mojom.dart' as input_events_mojo m; 9 import 'package:mojo_services/mojo/input_events.mojom.dart' as input_events_mojo m;
10 10
11 11
12 12
13 class _InputConnectionSetListenerParams extends bindings.Struct { 13 class _InputConnectionSetListenerParams extends bindings.Struct {
14 static const List<bindings.StructDataHeader> kVersions = const [ 14 static const List<bindings.StructDataHeader> kVersions = const [
15 const bindings.StructDataHeader(16, 0) 15 const bindings.StructDataHeader(16, 0)
16 ]; 16 ];
17 InputListenerInterface listener = null; 17 InputListenerInterface listener = null;
18 18
19 _InputConnectionSetListenerParams() : super(kVersions.last.size); 19 _InputConnectionSetListenerParams() : super(kVersions.last.size);
20 20
21 _InputConnectionSetListenerParams.init(
22 InputListenerInterface this.listener
23 ) : super(kVersions.last.size);
24
21 static _InputConnectionSetListenerParams deserialize(bindings.Message message) { 25 static _InputConnectionSetListenerParams deserialize(bindings.Message message) {
22 var decoder = new bindings.Decoder(message); 26 var decoder = new bindings.Decoder(message);
23 var result = decode(decoder); 27 var result = decode(decoder);
24 if (decoder.excessHandles != null) { 28 if (decoder.excessHandles != null) {
25 decoder.excessHandles.forEach((h) => h.close()); 29 decoder.excessHandles.forEach((h) => h.close());
26 } 30 }
27 return result; 31 return result;
28 } 32 }
29 33
30 static _InputConnectionSetListenerParams decode(bindings.Decoder decoder0) { 34 static _InputConnectionSetListenerParams decode(bindings.Decoder decoder0) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 86
83 87
84 class _InputListenerOnEventParams extends bindings.Struct { 88 class _InputListenerOnEventParams extends bindings.Struct {
85 static const List<bindings.StructDataHeader> kVersions = const [ 89 static const List<bindings.StructDataHeader> kVersions = const [
86 const bindings.StructDataHeader(16, 0) 90 const bindings.StructDataHeader(16, 0)
87 ]; 91 ];
88 input_events_mojom.Event event = null; 92 input_events_mojom.Event event = null;
89 93
90 _InputListenerOnEventParams() : super(kVersions.last.size); 94 _InputListenerOnEventParams() : super(kVersions.last.size);
91 95
96 _InputListenerOnEventParams.init(
97 input_events_mojom.Event this.event
98 ) : super(kVersions.last.size);
99
92 static _InputListenerOnEventParams deserialize(bindings.Message message) { 100 static _InputListenerOnEventParams deserialize(bindings.Message message) {
93 var decoder = new bindings.Decoder(message); 101 var decoder = new bindings.Decoder(message);
94 var result = decode(decoder); 102 var result = decode(decoder);
95 if (decoder.excessHandles != null) { 103 if (decoder.excessHandles != null) {
96 decoder.excessHandles.forEach((h) => h.close()); 104 decoder.excessHandles.forEach((h) => h.close());
97 } 105 }
98 return result; 106 return result;
99 } 107 }
100 108
101 static _InputListenerOnEventParams decode(bindings.Decoder decoder0) { 109 static _InputListenerOnEventParams decode(bindings.Decoder decoder0) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 163
156 164
157 class InputListenerOnEventResponseParams extends bindings.Struct { 165 class InputListenerOnEventResponseParams extends bindings.Struct {
158 static const List<bindings.StructDataHeader> kVersions = const [ 166 static const List<bindings.StructDataHeader> kVersions = const [
159 const bindings.StructDataHeader(16, 0) 167 const bindings.StructDataHeader(16, 0)
160 ]; 168 ];
161 bool consumed = false; 169 bool consumed = false;
162 170
163 InputListenerOnEventResponseParams() : super(kVersions.last.size); 171 InputListenerOnEventResponseParams() : super(kVersions.last.size);
164 172
173 InputListenerOnEventResponseParams.init(
174 bool this.consumed
175 ) : super(kVersions.last.size);
176
165 static InputListenerOnEventResponseParams deserialize(bindings.Message message ) { 177 static InputListenerOnEventResponseParams deserialize(bindings.Message message ) {
166 var decoder = new bindings.Decoder(message); 178 var decoder = new bindings.Decoder(message);
167 var result = decode(decoder); 179 var result = decode(decoder);
168 if (decoder.excessHandles != null) { 180 if (decoder.excessHandles != null) {
169 decoder.excessHandles.forEach((h) => h.close()); 181 decoder.excessHandles.forEach((h) => h.close());
170 } 182 }
171 return result; 183 return result;
172 } 184 }
173 185
174 static InputListenerOnEventResponseParams decode(bindings.Decoder decoder0) { 186 static InputListenerOnEventResponseParams decode(bindings.Decoder decoder0) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 Map toJson() { 233 Map toJson() {
222 Map map = new Map(); 234 Map map = new Map();
223 map["consumed"] = consumed; 235 map["consumed"] = consumed;
224 return map; 236 return map;
225 } 237 }
226 } 238 }
227 239
228 const int _inputConnectionMethodSetListenerName = 0; 240 const int _inputConnectionMethodSetListenerName = 0;
229 241
230 class _InputConnectionServiceDescription implements service_describer.ServiceDes cription { 242 class _InputConnectionServiceDescription implements service_describer.ServiceDes cription {
231 dynamic getTopLevelInterface([Function responseFactory]) => 243 void getTopLevelInterface(Function responder) {
232 responseFactory(null); 244 responder(null);
245 }
233 246
234 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 247 void getTypeDefinition(String typeKey, Function responder) {
235 responseFactory(null); 248 responder(null);
249 }
236 250
237 dynamic getAllTypeDefinitions([Function responseFactory]) => 251 void getAllTypeDefinitions(Function responder) {
238 responseFactory(null); 252 responder(null);
253 }
239 } 254 }
240 255
241 abstract class InputConnection { 256 abstract class InputConnection {
242 static const String serviceName = "mojo::ui::InputConnection"; 257 static const String serviceName = "mojo::ui::InputConnection";
243 258
244 static service_describer.ServiceDescription _cachedServiceDescription; 259 static service_describer.ServiceDescription _cachedServiceDescription;
245 static service_describer.ServiceDescription get serviceDescription { 260 static service_describer.ServiceDescription get serviceDescription {
246 if (_cachedServiceDescription == null) { 261 if (_cachedServiceDescription == null) {
247 _cachedServiceDescription = new _InputConnectionServiceDescription(); 262 _cachedServiceDescription = new _InputConnectionServiceDescription();
248 } 263 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 : super.fromHandle(handle, autoBegin: impl != null) { 393 : super.fromHandle(handle, autoBegin: impl != null) {
379 _impl = impl; 394 _impl = impl;
380 } 395 }
381 396
382 _InputConnectionStubControl.unbound([this._impl]) : super.unbound(); 397 _InputConnectionStubControl.unbound([this._impl]) : super.unbound();
383 398
384 String get serviceName => InputConnection.serviceName; 399 String get serviceName => InputConnection.serviceName;
385 400
386 401
387 402
388 dynamic handleMessage(bindings.ServiceMessage message) { 403 void handleMessage(bindings.ServiceMessage message) {
389 if (bindings.ControlMessageHandler.isControlMessage(message)) { 404 if (bindings.ControlMessageHandler.isControlMessage(message)) {
390 return bindings.ControlMessageHandler.handleMessage(this, 405 bindings.ControlMessageHandler.handleMessage(
391 0, 406 this, 0, message);
392 message); 407 return;
393 } 408 }
394 if (_impl == null) { 409 if (_impl == null) {
395 throw new core.MojoApiError("$this has no implementation set"); 410 throw new core.MojoApiError("$this has no implementation set");
396 } 411 }
397 switch (message.header.type) { 412 switch (message.header.type) {
398 case _inputConnectionMethodSetListenerName: 413 case _inputConnectionMethodSetListenerName:
399 var params = _InputConnectionSetListenerParams.deserialize( 414 var params = _InputConnectionSetListenerParams.deserialize(
400 message.payload); 415 message.payload);
401 _impl.setListener(params.listener); 416 _impl.setListener(params.listener);
402 break; 417 break;
403 default: 418 default:
404 throw new bindings.MojoCodecError("Unexpected message name"); 419 throw new bindings.MojoCodecError("Unexpected message name");
405 break; 420 break;
406 } 421 }
407 return null;
408 } 422 }
409 423
410 InputConnection get impl => _impl; 424 InputConnection get impl => _impl;
411 set impl(InputConnection d) { 425 set impl(InputConnection d) {
412 if (d == null) { 426 if (d == null) {
413 throw new core.MojoApiError("$this: Cannot set a null implementation"); 427 throw new core.MojoApiError("$this: Cannot set a null implementation");
414 } 428 }
415 if (isBound && (_impl == null)) { 429 if (isBound && (_impl == null)) {
416 beginHandlingEvents(); 430 beginHandlingEvents();
417 } 431 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 473
460 474
461 void setListener(InputListenerInterface listener) { 475 void setListener(InputListenerInterface listener) {
462 return impl.setListener(listener); 476 return impl.setListener(listener);
463 } 477 }
464 } 478 }
465 479
466 const int _inputListenerMethodOnEventName = 0; 480 const int _inputListenerMethodOnEventName = 0;
467 481
468 class _InputListenerServiceDescription implements service_describer.ServiceDescr iption { 482 class _InputListenerServiceDescription implements service_describer.ServiceDescr iption {
469 dynamic getTopLevelInterface([Function responseFactory]) => 483 void getTopLevelInterface(Function responder) {
470 responseFactory(null); 484 responder(null);
485 }
471 486
472 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 487 void getTypeDefinition(String typeKey, Function responder) {
473 responseFactory(null); 488 responder(null);
489 }
474 490
475 dynamic getAllTypeDefinitions([Function responseFactory]) => 491 void getAllTypeDefinitions(Function responder) {
476 responseFactory(null); 492 responder(null);
493 }
477 } 494 }
478 495
479 abstract class InputListener { 496 abstract class InputListener {
480 static const String serviceName = null; 497 static const String serviceName = null;
481 498
482 static service_describer.ServiceDescription _cachedServiceDescription; 499 static service_describer.ServiceDescription _cachedServiceDescription;
483 static service_describer.ServiceDescription get serviceDescription { 500 static service_describer.ServiceDescription get serviceDescription {
484 if (_cachedServiceDescription == null) { 501 if (_cachedServiceDescription == null) {
485 _cachedServiceDescription = new _InputListenerServiceDescription(); 502 _cachedServiceDescription = new _InputListenerServiceDescription();
486 } 503 }
487 return _cachedServiceDescription; 504 return _cachedServiceDescription;
488 } 505 }
489 506
490 static InputListenerProxy connectToService( 507 static InputListenerProxy connectToService(
491 bindings.ServiceConnector s, String url, [String serviceName]) { 508 bindings.ServiceConnector s, String url, [String serviceName]) {
492 InputListenerProxy p = new InputListenerProxy.unbound(); 509 InputListenerProxy p = new InputListenerProxy.unbound();
493 String name = serviceName ?? InputListener.serviceName; 510 String name = serviceName ?? InputListener.serviceName;
494 if ((name == null) || name.isEmpty) { 511 if ((name == null) || name.isEmpty) {
495 throw new core.MojoApiError( 512 throw new core.MojoApiError(
496 "If an interface has no ServiceName, then one must be provided."); 513 "If an interface has no ServiceName, then one must be provided.");
497 } 514 }
498 s.connectToService(url, p, name); 515 s.connectToService(url, p, name);
499 return p; 516 return p;
500 } 517 }
501 dynamic onEvent(input_events_mojom.Event event,[Function responseFactory = nul l]); 518 void onEvent(input_events_mojom.Event event,void callback(bool consumed));
502 } 519 }
503 520
504 abstract class InputListenerInterface 521 abstract class InputListenerInterface
505 implements bindings.MojoInterface<InputListener>, 522 implements bindings.MojoInterface<InputListener>,
506 InputListener { 523 InputListener {
507 factory InputListenerInterface([InputListener impl]) => 524 factory InputListenerInterface([InputListener impl]) =>
508 new InputListenerStub.unbound(impl); 525 new InputListenerStub.unbound(impl);
509 526
510 factory InputListenerInterface.fromEndpoint( 527 factory InputListenerInterface.fromEndpoint(
511 core.MojoMessagePipeEndpoint endpoint, 528 core.MojoMessagePipeEndpoint endpoint,
(...skipping 29 matching lines...) Expand all
541 558
542 void handleResponse(bindings.ServiceMessage message) { 559 void handleResponse(bindings.ServiceMessage message) {
543 switch (message.header.type) { 560 switch (message.header.type) {
544 case _inputListenerMethodOnEventName: 561 case _inputListenerMethodOnEventName:
545 var r = InputListenerOnEventResponseParams.deserialize( 562 var r = InputListenerOnEventResponseParams.deserialize(
546 message.payload); 563 message.payload);
547 if (!message.header.hasRequestId) { 564 if (!message.header.hasRequestId) {
548 proxyError("Expected a message with a valid request Id."); 565 proxyError("Expected a message with a valid request Id.");
549 return; 566 return;
550 } 567 }
551 Completer c = completerMap[message.header.requestId]; 568 Function callback = callbackMap[message.header.requestId];
552 if (c == null) { 569 if (callback == null) {
553 proxyError( 570 proxyError(
554 "Message had unknown request Id: ${message.header.requestId}"); 571 "Message had unknown request Id: ${message.header.requestId}");
555 return; 572 return;
556 } 573 }
557 completerMap.remove(message.header.requestId); 574 callbackMap.remove(message.header.requestId);
558 if (c.isCompleted) { 575 callback(r.consumed );
559 proxyError("Response completer already completed");
560 return;
561 }
562 c.complete(r);
563 break; 576 break;
564 default: 577 default:
565 proxyError("Unexpected message type: ${message.header.type}"); 578 proxyError("Unexpected message type: ${message.header.type}");
566 close(immediate: true); 579 close(immediate: true);
567 break; 580 break;
568 } 581 }
569 } 582 }
570 583
571 @override 584 @override
572 String toString() { 585 String toString() {
(...skipping 24 matching lines...) Expand all
597 return newMockedProxy; 610 return newMockedProxy;
598 } 611 }
599 612
600 static InputListenerProxy newFromEndpoint( 613 static InputListenerProxy newFromEndpoint(
601 core.MojoMessagePipeEndpoint endpoint) { 614 core.MojoMessagePipeEndpoint endpoint) {
602 assert(endpoint.setDescription("For InputListenerProxy")); 615 assert(endpoint.setDescription("For InputListenerProxy"));
603 return new InputListenerProxy.fromEndpoint(endpoint); 616 return new InputListenerProxy.fromEndpoint(endpoint);
604 } 617 }
605 618
606 619
607 dynamic onEvent(input_events_mojom.Event event,[Function responseFactory = nul l]) { 620 void onEvent(input_events_mojom.Event event,void callback(bool consumed)) {
608 if (impl != null) { 621 if (impl != null) {
609 return new Future(() => impl.onEvent(event,_InputListenerStubControl._inpu tListenerOnEventResponseParamsFactory)); 622 impl.onEvent(event,callback);
623 return;
610 } 624 }
611 var params = new _InputListenerOnEventParams(); 625 var params = new _InputListenerOnEventParams();
612 params.event = event; 626 params.event = event;
613 return ctrl.sendMessageWithRequestId( 627 ctrl.sendMessageWithRequestId(
614 params, 628 params,
615 _inputListenerMethodOnEventName, 629 _inputListenerMethodOnEventName,
616 -1, 630 -1,
617 bindings.MessageHeader.kMessageExpectsResponse); 631 bindings.MessageHeader.kMessageExpectsResponse,
632 callback);
618 } 633 }
619 } 634 }
620 635
621 class _InputListenerStubControl 636 class _InputListenerStubControl
622 extends bindings.StubMessageHandler 637 extends bindings.StubMessageHandler
623 implements bindings.StubControl<InputListener> { 638 implements bindings.StubControl<InputListener> {
624 InputListener _impl; 639 InputListener _impl;
625 640
626 _InputListenerStubControl.fromEndpoint( 641 _InputListenerStubControl.fromEndpoint(
627 core.MojoMessagePipeEndpoint endpoint, [InputListener impl]) 642 core.MojoMessagePipeEndpoint endpoint, [InputListener impl])
628 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 643 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
629 _impl = impl; 644 _impl = impl;
630 } 645 }
631 646
632 _InputListenerStubControl.fromHandle( 647 _InputListenerStubControl.fromHandle(
633 core.MojoHandle handle, [InputListener impl]) 648 core.MojoHandle handle, [InputListener impl])
634 : super.fromHandle(handle, autoBegin: impl != null) { 649 : super.fromHandle(handle, autoBegin: impl != null) {
635 _impl = impl; 650 _impl = impl;
636 } 651 }
637 652
638 _InputListenerStubControl.unbound([this._impl]) : super.unbound(); 653 _InputListenerStubControl.unbound([this._impl]) : super.unbound();
639 654
640 String get serviceName => InputListener.serviceName; 655 String get serviceName => InputListener.serviceName;
641 656
642 657
643 static InputListenerOnEventResponseParams _inputListenerOnEventResponseParamsF actory(bool consumed) { 658 Function _inputListenerOnEventResponseParamsResponder(
644 var result = new InputListenerOnEventResponseParams(); 659 int requestId) {
645 result.consumed = consumed; 660 return (bool consumed) {
646 return result; 661 var result = new InputListenerOnEventResponseParams();
662 result.consumed = consumed;
663 sendResponse(buildResponseWithId(
664 result,
665 _inputListenerMethodOnEventName,
666 requestId,
667 bindings.MessageHeader.kMessageIsResponse));
668 };
647 } 669 }
648 670
649 dynamic handleMessage(bindings.ServiceMessage message) { 671 void handleMessage(bindings.ServiceMessage message) {
650 if (bindings.ControlMessageHandler.isControlMessage(message)) { 672 if (bindings.ControlMessageHandler.isControlMessage(message)) {
651 return bindings.ControlMessageHandler.handleMessage(this, 673 bindings.ControlMessageHandler.handleMessage(
652 0, 674 this, 0, message);
653 message); 675 return;
654 } 676 }
655 if (_impl == null) { 677 if (_impl == null) {
656 throw new core.MojoApiError("$this has no implementation set"); 678 throw new core.MojoApiError("$this has no implementation set");
657 } 679 }
658 switch (message.header.type) { 680 switch (message.header.type) {
659 case _inputListenerMethodOnEventName: 681 case _inputListenerMethodOnEventName:
660 var params = _InputListenerOnEventParams.deserialize( 682 var params = _InputListenerOnEventParams.deserialize(
661 message.payload); 683 message.payload);
662 var response = _impl.onEvent(params.event,_inputListenerOnEventResponseP aramsFactory); 684 _impl.onEvent(params.event, _inputListenerOnEventResponseParamsResponder (message.header.requestId));
663 if (response is Future) {
664 return response.then((response) {
665 if (response != null) {
666 return buildResponseWithId(
667 response,
668 _inputListenerMethodOnEventName,
669 message.header.requestId,
670 bindings.MessageHeader.kMessageIsResponse);
671 }
672 });
673 } else if (response != null) {
674 return buildResponseWithId(
675 response,
676 _inputListenerMethodOnEventName,
677 message.header.requestId,
678 bindings.MessageHeader.kMessageIsResponse);
679 }
680 break; 685 break;
681 default: 686 default:
682 throw new bindings.MojoCodecError("Unexpected message name"); 687 throw new bindings.MojoCodecError("Unexpected message name");
683 break; 688 break;
684 } 689 }
685 return null;
686 } 690 }
687 691
688 InputListener get impl => _impl; 692 InputListener get impl => _impl;
689 set impl(InputListener d) { 693 set impl(InputListener d) {
690 if (d == null) { 694 if (d == null) {
691 throw new core.MojoApiError("$this: Cannot set a null implementation"); 695 throw new core.MojoApiError("$this: Cannot set a null implementation");
692 } 696 }
693 if (isBound && (_impl == null)) { 697 if (isBound && (_impl == null)) {
694 beginHandlingEvents(); 698 beginHandlingEvents();
695 } 699 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 core.MojoHandle handle, [InputListener impl]) 733 core.MojoHandle handle, [InputListener impl])
730 : super(new _InputListenerStubControl.fromHandle(handle, impl)); 734 : super(new _InputListenerStubControl.fromHandle(handle, impl));
731 735
732 static InputListenerStub newFromEndpoint( 736 static InputListenerStub newFromEndpoint(
733 core.MojoMessagePipeEndpoint endpoint) { 737 core.MojoMessagePipeEndpoint endpoint) {
734 assert(endpoint.setDescription("For InputListenerStub")); 738 assert(endpoint.setDescription("For InputListenerStub"));
735 return new InputListenerStub.fromEndpoint(endpoint); 739 return new InputListenerStub.fromEndpoint(endpoint);
736 } 740 }
737 741
738 742
739 dynamic onEvent(input_events_mojom.Event event,[Function responseFactory = nul l]) { 743 void onEvent(input_events_mojom.Event event,void callback(bool consumed)) {
740 return impl.onEvent(event,responseFactory); 744 return impl.onEvent(event,callback);
741 } 745 }
742 } 746 }
743 747
744 748
745 749
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698