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

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: Cleanup 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 // 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 : super.fromHandle(handle, autoBegin: impl != null) { 789 : super.fromHandle(handle, autoBegin: impl != null) {
762 _impl = impl; 790 _impl = impl;
763 } 791 }
764 792
765 _SpeechRecognizerListenerStubControl.unbound([this._impl]) : super.unbound(); 793 _SpeechRecognizerListenerStubControl.unbound([this._impl]) : super.unbound();
766 794
767 String get serviceName => SpeechRecognizerListener.serviceName; 795 String get serviceName => SpeechRecognizerListener.serviceName;
768 796
769 797
770 798
771 dynamic handleMessage(bindings.ServiceMessage message) { 799 void handleMessage(bindings.ServiceMessage message) {
772 if (bindings.ControlMessageHandler.isControlMessage(message)) { 800 if (bindings.ControlMessageHandler.isControlMessage(message)) {
773 return bindings.ControlMessageHandler.handleMessage(this, 801 bindings.ControlMessageHandler.handleMessage(
774 0, 802 this, 0, message);
775 message); 803 return;
776 } 804 }
777 if (_impl == null) { 805 if (_impl == null) {
778 throw new core.MojoApiError("$this has no implementation set"); 806 throw new core.MojoApiError("$this has no implementation set");
779 } 807 }
780 switch (message.header.type) { 808 switch (message.header.type) {
781 case _speechRecognizerListenerMethodOnRecognizerErrorName: 809 case _speechRecognizerListenerMethodOnRecognizerErrorName:
782 var params = _SpeechRecognizerListenerOnRecognizerErrorParams.deserializ e( 810 var params = _SpeechRecognizerListenerOnRecognizerErrorParams.deserializ e(
783 message.payload); 811 message.payload);
784 _impl.onRecognizerError(params.errorCode); 812 _impl.onRecognizerError(params.errorCode);
785 break; 813 break;
786 case _speechRecognizerListenerMethodOnResultsName: 814 case _speechRecognizerListenerMethodOnResultsName:
787 var params = _SpeechRecognizerListenerOnResultsParams.deserialize( 815 var params = _SpeechRecognizerListenerOnResultsParams.deserialize(
788 message.payload); 816 message.payload);
789 _impl.onResults(params.results, params.complete); 817 _impl.onResults(params.results, params.complete);
790 break; 818 break;
791 case _speechRecognizerListenerMethodOnSoundLevelChangedName: 819 case _speechRecognizerListenerMethodOnSoundLevelChangedName:
792 var params = _SpeechRecognizerListenerOnSoundLevelChangedParams.deserial ize( 820 var params = _SpeechRecognizerListenerOnSoundLevelChangedParams.deserial ize(
793 message.payload); 821 message.payload);
794 _impl.onSoundLevelChanged(params.rmsDb); 822 _impl.onSoundLevelChanged(params.rmsDb);
795 break; 823 break;
796 default: 824 default:
797 throw new bindings.MojoCodecError("Unexpected message name"); 825 throw new bindings.MojoCodecError("Unexpected message name");
798 break; 826 break;
799 } 827 }
800 return null;
801 } 828 }
802 829
803 SpeechRecognizerListener get impl => _impl; 830 SpeechRecognizerListener get impl => _impl;
804 set impl(SpeechRecognizerListener d) { 831 set impl(SpeechRecognizerListener d) {
805 if (d == null) { 832 if (d == null) {
806 throw new core.MojoApiError("$this: Cannot set a null implementation"); 833 throw new core.MojoApiError("$this: Cannot set a null implementation");
807 } 834 }
808 if (isBound && (_impl == null)) { 835 if (isBound && (_impl == null)) {
809 beginHandlingEvents(); 836 beginHandlingEvents();
810 } 837 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 } 886 }
860 void onSoundLevelChanged(double rmsDb) { 887 void onSoundLevelChanged(double rmsDb) {
861 return impl.onSoundLevelChanged(rmsDb); 888 return impl.onSoundLevelChanged(rmsDb);
862 } 889 }
863 } 890 }
864 891
865 const int _speechRecognizerServiceMethodListenName = 0; 892 const int _speechRecognizerServiceMethodListenName = 0;
866 const int _speechRecognizerServiceMethodStopListeningName = 1; 893 const int _speechRecognizerServiceMethodStopListeningName = 1;
867 894
868 class _SpeechRecognizerServiceServiceDescription implements service_describer.Se rviceDescription { 895 class _SpeechRecognizerServiceServiceDescription implements service_describer.Se rviceDescription {
869 dynamic getTopLevelInterface([Function responseFactory]) => 896 void getTopLevelInterface(Function responder) {
870 responseFactory(null); 897 responder(null);
898 }
871 899
872 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 900 void getTypeDefinition(String typeKey, Function responder) {
873 responseFactory(null); 901 responder(null);
902 }
874 903
875 dynamic getAllTypeDefinitions([Function responseFactory]) => 904 void getAllTypeDefinitions(Function responder) {
876 responseFactory(null); 905 responder(null);
906 }
877 } 907 }
878 908
879 abstract class SpeechRecognizerService { 909 abstract class SpeechRecognizerService {
880 static const String serviceName = "speech_recognizer::SpeechRecognizerService" ; 910 static const String serviceName = "speech_recognizer::SpeechRecognizerService" ;
881 911
882 static service_describer.ServiceDescription _cachedServiceDescription; 912 static service_describer.ServiceDescription _cachedServiceDescription;
883 static service_describer.ServiceDescription get serviceDescription { 913 static service_describer.ServiceDescription get serviceDescription {
884 if (_cachedServiceDescription == null) { 914 if (_cachedServiceDescription == null) {
885 _cachedServiceDescription = new _SpeechRecognizerServiceServiceDescription (); 915 _cachedServiceDescription = new _SpeechRecognizerServiceServiceDescription ();
886 } 916 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 : super.fromHandle(handle, autoBegin: impl != null) { 1060 : super.fromHandle(handle, autoBegin: impl != null) {
1031 _impl = impl; 1061 _impl = impl;
1032 } 1062 }
1033 1063
1034 _SpeechRecognizerServiceStubControl.unbound([this._impl]) : super.unbound(); 1064 _SpeechRecognizerServiceStubControl.unbound([this._impl]) : super.unbound();
1035 1065
1036 String get serviceName => SpeechRecognizerService.serviceName; 1066 String get serviceName => SpeechRecognizerService.serviceName;
1037 1067
1038 1068
1039 1069
1040 dynamic handleMessage(bindings.ServiceMessage message) { 1070 void handleMessage(bindings.ServiceMessage message) {
1041 if (bindings.ControlMessageHandler.isControlMessage(message)) { 1071 if (bindings.ControlMessageHandler.isControlMessage(message)) {
1042 return bindings.ControlMessageHandler.handleMessage(this, 1072 bindings.ControlMessageHandler.handleMessage(
1043 0, 1073 this, 0, message);
1044 message); 1074 return;
1045 } 1075 }
1046 if (_impl == null) { 1076 if (_impl == null) {
1047 throw new core.MojoApiError("$this has no implementation set"); 1077 throw new core.MojoApiError("$this has no implementation set");
1048 } 1078 }
1049 switch (message.header.type) { 1079 switch (message.header.type) {
1050 case _speechRecognizerServiceMethodListenName: 1080 case _speechRecognizerServiceMethodListenName:
1051 var params = _SpeechRecognizerServiceListenParams.deserialize( 1081 var params = _SpeechRecognizerServiceListenParams.deserialize(
1052 message.payload); 1082 message.payload);
1053 _impl.listen(params.listener); 1083 _impl.listen(params.listener);
1054 break; 1084 break;
1055 case _speechRecognizerServiceMethodStopListeningName: 1085 case _speechRecognizerServiceMethodStopListeningName:
1056 _impl.stopListening(); 1086 _impl.stopListening();
1057 break; 1087 break;
1058 default: 1088 default:
1059 throw new bindings.MojoCodecError("Unexpected message name"); 1089 throw new bindings.MojoCodecError("Unexpected message name");
1060 break; 1090 break;
1061 } 1091 }
1062 return null;
1063 } 1092 }
1064 1093
1065 SpeechRecognizerService get impl => _impl; 1094 SpeechRecognizerService get impl => _impl;
1066 set impl(SpeechRecognizerService d) { 1095 set impl(SpeechRecognizerService d) {
1067 if (d == null) { 1096 if (d == null) {
1068 throw new core.MojoApiError("$this: Cannot set a null implementation"); 1097 throw new core.MojoApiError("$this: Cannot set a null implementation");
1069 } 1098 }
1070 if (isBound && (_impl == null)) { 1099 if (isBound && (_impl == null)) {
1071 beginHandlingEvents(); 1100 beginHandlingEvents();
1072 } 1101 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 void listen(SpeechRecognizerListenerInterface listener) { 1145 void listen(SpeechRecognizerListenerInterface listener) {
1117 return impl.listen(listener); 1146 return impl.listen(listener);
1118 } 1147 }
1119 void stopListening() { 1148 void stopListening() {
1120 return impl.stopListening(); 1149 return impl.stopListening();
1121 } 1150 }
1122 } 1151 }
1123 1152
1124 1153
1125 1154
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698