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

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

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Move code from mojo_patch to proxy.dart 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 speech_recognizer_mojom; 5 library speech_recognizer_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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 class UtteranceCandidate extends bindings.Struct { 114 class UtteranceCandidate extends bindings.Struct {
115 static const List<bindings.StructDataHeader> kVersions = const [ 115 static const List<bindings.StructDataHeader> kVersions = const [
116 const bindings.StructDataHeader(24, 0) 116 const bindings.StructDataHeader(24, 0)
117 ]; 117 ];
118 String text = null; 118 String text = null;
119 double confidenceScore = 0.0; 119 double confidenceScore = 0.0;
120 120
121 UtteranceCandidate() : super(kVersions.last.size); 121 UtteranceCandidate() : super(kVersions.last.size);
122 122
123 UtteranceCandidate.init(
124 String this.text,
125 double this.confidenceScore
126 ) : super(kVersions.last.size);
127
123 static UtteranceCandidate deserialize(bindings.Message message) { 128 static UtteranceCandidate deserialize(bindings.Message message) {
124 var decoder = new bindings.Decoder(message); 129 var decoder = new bindings.Decoder(message);
125 var result = decode(decoder); 130 var result = decode(decoder);
126 if (decoder.excessHandles != null) { 131 if (decoder.excessHandles != null) {
127 decoder.excessHandles.forEach((h) => h.close()); 132 decoder.excessHandles.forEach((h) => h.close());
128 } 133 }
129 return result; 134 return result;
130 } 135 }
131 136
132 static UtteranceCandidate decode(bindings.Decoder decoder0) { 137 static UtteranceCandidate decode(bindings.Decoder decoder0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 203
199 204
200 class _SpeechRecognizerListenerOnRecognizerErrorParams extends bindings.Struct { 205 class _SpeechRecognizerListenerOnRecognizerErrorParams extends bindings.Struct {
201 static const List<bindings.StructDataHeader> kVersions = const [ 206 static const List<bindings.StructDataHeader> kVersions = const [
202 const bindings.StructDataHeader(16, 0) 207 const bindings.StructDataHeader(16, 0)
203 ]; 208 ];
204 Error errorCode = null; 209 Error errorCode = null;
205 210
206 _SpeechRecognizerListenerOnRecognizerErrorParams() : super(kVersions.last.size ); 211 _SpeechRecognizerListenerOnRecognizerErrorParams() : super(kVersions.last.size );
207 212
213 _SpeechRecognizerListenerOnRecognizerErrorParams.init(
214 Error this.errorCode
215 ) : super(kVersions.last.size);
216
208 static _SpeechRecognizerListenerOnRecognizerErrorParams deserialize(bindings.M essage message) { 217 static _SpeechRecognizerListenerOnRecognizerErrorParams deserialize(bindings.M essage message) {
209 var decoder = new bindings.Decoder(message); 218 var decoder = new bindings.Decoder(message);
210 var result = decode(decoder); 219 var result = decode(decoder);
211 if (decoder.excessHandles != null) { 220 if (decoder.excessHandles != null) {
212 decoder.excessHandles.forEach((h) => h.close()); 221 decoder.excessHandles.forEach((h) => h.close());
213 } 222 }
214 return result; 223 return result;
215 } 224 }
216 225
217 static _SpeechRecognizerListenerOnRecognizerErrorParams decode(bindings.Decode r decoder0) { 226 static _SpeechRecognizerListenerOnRecognizerErrorParams decode(bindings.Decode r decoder0) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 284
276 class _SpeechRecognizerListenerOnResultsParams extends bindings.Struct { 285 class _SpeechRecognizerListenerOnResultsParams extends bindings.Struct {
277 static const List<bindings.StructDataHeader> kVersions = const [ 286 static const List<bindings.StructDataHeader> kVersions = const [
278 const bindings.StructDataHeader(24, 0) 287 const bindings.StructDataHeader(24, 0)
279 ]; 288 ];
280 List<UtteranceCandidate> results = null; 289 List<UtteranceCandidate> results = null;
281 bool complete = false; 290 bool complete = false;
282 291
283 _SpeechRecognizerListenerOnResultsParams() : super(kVersions.last.size); 292 _SpeechRecognizerListenerOnResultsParams() : super(kVersions.last.size);
284 293
294 _SpeechRecognizerListenerOnResultsParams.init(
295 List<UtteranceCandidate> this.results,
296 bool this.complete
297 ) : super(kVersions.last.size);
298
285 static _SpeechRecognizerListenerOnResultsParams deserialize(bindings.Message m essage) { 299 static _SpeechRecognizerListenerOnResultsParams deserialize(bindings.Message m essage) {
286 var decoder = new bindings.Decoder(message); 300 var decoder = new bindings.Decoder(message);
287 var result = decode(decoder); 301 var result = decode(decoder);
288 if (decoder.excessHandles != null) { 302 if (decoder.excessHandles != null) {
289 decoder.excessHandles.forEach((h) => h.close()); 303 decoder.excessHandles.forEach((h) => h.close());
290 } 304 }
291 return result; 305 return result;
292 } 306 }
293 307
294 static _SpeechRecognizerListenerOnResultsParams decode(bindings.Decoder decode r0) { 308 static _SpeechRecognizerListenerOnResultsParams decode(bindings.Decoder decode r0) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 390
377 391
378 class _SpeechRecognizerListenerOnSoundLevelChangedParams extends bindings.Struct { 392 class _SpeechRecognizerListenerOnSoundLevelChangedParams extends bindings.Struct {
379 static const List<bindings.StructDataHeader> kVersions = const [ 393 static const List<bindings.StructDataHeader> kVersions = const [
380 const bindings.StructDataHeader(16, 0) 394 const bindings.StructDataHeader(16, 0)
381 ]; 395 ];
382 double rmsDb = 0.0; 396 double rmsDb = 0.0;
383 397
384 _SpeechRecognizerListenerOnSoundLevelChangedParams() : super(kVersions.last.si ze); 398 _SpeechRecognizerListenerOnSoundLevelChangedParams() : super(kVersions.last.si ze);
385 399
400 _SpeechRecognizerListenerOnSoundLevelChangedParams.init(
401 double this.rmsDb
402 ) : super(kVersions.last.size);
403
386 static _SpeechRecognizerListenerOnSoundLevelChangedParams deserialize(bindings .Message message) { 404 static _SpeechRecognizerListenerOnSoundLevelChangedParams deserialize(bindings .Message message) {
387 var decoder = new bindings.Decoder(message); 405 var decoder = new bindings.Decoder(message);
388 var result = decode(decoder); 406 var result = decode(decoder);
389 if (decoder.excessHandles != null) { 407 if (decoder.excessHandles != null) {
390 decoder.excessHandles.forEach((h) => h.close()); 408 decoder.excessHandles.forEach((h) => h.close());
391 } 409 }
392 return result; 410 return result;
393 } 411 }
394 412
395 static _SpeechRecognizerListenerOnSoundLevelChangedParams decode(bindings.Deco der decoder0) { 413 static _SpeechRecognizerListenerOnSoundLevelChangedParams decode(bindings.Deco der decoder0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 466
449 467
450 class _SpeechRecognizerServiceListenParams extends bindings.Struct { 468 class _SpeechRecognizerServiceListenParams extends bindings.Struct {
451 static const List<bindings.StructDataHeader> kVersions = const [ 469 static const List<bindings.StructDataHeader> kVersions = const [
452 const bindings.StructDataHeader(16, 0) 470 const bindings.StructDataHeader(16, 0)
453 ]; 471 ];
454 SpeechRecognizerListenerInterface listener = null; 472 SpeechRecognizerListenerInterface listener = null;
455 473
456 _SpeechRecognizerServiceListenParams() : super(kVersions.last.size); 474 _SpeechRecognizerServiceListenParams() : super(kVersions.last.size);
457 475
476 _SpeechRecognizerServiceListenParams.init(
477 SpeechRecognizerListenerInterface this.listener
478 ) : super(kVersions.last.size);
479
458 static _SpeechRecognizerServiceListenParams deserialize(bindings.Message messa ge) { 480 static _SpeechRecognizerServiceListenParams deserialize(bindings.Message messa ge) {
459 var decoder = new bindings.Decoder(message); 481 var decoder = new bindings.Decoder(message);
460 var result = decode(decoder); 482 var result = decode(decoder);
461 if (decoder.excessHandles != null) { 483 if (decoder.excessHandles != null) {
462 decoder.excessHandles.forEach((h) => h.close()); 484 decoder.excessHandles.forEach((h) => h.close());
463 } 485 }
464 return result; 486 return result;
465 } 487 }
466 488
467 static _SpeechRecognizerServiceListenParams decode(bindings.Decoder decoder0) { 489 static _SpeechRecognizerServiceListenParams decode(bindings.Decoder decoder0) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 540 }
519 541
520 542
521 class _SpeechRecognizerServiceStopListeningParams extends bindings.Struct { 543 class _SpeechRecognizerServiceStopListeningParams extends bindings.Struct {
522 static const List<bindings.StructDataHeader> kVersions = const [ 544 static const List<bindings.StructDataHeader> kVersions = const [
523 const bindings.StructDataHeader(8, 0) 545 const bindings.StructDataHeader(8, 0)
524 ]; 546 ];
525 547
526 _SpeechRecognizerServiceStopListeningParams() : super(kVersions.last.size); 548 _SpeechRecognizerServiceStopListeningParams() : super(kVersions.last.size);
527 549
550 _SpeechRecognizerServiceStopListeningParams.init(
551 ) : super(kVersions.last.size);
552
528 static _SpeechRecognizerServiceStopListeningParams deserialize(bindings.Messag e message) { 553 static _SpeechRecognizerServiceStopListeningParams deserialize(bindings.Messag e message) {
529 var decoder = new bindings.Decoder(message); 554 var decoder = new bindings.Decoder(message);
530 var result = decode(decoder); 555 var result = decode(decoder);
531 if (decoder.excessHandles != null) { 556 if (decoder.excessHandles != null) {
532 decoder.excessHandles.forEach((h) => h.close()); 557 decoder.excessHandles.forEach((h) => h.close());
533 } 558 }
534 return result; 559 return result;
535 } 560 }
536 561
537 static _SpeechRecognizerServiceStopListeningParams decode(bindings.Decoder dec oder0) { 562 static _SpeechRecognizerServiceStopListeningParams decode(bindings.Decoder dec oder0) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 Map map = new Map(); 598 Map map = new Map();
574 return map; 599 return map;
575 } 600 }
576 } 601 }
577 602
578 const int _speechRecognizerListenerMethodOnRecognizerErrorName = 0; 603 const int _speechRecognizerListenerMethodOnRecognizerErrorName = 0;
579 const int _speechRecognizerListenerMethodOnResultsName = 1; 604 const int _speechRecognizerListenerMethodOnResultsName = 1;
580 const int _speechRecognizerListenerMethodOnSoundLevelChangedName = 2; 605 const int _speechRecognizerListenerMethodOnSoundLevelChangedName = 2;
581 606
582 class _SpeechRecognizerListenerServiceDescription implements service_describer.S erviceDescription { 607 class _SpeechRecognizerListenerServiceDescription implements service_describer.S erviceDescription {
583 dynamic getTopLevelInterface([Function responseFactory]) => 608 void getTopLevelInterface(Function responder) {
584 responseFactory(null); 609 responder(null);
610 }
585 611
586 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 612 void getTypeDefinition(String typeKey, Function responder) {
587 responseFactory(null); 613 responder(null);
614 }
588 615
589 dynamic getAllTypeDefinitions([Function responseFactory]) => 616 void getAllTypeDefinitions(Function responder) {
590 responseFactory(null); 617 responder(null);
618 }
591 } 619 }
592 620
593 abstract class SpeechRecognizerListener { 621 abstract class SpeechRecognizerListener {
594 static const String serviceName = null; 622 static const String serviceName = null;
595 623
596 static service_describer.ServiceDescription _cachedServiceDescription; 624 static service_describer.ServiceDescription _cachedServiceDescription;
597 static service_describer.ServiceDescription get serviceDescription { 625 static service_describer.ServiceDescription get serviceDescription {
598 if (_cachedServiceDescription == null) { 626 if (_cachedServiceDescription == null) {
599 _cachedServiceDescription = new _SpeechRecognizerListenerServiceDescriptio n(); 627 _cachedServiceDescription = new _SpeechRecognizerListenerServiceDescriptio n();
600 } 628 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 : super.fromHandle(handle, autoBegin: impl != null) { 768 : super.fromHandle(handle, autoBegin: impl != null) {
741 _impl = impl; 769 _impl = impl;
742 } 770 }
743 771
744 _SpeechRecognizerListenerStubControl.unbound([this._impl]) : super.unbound(); 772 _SpeechRecognizerListenerStubControl.unbound([this._impl]) : super.unbound();
745 773
746 String get serviceName => SpeechRecognizerListener.serviceName; 774 String get serviceName => SpeechRecognizerListener.serviceName;
747 775
748 776
749 777
750 dynamic handleMessage(bindings.ServiceMessage message) { 778 void handleMessage(bindings.ServiceMessage message) {
751 if (bindings.ControlMessageHandler.isControlMessage(message)) { 779 if (bindings.ControlMessageHandler.isControlMessage(message)) {
752 return bindings.ControlMessageHandler.handleMessage(this, 780 bindings.ControlMessageHandler.handleMessage(
753 0, 781 this, 0, message);
754 message); 782 return;
755 } 783 }
756 if (_impl == null) { 784 if (_impl == null) {
757 throw new core.MojoApiError("$this has no implementation set"); 785 throw new core.MojoApiError("$this has no implementation set");
758 } 786 }
759 switch (message.header.type) { 787 switch (message.header.type) {
760 case _speechRecognizerListenerMethodOnRecognizerErrorName: 788 case _speechRecognizerListenerMethodOnRecognizerErrorName:
761 var params = _SpeechRecognizerListenerOnRecognizerErrorParams.deserializ e( 789 var params = _SpeechRecognizerListenerOnRecognizerErrorParams.deserializ e(
762 message.payload); 790 message.payload);
763 _impl.onRecognizerError(params.errorCode); 791 _impl.onRecognizerError(params.errorCode);
764 break; 792 break;
765 case _speechRecognizerListenerMethodOnResultsName: 793 case _speechRecognizerListenerMethodOnResultsName:
766 var params = _SpeechRecognizerListenerOnResultsParams.deserialize( 794 var params = _SpeechRecognizerListenerOnResultsParams.deserialize(
767 message.payload); 795 message.payload);
768 _impl.onResults(params.results, params.complete); 796 _impl.onResults(params.results, params.complete);
769 break; 797 break;
770 case _speechRecognizerListenerMethodOnSoundLevelChangedName: 798 case _speechRecognizerListenerMethodOnSoundLevelChangedName:
771 var params = _SpeechRecognizerListenerOnSoundLevelChangedParams.deserial ize( 799 var params = _SpeechRecognizerListenerOnSoundLevelChangedParams.deserial ize(
772 message.payload); 800 message.payload);
773 _impl.onSoundLevelChanged(params.rmsDb); 801 _impl.onSoundLevelChanged(params.rmsDb);
774 break; 802 break;
775 default: 803 default:
776 throw new bindings.MojoCodecError("Unexpected message name"); 804 throw new bindings.MojoCodecError("Unexpected message name");
777 break; 805 break;
778 } 806 }
779 return null;
780 } 807 }
781 808
782 SpeechRecognizerListener get impl => _impl; 809 SpeechRecognizerListener get impl => _impl;
783 set impl(SpeechRecognizerListener d) { 810 set impl(SpeechRecognizerListener d) {
784 if (d == null) { 811 if (d == null) {
785 throw new core.MojoApiError("$this: Cannot set a null implementation"); 812 throw new core.MojoApiError("$this: Cannot set a null implementation");
786 } 813 }
787 if (isBound && (_impl == null)) { 814 if (isBound && (_impl == null)) {
788 beginHandlingEvents(); 815 beginHandlingEvents();
789 } 816 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } 865 }
839 void onSoundLevelChanged(double rmsDb) { 866 void onSoundLevelChanged(double rmsDb) {
840 return impl.onSoundLevelChanged(rmsDb); 867 return impl.onSoundLevelChanged(rmsDb);
841 } 868 }
842 } 869 }
843 870
844 const int _speechRecognizerServiceMethodListenName = 0; 871 const int _speechRecognizerServiceMethodListenName = 0;
845 const int _speechRecognizerServiceMethodStopListeningName = 1; 872 const int _speechRecognizerServiceMethodStopListeningName = 1;
846 873
847 class _SpeechRecognizerServiceServiceDescription implements service_describer.Se rviceDescription { 874 class _SpeechRecognizerServiceServiceDescription implements service_describer.Se rviceDescription {
848 dynamic getTopLevelInterface([Function responseFactory]) => 875 void getTopLevelInterface(Function responder) {
849 responseFactory(null); 876 responder(null);
877 }
850 878
851 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 879 void getTypeDefinition(String typeKey, Function responder) {
852 responseFactory(null); 880 responder(null);
881 }
853 882
854 dynamic getAllTypeDefinitions([Function responseFactory]) => 883 void getAllTypeDefinitions(Function responder) {
855 responseFactory(null); 884 responder(null);
885 }
856 } 886 }
857 887
858 abstract class SpeechRecognizerService { 888 abstract class SpeechRecognizerService {
859 static const String serviceName = "speech_recognizer::SpeechRecognizerService" ; 889 static const String serviceName = "speech_recognizer::SpeechRecognizerService" ;
860 890
861 static service_describer.ServiceDescription _cachedServiceDescription; 891 static service_describer.ServiceDescription _cachedServiceDescription;
862 static service_describer.ServiceDescription get serviceDescription { 892 static service_describer.ServiceDescription get serviceDescription {
863 if (_cachedServiceDescription == null) { 893 if (_cachedServiceDescription == null) {
864 _cachedServiceDescription = new _SpeechRecognizerServiceServiceDescription (); 894 _cachedServiceDescription = new _SpeechRecognizerServiceServiceDescription ();
865 } 895 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 : super.fromHandle(handle, autoBegin: impl != null) { 1022 : super.fromHandle(handle, autoBegin: impl != null) {
993 _impl = impl; 1023 _impl = impl;
994 } 1024 }
995 1025
996 _SpeechRecognizerServiceStubControl.unbound([this._impl]) : super.unbound(); 1026 _SpeechRecognizerServiceStubControl.unbound([this._impl]) : super.unbound();
997 1027
998 String get serviceName => SpeechRecognizerService.serviceName; 1028 String get serviceName => SpeechRecognizerService.serviceName;
999 1029
1000 1030
1001 1031
1002 dynamic handleMessage(bindings.ServiceMessage message) { 1032 void handleMessage(bindings.ServiceMessage message) {
1003 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1033 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1004 return bindings.ControlMessageHandler.handleMessage(this, 1034 bindings.ControlMessageHandler.handleMessage(
1005 0, 1035 this, 0, message);
1006 message); 1036 return;
1007 } 1037 }
1008 if (_impl == null) { 1038 if (_impl == null) {
1009 throw new core.MojoApiError("$this has no implementation set"); 1039 throw new core.MojoApiError("$this has no implementation set");
1010 } 1040 }
1011 switch (message.header.type) { 1041 switch (message.header.type) {
1012 case _speechRecognizerServiceMethodListenName: 1042 case _speechRecognizerServiceMethodListenName:
1013 var params = _SpeechRecognizerServiceListenParams.deserialize( 1043 var params = _SpeechRecognizerServiceListenParams.deserialize(
1014 message.payload); 1044 message.payload);
1015 _impl.listen(params.listener); 1045 _impl.listen(params.listener);
1016 break; 1046 break;
1017 case _speechRecognizerServiceMethodStopListeningName: 1047 case _speechRecognizerServiceMethodStopListeningName:
1018 _impl.stopListening(); 1048 _impl.stopListening();
1019 break; 1049 break;
1020 default: 1050 default:
1021 throw new bindings.MojoCodecError("Unexpected message name"); 1051 throw new bindings.MojoCodecError("Unexpected message name");
1022 break; 1052 break;
1023 } 1053 }
1024 return null;
1025 } 1054 }
1026 1055
1027 SpeechRecognizerService get impl => _impl; 1056 SpeechRecognizerService get impl => _impl;
1028 set impl(SpeechRecognizerService d) { 1057 set impl(SpeechRecognizerService d) {
1029 if (d == null) { 1058 if (d == null) {
1030 throw new core.MojoApiError("$this: Cannot set a null implementation"); 1059 throw new core.MojoApiError("$this: Cannot set a null implementation");
1031 } 1060 }
1032 if (isBound && (_impl == null)) { 1061 if (isBound && (_impl == null)) {
1033 beginHandlingEvents(); 1062 beginHandlingEvents();
1034 } 1063 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 void listen(SpeechRecognizerListenerInterface listener) { 1107 void listen(SpeechRecognizerListenerInterface listener) {
1079 return impl.listen(listener); 1108 return impl.listen(listener);
1080 } 1109 }
1081 void stopListening() { 1110 void stopListening() {
1082 return impl.stopListening(); 1111 return impl.stopListening();
1083 } 1112 }
1084 } 1113 }
1085 1114
1086 1115
1087 1116
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698