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

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

Issue 1964193002: Dart: Refactors Proxies (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address comments 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 } 591 }
592 592
593 abstract class SpeechRecognizerListener { 593 abstract class SpeechRecognizerListener {
594 static const String serviceName = null; 594 static const String serviceName = null;
595 void onRecognizerError(Error errorCode); 595 void onRecognizerError(Error errorCode);
596 void onResults(List<UtteranceCandidate> results, bool complete); 596 void onResults(List<UtteranceCandidate> results, bool complete);
597 void onSoundLevelChanged(double rmsDb); 597 void onSoundLevelChanged(double rmsDb);
598 } 598 }
599 599
600 600
601 class _SpeechRecognizerListenerProxyImpl extends bindings.Proxy { 601 class _SpeechRecognizerListenerProxyControl extends bindings.ProxyMessageHandler
602 _SpeechRecognizerListenerProxyImpl.fromEndpoint( 602 implements bindings.ProxyControl {
603 _SpeechRecognizerListenerProxyControl.fromEndpoint(
603 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 604 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
604 605
605 _SpeechRecognizerListenerProxyImpl.fromHandle(core.MojoHandle handle) : 606 _SpeechRecognizerListenerProxyControl.fromHandle(
606 super.fromHandle(handle); 607 core.MojoHandle handle) : super.fromHandle(handle);
607 608
608 _SpeechRecognizerListenerProxyImpl.unbound() : super.unbound(); 609 _SpeechRecognizerListenerProxyControl.unbound() : super.unbound();
609
610 static _SpeechRecognizerListenerProxyImpl newFromEndpoint(
611 core.MojoMessagePipeEndpoint endpoint) {
612 assert(endpoint.setDescription("For _SpeechRecognizerListenerProxyImpl"));
613 return new _SpeechRecognizerListenerProxyImpl.fromEndpoint(endpoint);
614 }
615 610
616 service_describer.ServiceDescription get serviceDescription => 611 service_describer.ServiceDescription get serviceDescription =>
617 new _SpeechRecognizerListenerServiceDescription(); 612 new _SpeechRecognizerListenerServiceDescription();
618 613
614 String get serviceName => SpeechRecognizerListener.serviceName;
615
616 @override
619 void handleResponse(bindings.ServiceMessage message) { 617 void handleResponse(bindings.ServiceMessage message) {
620 switch (message.header.type) { 618 switch (message.header.type) {
621 default: 619 default:
622 proxyError("Unexpected message type: ${message.header.type}"); 620 proxyError("Unexpected message type: ${message.header.type}");
623 close(immediate: true); 621 close(immediate: true);
624 break; 622 break;
625 } 623 }
626 } 624 }
627 625
626 @override
628 String toString() { 627 String toString() {
629 var superString = super.toString(); 628 var superString = super.toString();
630 return "_SpeechRecognizerListenerProxyImpl($superString)"; 629 return "_SpeechRecognizerListenerProxyControl($superString)";
631 } 630 }
632 } 631 }
633 632
634 633
635 class _SpeechRecognizerListenerProxyCalls implements SpeechRecognizerListener { 634 class SpeechRecognizerListenerProxy extends bindings.Proxy
636 _SpeechRecognizerListenerProxyImpl _proxyImpl; 635 implements SpeechRecognizerListener {
636 SpeechRecognizerListenerProxy.fromEndpoint(
637 core.MojoMessagePipeEndpoint endpoint)
638 : super(new _SpeechRecognizerListenerProxyControl.fromEndpoint(endpoint));
637 639
638 _SpeechRecognizerListenerProxyCalls(this._proxyImpl); 640 SpeechRecognizerListenerProxy.fromHandle(core.MojoHandle handle)
639 void onRecognizerError(Error errorCode) { 641 : super(new _SpeechRecognizerListenerProxyControl.fromHandle(handle));
640 if (!_proxyImpl.isBound) {
641 _proxyImpl.proxyError("The Proxy is closed.");
642 return;
643 }
644 var params = new _SpeechRecognizerListenerOnRecognizerErrorParams();
645 params.errorCode = errorCode;
646 _proxyImpl.sendMessage(params, _speechRecognizerListenerMethodOnRecognizer ErrorName);
647 }
648 void onResults(List<UtteranceCandidate> results, bool complete) {
649 if (!_proxyImpl.isBound) {
650 _proxyImpl.proxyError("The Proxy is closed.");
651 return;
652 }
653 var params = new _SpeechRecognizerListenerOnResultsParams();
654 params.results = results;
655 params.complete = complete;
656 _proxyImpl.sendMessage(params, _speechRecognizerListenerMethodOnResultsNam e);
657 }
658 void onSoundLevelChanged(double rmsDb) {
659 if (!_proxyImpl.isBound) {
660 _proxyImpl.proxyError("The Proxy is closed.");
661 return;
662 }
663 var params = new _SpeechRecognizerListenerOnSoundLevelChangedParams();
664 params.rmsDb = rmsDb;
665 _proxyImpl.sendMessage(params, _speechRecognizerListenerMethodOnSoundLevel ChangedName);
666 }
667 }
668 642
643 SpeechRecognizerListenerProxy.unbound()
644 : super(new _SpeechRecognizerListenerProxyControl.unbound());
669 645
670 class SpeechRecognizerListenerProxy implements bindings.ProxyBase { 646 static SpeechRecognizerListenerProxy newFromEndpoint(
671 final bindings.Proxy impl; 647 core.MojoMessagePipeEndpoint endpoint) {
672 SpeechRecognizerListener ptr; 648 assert(endpoint.setDescription("For SpeechRecognizerListenerProxy"));
673 649 return new SpeechRecognizerListenerProxy.fromEndpoint(endpoint);
674 SpeechRecognizerListenerProxy(_SpeechRecognizerListenerProxyImpl proxyImpl) :
675 impl = proxyImpl,
676 ptr = new _SpeechRecognizerListenerProxyCalls(proxyImpl);
677
678 SpeechRecognizerListenerProxy.fromEndpoint(
679 core.MojoMessagePipeEndpoint endpoint) :
680 impl = new _SpeechRecognizerListenerProxyImpl.fromEndpoint(endpoint) {
681 ptr = new _SpeechRecognizerListenerProxyCalls(impl);
682 }
683
684 SpeechRecognizerListenerProxy.fromHandle(core.MojoHandle handle) :
685 impl = new _SpeechRecognizerListenerProxyImpl.fromHandle(handle) {
686 ptr = new _SpeechRecognizerListenerProxyCalls(impl);
687 }
688
689 SpeechRecognizerListenerProxy.unbound() :
690 impl = new _SpeechRecognizerListenerProxyImpl.unbound() {
691 ptr = new _SpeechRecognizerListenerProxyCalls(impl);
692 } 650 }
693 651
694 factory SpeechRecognizerListenerProxy.connectToService( 652 factory SpeechRecognizerListenerProxy.connectToService(
695 bindings.ServiceConnector s, String url, [String serviceName]) { 653 bindings.ServiceConnector s, String url, [String serviceName]) {
696 SpeechRecognizerListenerProxy p = new SpeechRecognizerListenerProxy.unbound( ); 654 SpeechRecognizerListenerProxy p = new SpeechRecognizerListenerProxy.unbound( );
697 s.connectToService(url, p, serviceName); 655 s.connectToService(url, p, serviceName);
698 return p; 656 return p;
699 } 657 }
700 658
701 static SpeechRecognizerListenerProxy newFromEndpoint( 659
702 core.MojoMessagePipeEndpoint endpoint) { 660 void onRecognizerError(Error errorCode) {
703 assert(endpoint.setDescription("For SpeechRecognizerListenerProxy")); 661 if (!ctrl.isBound) {
704 return new SpeechRecognizerListenerProxy.fromEndpoint(endpoint); 662 ctrl.proxyError("The Proxy is closed.");
663 return;
664 }
665 var params = new _SpeechRecognizerListenerOnRecognizerErrorParams();
666 params.errorCode = errorCode;
667 ctrl.sendMessage(params,
668 _speechRecognizerListenerMethodOnRecognizerErrorName);
705 } 669 }
706 670 void onResults(List<UtteranceCandidate> results, bool complete) {
707 String get serviceName => SpeechRecognizerListener.serviceName; 671 if (!ctrl.isBound) {
708 672 ctrl.proxyError("The Proxy is closed.");
709 Future close({bool immediate: false}) => impl.close(immediate: immediate); 673 return;
710 674 }
711 Future responseOrError(Future f) => impl.responseOrError(f); 675 var params = new _SpeechRecognizerListenerOnResultsParams();
712 676 params.results = results;
713 Future get errorFuture => impl.errorFuture; 677 params.complete = complete;
714 678 ctrl.sendMessage(params,
715 int get version => impl.version; 679 _speechRecognizerListenerMethodOnResultsName);
716
717 Future<int> queryVersion() => impl.queryVersion();
718
719 void requireVersion(int requiredVersion) {
720 impl.requireVersion(requiredVersion);
721 } 680 }
722 681 void onSoundLevelChanged(double rmsDb) {
723 String toString() { 682 if (!ctrl.isBound) {
724 return "SpeechRecognizerListenerProxy($impl)"; 683 ctrl.proxyError("The Proxy is closed.");
684 return;
685 }
686 var params = new _SpeechRecognizerListenerOnSoundLevelChangedParams();
687 params.rmsDb = rmsDb;
688 ctrl.sendMessage(params,
689 _speechRecognizerListenerMethodOnSoundLevelChangedName);
725 } 690 }
726 } 691 }
727 692
728 693
729 class SpeechRecognizerListenerStub extends bindings.Stub { 694 class SpeechRecognizerListenerStub extends bindings.Stub {
730 SpeechRecognizerListener _impl; 695 SpeechRecognizerListener _impl;
731 696
732 SpeechRecognizerListenerStub.fromEndpoint( 697 SpeechRecognizerListenerStub.fromEndpoint(
733 core.MojoMessagePipeEndpoint endpoint, [SpeechRecognizerListener impl]) 698 core.MojoMessagePipeEndpoint endpoint, [SpeechRecognizerListener impl])
734 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 699 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 responseFactory(null); 797 responseFactory(null);
833 } 798 }
834 799
835 abstract class SpeechRecognizerService { 800 abstract class SpeechRecognizerService {
836 static const String serviceName = "speech_recognizer::SpeechRecognizerService" ; 801 static const String serviceName = "speech_recognizer::SpeechRecognizerService" ;
837 void listen(Object listener); 802 void listen(Object listener);
838 void stopListening(); 803 void stopListening();
839 } 804 }
840 805
841 806
842 class _SpeechRecognizerServiceProxyImpl extends bindings.Proxy { 807 class _SpeechRecognizerServiceProxyControl extends bindings.ProxyMessageHandler
843 _SpeechRecognizerServiceProxyImpl.fromEndpoint( 808 implements bindings.ProxyControl {
809 _SpeechRecognizerServiceProxyControl.fromEndpoint(
844 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 810 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
845 811
846 _SpeechRecognizerServiceProxyImpl.fromHandle(core.MojoHandle handle) : 812 _SpeechRecognizerServiceProxyControl.fromHandle(
847 super.fromHandle(handle); 813 core.MojoHandle handle) : super.fromHandle(handle);
848 814
849 _SpeechRecognizerServiceProxyImpl.unbound() : super.unbound(); 815 _SpeechRecognizerServiceProxyControl.unbound() : super.unbound();
850
851 static _SpeechRecognizerServiceProxyImpl newFromEndpoint(
852 core.MojoMessagePipeEndpoint endpoint) {
853 assert(endpoint.setDescription("For _SpeechRecognizerServiceProxyImpl"));
854 return new _SpeechRecognizerServiceProxyImpl.fromEndpoint(endpoint);
855 }
856 816
857 service_describer.ServiceDescription get serviceDescription => 817 service_describer.ServiceDescription get serviceDescription =>
858 new _SpeechRecognizerServiceServiceDescription(); 818 new _SpeechRecognizerServiceServiceDescription();
859 819
820 String get serviceName => SpeechRecognizerService.serviceName;
821
822 @override
860 void handleResponse(bindings.ServiceMessage message) { 823 void handleResponse(bindings.ServiceMessage message) {
861 switch (message.header.type) { 824 switch (message.header.type) {
862 default: 825 default:
863 proxyError("Unexpected message type: ${message.header.type}"); 826 proxyError("Unexpected message type: ${message.header.type}");
864 close(immediate: true); 827 close(immediate: true);
865 break; 828 break;
866 } 829 }
867 } 830 }
868 831
832 @override
869 String toString() { 833 String toString() {
870 var superString = super.toString(); 834 var superString = super.toString();
871 return "_SpeechRecognizerServiceProxyImpl($superString)"; 835 return "_SpeechRecognizerServiceProxyControl($superString)";
872 } 836 }
873 } 837 }
874 838
875 839
876 class _SpeechRecognizerServiceProxyCalls implements SpeechRecognizerService { 840 class SpeechRecognizerServiceProxy extends bindings.Proxy
877 _SpeechRecognizerServiceProxyImpl _proxyImpl; 841 implements SpeechRecognizerService {
842 SpeechRecognizerServiceProxy.fromEndpoint(
843 core.MojoMessagePipeEndpoint endpoint)
844 : super(new _SpeechRecognizerServiceProxyControl.fromEndpoint(endpoint));
878 845
879 _SpeechRecognizerServiceProxyCalls(this._proxyImpl); 846 SpeechRecognizerServiceProxy.fromHandle(core.MojoHandle handle)
880 void listen(Object listener) { 847 : super(new _SpeechRecognizerServiceProxyControl.fromHandle(handle));
881 if (!_proxyImpl.isBound) {
882 _proxyImpl.proxyError("The Proxy is closed.");
883 return;
884 }
885 var params = new _SpeechRecognizerServiceListenParams();
886 params.listener = listener;
887 _proxyImpl.sendMessage(params, _speechRecognizerServiceMethodListenName);
888 }
889 void stopListening() {
890 if (!_proxyImpl.isBound) {
891 _proxyImpl.proxyError("The Proxy is closed.");
892 return;
893 }
894 var params = new _SpeechRecognizerServiceStopListeningParams();
895 _proxyImpl.sendMessage(params, _speechRecognizerServiceMethodStopListening Name);
896 }
897 }
898 848
849 SpeechRecognizerServiceProxy.unbound()
850 : super(new _SpeechRecognizerServiceProxyControl.unbound());
899 851
900 class SpeechRecognizerServiceProxy implements bindings.ProxyBase { 852 static SpeechRecognizerServiceProxy newFromEndpoint(
901 final bindings.Proxy impl; 853 core.MojoMessagePipeEndpoint endpoint) {
902 SpeechRecognizerService ptr; 854 assert(endpoint.setDescription("For SpeechRecognizerServiceProxy"));
903 855 return new SpeechRecognizerServiceProxy.fromEndpoint(endpoint);
904 SpeechRecognizerServiceProxy(_SpeechRecognizerServiceProxyImpl proxyImpl) :
905 impl = proxyImpl,
906 ptr = new _SpeechRecognizerServiceProxyCalls(proxyImpl);
907
908 SpeechRecognizerServiceProxy.fromEndpoint(
909 core.MojoMessagePipeEndpoint endpoint) :
910 impl = new _SpeechRecognizerServiceProxyImpl.fromEndpoint(endpoint) {
911 ptr = new _SpeechRecognizerServiceProxyCalls(impl);
912 }
913
914 SpeechRecognizerServiceProxy.fromHandle(core.MojoHandle handle) :
915 impl = new _SpeechRecognizerServiceProxyImpl.fromHandle(handle) {
916 ptr = new _SpeechRecognizerServiceProxyCalls(impl);
917 }
918
919 SpeechRecognizerServiceProxy.unbound() :
920 impl = new _SpeechRecognizerServiceProxyImpl.unbound() {
921 ptr = new _SpeechRecognizerServiceProxyCalls(impl);
922 } 856 }
923 857
924 factory SpeechRecognizerServiceProxy.connectToService( 858 factory SpeechRecognizerServiceProxy.connectToService(
925 bindings.ServiceConnector s, String url, [String serviceName]) { 859 bindings.ServiceConnector s, String url, [String serviceName]) {
926 SpeechRecognizerServiceProxy p = new SpeechRecognizerServiceProxy.unbound(); 860 SpeechRecognizerServiceProxy p = new SpeechRecognizerServiceProxy.unbound();
927 s.connectToService(url, p, serviceName); 861 s.connectToService(url, p, serviceName);
928 return p; 862 return p;
929 } 863 }
930 864
931 static SpeechRecognizerServiceProxy newFromEndpoint( 865
932 core.MojoMessagePipeEndpoint endpoint) { 866 void listen(Object listener) {
933 assert(endpoint.setDescription("For SpeechRecognizerServiceProxy")); 867 if (!ctrl.isBound) {
934 return new SpeechRecognizerServiceProxy.fromEndpoint(endpoint); 868 ctrl.proxyError("The Proxy is closed.");
869 return;
870 }
871 var params = new _SpeechRecognizerServiceListenParams();
872 params.listener = listener;
873 ctrl.sendMessage(params,
874 _speechRecognizerServiceMethodListenName);
935 } 875 }
936 876 void stopListening() {
937 String get serviceName => SpeechRecognizerService.serviceName; 877 if (!ctrl.isBound) {
938 878 ctrl.proxyError("The Proxy is closed.");
939 Future close({bool immediate: false}) => impl.close(immediate: immediate); 879 return;
940 880 }
941 Future responseOrError(Future f) => impl.responseOrError(f); 881 var params = new _SpeechRecognizerServiceStopListeningParams();
942 882 ctrl.sendMessage(params,
943 Future get errorFuture => impl.errorFuture; 883 _speechRecognizerServiceMethodStopListeningName);
944
945 int get version => impl.version;
946
947 Future<int> queryVersion() => impl.queryVersion();
948
949 void requireVersion(int requiredVersion) {
950 impl.requireVersion(requiredVersion);
951 }
952
953 String toString() {
954 return "SpeechRecognizerServiceProxy($impl)";
955 } 884 }
956 } 885 }
957 886
958 887
959 class SpeechRecognizerServiceStub extends bindings.Stub { 888 class SpeechRecognizerServiceStub extends bindings.Stub {
960 SpeechRecognizerService _impl; 889 SpeechRecognizerService _impl;
961 890
962 SpeechRecognizerServiceStub.fromEndpoint( 891 SpeechRecognizerServiceStub.fromEndpoint(
963 core.MojoMessagePipeEndpoint endpoint, [SpeechRecognizerService impl]) 892 core.MojoMessagePipeEndpoint endpoint, [SpeechRecognizerService impl])
964 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 893 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 static service_describer.ServiceDescription get serviceDescription { 965 static service_describer.ServiceDescription get serviceDescription {
1037 if (_cachedServiceDescription == null) { 966 if (_cachedServiceDescription == null) {
1038 _cachedServiceDescription = new _SpeechRecognizerServiceServiceDescription (); 967 _cachedServiceDescription = new _SpeechRecognizerServiceServiceDescription ();
1039 } 968 }
1040 return _cachedServiceDescription; 969 return _cachedServiceDescription;
1041 } 970 }
1042 } 971 }
1043 972
1044 973
1045 974
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698