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 process_mojom; | 5 library process_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 import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; | 10 import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; |
11 import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; | 11 import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; |
12 | 12 |
13 | 13 |
14 | 14 |
15 class _ProcessSpawnParams extends bindings.Struct { | 15 class _ProcessSpawnParams extends bindings.Struct { |
16 static const List<bindings.StructDataHeader> kVersions = const [ | 16 static const List<bindings.StructDataHeader> kVersions = const [ |
17 const bindings.StructDataHeader(64, 0) | 17 const bindings.StructDataHeader(64, 0) |
18 ]; | 18 ]; |
19 List<int> path = null; | 19 List<int> path = null; |
20 List<List<int>> argv = null; | 20 List<List<int>> argv = null; |
21 List<List<int>> envp = null; | 21 List<List<int>> envp = null; |
22 file_mojom.FileInterface stdinFile = null; | 22 file_mojom.FileInterface stdinFile = null; |
23 file_mojom.FileInterface stdoutFile = null; | 23 file_mojom.FileInterface stdoutFile = null; |
24 file_mojom.FileInterface stderrFile = null; | 24 file_mojom.FileInterface stderrFile = null; |
25 ProcessControllerInterfaceRequest processController = null; | 25 ProcessControllerInterfaceRequest processController = null; |
26 | 26 |
27 _ProcessSpawnParams() : super(kVersions.last.size); | 27 _ProcessSpawnParams() : super(kVersions.last.size); |
28 | 28 |
| 29 _ProcessSpawnParams.init( |
| 30 List<int> this.path, |
| 31 List<List<int>> this.argv, |
| 32 List<List<int>> this.envp, |
| 33 file_mojom.FileInterface this.stdinFile, |
| 34 file_mojom.FileInterface this.stdoutFile, |
| 35 file_mojom.FileInterface this.stderrFile, |
| 36 ProcessControllerInterfaceRequest this.processController |
| 37 ) : super(kVersions.last.size); |
| 38 |
29 static _ProcessSpawnParams deserialize(bindings.Message message) { | 39 static _ProcessSpawnParams deserialize(bindings.Message message) { |
30 var decoder = new bindings.Decoder(message); | 40 var decoder = new bindings.Decoder(message); |
31 var result = decode(decoder); | 41 var result = decode(decoder); |
32 if (decoder.excessHandles != null) { | 42 if (decoder.excessHandles != null) { |
33 decoder.excessHandles.forEach((h) => h.close()); | 43 decoder.excessHandles.forEach((h) => h.close()); |
34 } | 44 } |
35 return result; | 45 return result; |
36 } | 46 } |
37 | 47 |
38 static _ProcessSpawnParams decode(bindings.Decoder decoder0) { | 48 static _ProcessSpawnParams decode(bindings.Decoder decoder0) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 206 |
197 | 207 |
198 class ProcessSpawnResponseParams extends bindings.Struct { | 208 class ProcessSpawnResponseParams extends bindings.Struct { |
199 static const List<bindings.StructDataHeader> kVersions = const [ | 209 static const List<bindings.StructDataHeader> kVersions = const [ |
200 const bindings.StructDataHeader(16, 0) | 210 const bindings.StructDataHeader(16, 0) |
201 ]; | 211 ]; |
202 types_mojom.Error error = null; | 212 types_mojom.Error error = null; |
203 | 213 |
204 ProcessSpawnResponseParams() : super(kVersions.last.size); | 214 ProcessSpawnResponseParams() : super(kVersions.last.size); |
205 | 215 |
| 216 ProcessSpawnResponseParams.init( |
| 217 types_mojom.Error this.error |
| 218 ) : super(kVersions.last.size); |
| 219 |
206 static ProcessSpawnResponseParams deserialize(bindings.Message message) { | 220 static ProcessSpawnResponseParams deserialize(bindings.Message message) { |
207 var decoder = new bindings.Decoder(message); | 221 var decoder = new bindings.Decoder(message); |
208 var result = decode(decoder); | 222 var result = decode(decoder); |
209 if (decoder.excessHandles != null) { | 223 if (decoder.excessHandles != null) { |
210 decoder.excessHandles.forEach((h) => h.close()); | 224 decoder.excessHandles.forEach((h) => h.close()); |
211 } | 225 } |
212 return result; | 226 return result; |
213 } | 227 } |
214 | 228 |
215 static ProcessSpawnResponseParams decode(bindings.Decoder decoder0) { | 229 static ProcessSpawnResponseParams decode(bindings.Decoder decoder0) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 const bindings.StructDataHeader(48, 0) | 290 const bindings.StructDataHeader(48, 0) |
277 ]; | 291 ]; |
278 List<int> path = null; | 292 List<int> path = null; |
279 List<List<int>> argv = null; | 293 List<List<int>> argv = null; |
280 List<List<int>> envp = null; | 294 List<List<int>> envp = null; |
281 file_mojom.FileInterface terminalFile = null; | 295 file_mojom.FileInterface terminalFile = null; |
282 ProcessControllerInterfaceRequest processController = null; | 296 ProcessControllerInterfaceRequest processController = null; |
283 | 297 |
284 _ProcessSpawnWithTerminalParams() : super(kVersions.last.size); | 298 _ProcessSpawnWithTerminalParams() : super(kVersions.last.size); |
285 | 299 |
| 300 _ProcessSpawnWithTerminalParams.init( |
| 301 List<int> this.path, |
| 302 List<List<int>> this.argv, |
| 303 List<List<int>> this.envp, |
| 304 file_mojom.FileInterface this.terminalFile, |
| 305 ProcessControllerInterfaceRequest this.processController |
| 306 ) : super(kVersions.last.size); |
| 307 |
286 static _ProcessSpawnWithTerminalParams deserialize(bindings.Message message) { | 308 static _ProcessSpawnWithTerminalParams deserialize(bindings.Message message) { |
287 var decoder = new bindings.Decoder(message); | 309 var decoder = new bindings.Decoder(message); |
288 var result = decode(decoder); | 310 var result = decode(decoder); |
289 if (decoder.excessHandles != null) { | 311 if (decoder.excessHandles != null) { |
290 decoder.excessHandles.forEach((h) => h.close()); | 312 decoder.excessHandles.forEach((h) => h.close()); |
291 } | 313 } |
292 return result; | 314 return result; |
293 } | 315 } |
294 | 316 |
295 static _ProcessSpawnWithTerminalParams decode(bindings.Decoder decoder0) { | 317 static _ProcessSpawnWithTerminalParams decode(bindings.Decoder decoder0) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 451 |
430 | 452 |
431 class ProcessSpawnWithTerminalResponseParams extends bindings.Struct { | 453 class ProcessSpawnWithTerminalResponseParams extends bindings.Struct { |
432 static const List<bindings.StructDataHeader> kVersions = const [ | 454 static const List<bindings.StructDataHeader> kVersions = const [ |
433 const bindings.StructDataHeader(16, 0) | 455 const bindings.StructDataHeader(16, 0) |
434 ]; | 456 ]; |
435 types_mojom.Error error = null; | 457 types_mojom.Error error = null; |
436 | 458 |
437 ProcessSpawnWithTerminalResponseParams() : super(kVersions.last.size); | 459 ProcessSpawnWithTerminalResponseParams() : super(kVersions.last.size); |
438 | 460 |
| 461 ProcessSpawnWithTerminalResponseParams.init( |
| 462 types_mojom.Error this.error |
| 463 ) : super(kVersions.last.size); |
| 464 |
439 static ProcessSpawnWithTerminalResponseParams deserialize(bindings.Message mes
sage) { | 465 static ProcessSpawnWithTerminalResponseParams deserialize(bindings.Message mes
sage) { |
440 var decoder = new bindings.Decoder(message); | 466 var decoder = new bindings.Decoder(message); |
441 var result = decode(decoder); | 467 var result = decode(decoder); |
442 if (decoder.excessHandles != null) { | 468 if (decoder.excessHandles != null) { |
443 decoder.excessHandles.forEach((h) => h.close()); | 469 decoder.excessHandles.forEach((h) => h.close()); |
444 } | 470 } |
445 return result; | 471 return result; |
446 } | 472 } |
447 | 473 |
448 static ProcessSpawnWithTerminalResponseParams decode(bindings.Decoder decoder0
) { | 474 static ProcessSpawnWithTerminalResponseParams decode(bindings.Decoder decoder0
) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 } | 530 } |
505 | 531 |
506 | 532 |
507 class _ProcessControllerWaitParams extends bindings.Struct { | 533 class _ProcessControllerWaitParams extends bindings.Struct { |
508 static const List<bindings.StructDataHeader> kVersions = const [ | 534 static const List<bindings.StructDataHeader> kVersions = const [ |
509 const bindings.StructDataHeader(8, 0) | 535 const bindings.StructDataHeader(8, 0) |
510 ]; | 536 ]; |
511 | 537 |
512 _ProcessControllerWaitParams() : super(kVersions.last.size); | 538 _ProcessControllerWaitParams() : super(kVersions.last.size); |
513 | 539 |
| 540 _ProcessControllerWaitParams.init( |
| 541 ) : super(kVersions.last.size); |
| 542 |
514 static _ProcessControllerWaitParams deserialize(bindings.Message message) { | 543 static _ProcessControllerWaitParams deserialize(bindings.Message message) { |
515 var decoder = new bindings.Decoder(message); | 544 var decoder = new bindings.Decoder(message); |
516 var result = decode(decoder); | 545 var result = decode(decoder); |
517 if (decoder.excessHandles != null) { | 546 if (decoder.excessHandles != null) { |
518 decoder.excessHandles.forEach((h) => h.close()); | 547 decoder.excessHandles.forEach((h) => h.close()); |
519 } | 548 } |
520 return result; | 549 return result; |
521 } | 550 } |
522 | 551 |
523 static _ProcessControllerWaitParams decode(bindings.Decoder decoder0) { | 552 static _ProcessControllerWaitParams decode(bindings.Decoder decoder0) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 593 |
565 class ProcessControllerWaitResponseParams extends bindings.Struct { | 594 class ProcessControllerWaitResponseParams extends bindings.Struct { |
566 static const List<bindings.StructDataHeader> kVersions = const [ | 595 static const List<bindings.StructDataHeader> kVersions = const [ |
567 const bindings.StructDataHeader(16, 0) | 596 const bindings.StructDataHeader(16, 0) |
568 ]; | 597 ]; |
569 types_mojom.Error error = null; | 598 types_mojom.Error error = null; |
570 int exitStatus = 0; | 599 int exitStatus = 0; |
571 | 600 |
572 ProcessControllerWaitResponseParams() : super(kVersions.last.size); | 601 ProcessControllerWaitResponseParams() : super(kVersions.last.size); |
573 | 602 |
| 603 ProcessControllerWaitResponseParams.init( |
| 604 types_mojom.Error this.error, |
| 605 int this.exitStatus |
| 606 ) : super(kVersions.last.size); |
| 607 |
574 static ProcessControllerWaitResponseParams deserialize(bindings.Message messag
e) { | 608 static ProcessControllerWaitResponseParams deserialize(bindings.Message messag
e) { |
575 var decoder = new bindings.Decoder(message); | 609 var decoder = new bindings.Decoder(message); |
576 var result = decode(decoder); | 610 var result = decode(decoder); |
577 if (decoder.excessHandles != null) { | 611 if (decoder.excessHandles != null) { |
578 decoder.excessHandles.forEach((h) => h.close()); | 612 decoder.excessHandles.forEach((h) => h.close()); |
579 } | 613 } |
580 return result; | 614 return result; |
581 } | 615 } |
582 | 616 |
583 static ProcessControllerWaitResponseParams decode(bindings.Decoder decoder0) { | 617 static ProcessControllerWaitResponseParams decode(bindings.Decoder decoder0) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 | 687 |
654 | 688 |
655 class _ProcessControllerKillParams extends bindings.Struct { | 689 class _ProcessControllerKillParams extends bindings.Struct { |
656 static const List<bindings.StructDataHeader> kVersions = const [ | 690 static const List<bindings.StructDataHeader> kVersions = const [ |
657 const bindings.StructDataHeader(16, 0) | 691 const bindings.StructDataHeader(16, 0) |
658 ]; | 692 ]; |
659 int signal = 0; | 693 int signal = 0; |
660 | 694 |
661 _ProcessControllerKillParams() : super(kVersions.last.size); | 695 _ProcessControllerKillParams() : super(kVersions.last.size); |
662 | 696 |
| 697 _ProcessControllerKillParams.init( |
| 698 int this.signal |
| 699 ) : super(kVersions.last.size); |
| 700 |
663 static _ProcessControllerKillParams deserialize(bindings.Message message) { | 701 static _ProcessControllerKillParams deserialize(bindings.Message message) { |
664 var decoder = new bindings.Decoder(message); | 702 var decoder = new bindings.Decoder(message); |
665 var result = decode(decoder); | 703 var result = decode(decoder); |
666 if (decoder.excessHandles != null) { | 704 if (decoder.excessHandles != null) { |
667 decoder.excessHandles.forEach((h) => h.close()); | 705 decoder.excessHandles.forEach((h) => h.close()); |
668 } | 706 } |
669 return result; | 707 return result; |
670 } | 708 } |
671 | 709 |
672 static _ProcessControllerKillParams decode(bindings.Decoder decoder0) { | 710 static _ProcessControllerKillParams decode(bindings.Decoder decoder0) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 | 763 |
726 | 764 |
727 class ProcessControllerKillResponseParams extends bindings.Struct { | 765 class ProcessControllerKillResponseParams extends bindings.Struct { |
728 static const List<bindings.StructDataHeader> kVersions = const [ | 766 static const List<bindings.StructDataHeader> kVersions = const [ |
729 const bindings.StructDataHeader(16, 0) | 767 const bindings.StructDataHeader(16, 0) |
730 ]; | 768 ]; |
731 types_mojom.Error error = null; | 769 types_mojom.Error error = null; |
732 | 770 |
733 ProcessControllerKillResponseParams() : super(kVersions.last.size); | 771 ProcessControllerKillResponseParams() : super(kVersions.last.size); |
734 | 772 |
| 773 ProcessControllerKillResponseParams.init( |
| 774 types_mojom.Error this.error |
| 775 ) : super(kVersions.last.size); |
| 776 |
735 static ProcessControllerKillResponseParams deserialize(bindings.Message messag
e) { | 777 static ProcessControllerKillResponseParams deserialize(bindings.Message messag
e) { |
736 var decoder = new bindings.Decoder(message); | 778 var decoder = new bindings.Decoder(message); |
737 var result = decode(decoder); | 779 var result = decode(decoder); |
738 if (decoder.excessHandles != null) { | 780 if (decoder.excessHandles != null) { |
739 decoder.excessHandles.forEach((h) => h.close()); | 781 decoder.excessHandles.forEach((h) => h.close()); |
740 } | 782 } |
741 return result; | 783 return result; |
742 } | 784 } |
743 | 785 |
744 static ProcessControllerKillResponseParams decode(bindings.Decoder decoder0) { | 786 static ProcessControllerKillResponseParams decode(bindings.Decoder decoder0) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 Map map = new Map(); | 838 Map map = new Map(); |
797 map["error"] = error; | 839 map["error"] = error; |
798 return map; | 840 return map; |
799 } | 841 } |
800 } | 842 } |
801 | 843 |
802 const int _processMethodSpawnName = 0; | 844 const int _processMethodSpawnName = 0; |
803 const int _processMethodSpawnWithTerminalName = 1; | 845 const int _processMethodSpawnWithTerminalName = 1; |
804 | 846 |
805 class _ProcessServiceDescription implements service_describer.ServiceDescription
{ | 847 class _ProcessServiceDescription implements service_describer.ServiceDescription
{ |
806 dynamic getTopLevelInterface([Function responseFactory]) => | 848 void getTopLevelInterface(Function responder) { |
807 responseFactory(null); | 849 responder(null); |
| 850 } |
808 | 851 |
809 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 852 void getTypeDefinition(String typeKey, Function responder) { |
810 responseFactory(null); | 853 responder(null); |
| 854 } |
811 | 855 |
812 dynamic getAllTypeDefinitions([Function responseFactory]) => | 856 void getAllTypeDefinitions(Function responder) { |
813 responseFactory(null); | 857 responder(null); |
| 858 } |
814 } | 859 } |
815 | 860 |
816 abstract class Process { | 861 abstract class Process { |
817 static const String serviceName = "native_support::Process"; | 862 static const String serviceName = "native_support::Process"; |
818 | 863 |
819 static service_describer.ServiceDescription _cachedServiceDescription; | 864 static service_describer.ServiceDescription _cachedServiceDescription; |
820 static service_describer.ServiceDescription get serviceDescription { | 865 static service_describer.ServiceDescription get serviceDescription { |
821 if (_cachedServiceDescription == null) { | 866 if (_cachedServiceDescription == null) { |
822 _cachedServiceDescription = new _ProcessServiceDescription(); | 867 _cachedServiceDescription = new _ProcessServiceDescription(); |
823 } | 868 } |
824 return _cachedServiceDescription; | 869 return _cachedServiceDescription; |
825 } | 870 } |
826 | 871 |
827 static ProcessProxy connectToService( | 872 static ProcessProxy connectToService( |
828 bindings.ServiceConnector s, String url, [String serviceName]) { | 873 bindings.ServiceConnector s, String url, [String serviceName]) { |
829 ProcessProxy p = new ProcessProxy.unbound(); | 874 ProcessProxy p = new ProcessProxy.unbound(); |
830 String name = serviceName ?? Process.serviceName; | 875 String name = serviceName ?? Process.serviceName; |
831 if ((name == null) || name.isEmpty) { | 876 if ((name == null) || name.isEmpty) { |
832 throw new core.MojoApiError( | 877 throw new core.MojoApiError( |
833 "If an interface has no ServiceName, then one must be provided."); | 878 "If an interface has no ServiceName, then one must be provided."); |
834 } | 879 } |
835 s.connectToService(url, p, name); | 880 s.connectToService(url, p, name); |
836 return p; | 881 return p; |
837 } | 882 } |
838 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,file_mo
jom.FileInterface stdinFile,file_mojom.FileInterface stdoutFile,file_mojom.FileI
nterface stderrFile,ProcessControllerInterfaceRequest processController,[Functio
n responseFactory = null]); | 883 void spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,file_mojom
.FileInterface stdinFile,file_mojom.FileInterface stdoutFile,file_mojom.FileInte
rface stderrFile,ProcessControllerInterfaceRequest processController,void callba
ck(types_mojom.Error error)); |
839 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>>
envp,file_mojom.FileInterface terminalFile,ProcessControllerInterfaceRequest pro
cessController,[Function responseFactory = null]); | 884 void spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>> env
p,file_mojom.FileInterface terminalFile,ProcessControllerInterfaceRequest proces
sController,void callback(types_mojom.Error error)); |
840 } | 885 } |
841 | 886 |
842 abstract class ProcessInterface | 887 abstract class ProcessInterface |
843 implements bindings.MojoInterface<Process>, | 888 implements bindings.MojoInterface<Process>, |
844 Process { | 889 Process { |
845 factory ProcessInterface([Process impl]) => | 890 factory ProcessInterface([Process impl]) => |
846 new ProcessStub.unbound(impl); | 891 new ProcessStub.unbound(impl); |
847 factory ProcessInterface.fromEndpoint( | 892 factory ProcessInterface.fromEndpoint( |
848 core.MojoMessagePipeEndpoint endpoint, | 893 core.MojoMessagePipeEndpoint endpoint, |
849 [Process impl]) => | 894 [Process impl]) => |
(...skipping 22 matching lines...) Expand all Loading... |
872 | 917 |
873 void handleResponse(bindings.ServiceMessage message) { | 918 void handleResponse(bindings.ServiceMessage message) { |
874 switch (message.header.type) { | 919 switch (message.header.type) { |
875 case _processMethodSpawnName: | 920 case _processMethodSpawnName: |
876 var r = ProcessSpawnResponseParams.deserialize( | 921 var r = ProcessSpawnResponseParams.deserialize( |
877 message.payload); | 922 message.payload); |
878 if (!message.header.hasRequestId) { | 923 if (!message.header.hasRequestId) { |
879 proxyError("Expected a message with a valid request Id."); | 924 proxyError("Expected a message with a valid request Id."); |
880 return; | 925 return; |
881 } | 926 } |
882 Completer c = completerMap[message.header.requestId]; | 927 Function callback = callbackMap[message.header.requestId]; |
883 if (c == null) { | 928 if (callback == null) { |
884 proxyError( | 929 proxyError( |
885 "Message had unknown request Id: ${message.header.requestId}"); | 930 "Message had unknown request Id: ${message.header.requestId}"); |
886 return; | 931 return; |
887 } | 932 } |
888 completerMap.remove(message.header.requestId); | 933 callbackMap.remove(message.header.requestId); |
889 if (c.isCompleted) { | 934 callback(r.error ); |
890 proxyError("Response completer already completed"); | |
891 return; | |
892 } | |
893 c.complete(r); | |
894 break; | 935 break; |
895 case _processMethodSpawnWithTerminalName: | 936 case _processMethodSpawnWithTerminalName: |
896 var r = ProcessSpawnWithTerminalResponseParams.deserialize( | 937 var r = ProcessSpawnWithTerminalResponseParams.deserialize( |
897 message.payload); | 938 message.payload); |
898 if (!message.header.hasRequestId) { | 939 if (!message.header.hasRequestId) { |
899 proxyError("Expected a message with a valid request Id."); | 940 proxyError("Expected a message with a valid request Id."); |
900 return; | 941 return; |
901 } | 942 } |
902 Completer c = completerMap[message.header.requestId]; | 943 Function callback = callbackMap[message.header.requestId]; |
903 if (c == null) { | 944 if (callback == null) { |
904 proxyError( | 945 proxyError( |
905 "Message had unknown request Id: ${message.header.requestId}"); | 946 "Message had unknown request Id: ${message.header.requestId}"); |
906 return; | 947 return; |
907 } | 948 } |
908 completerMap.remove(message.header.requestId); | 949 callbackMap.remove(message.header.requestId); |
909 if (c.isCompleted) { | 950 callback(r.error ); |
910 proxyError("Response completer already completed"); | |
911 return; | |
912 } | |
913 c.complete(r); | |
914 break; | 951 break; |
915 default: | 952 default: |
916 proxyError("Unexpected message type: ${message.header.type}"); | 953 proxyError("Unexpected message type: ${message.header.type}"); |
917 close(immediate: true); | 954 close(immediate: true); |
918 break; | 955 break; |
919 } | 956 } |
920 } | 957 } |
921 | 958 |
922 Process get impl => null; | 959 Process get impl => null; |
923 set impl(Process _) { | 960 set impl(Process _) { |
(...skipping 22 matching lines...) Expand all Loading... |
946 ProcessProxy.unbound() | 983 ProcessProxy.unbound() |
947 : super(new _ProcessProxyControl.unbound()); | 984 : super(new _ProcessProxyControl.unbound()); |
948 | 985 |
949 static ProcessProxy newFromEndpoint( | 986 static ProcessProxy newFromEndpoint( |
950 core.MojoMessagePipeEndpoint endpoint) { | 987 core.MojoMessagePipeEndpoint endpoint) { |
951 assert(endpoint.setDescription("For ProcessProxy")); | 988 assert(endpoint.setDescription("For ProcessProxy")); |
952 return new ProcessProxy.fromEndpoint(endpoint); | 989 return new ProcessProxy.fromEndpoint(endpoint); |
953 } | 990 } |
954 | 991 |
955 | 992 |
956 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,file_mo
jom.FileInterface stdinFile,file_mojom.FileInterface stdoutFile,file_mojom.FileI
nterface stderrFile,ProcessControllerInterfaceRequest processController,[Functio
n responseFactory = null]) { | 993 void spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,file_mojom
.FileInterface stdinFile,file_mojom.FileInterface stdoutFile,file_mojom.FileInte
rface stderrFile,ProcessControllerInterfaceRequest processController,void callba
ck(types_mojom.Error error)) { |
957 var params = new _ProcessSpawnParams(); | 994 var params = new _ProcessSpawnParams(); |
958 params.path = path; | 995 params.path = path; |
959 params.argv = argv; | 996 params.argv = argv; |
960 params.envp = envp; | 997 params.envp = envp; |
961 params.stdinFile = stdinFile; | 998 params.stdinFile = stdinFile; |
962 params.stdoutFile = stdoutFile; | 999 params.stdoutFile = stdoutFile; |
963 params.stderrFile = stderrFile; | 1000 params.stderrFile = stderrFile; |
964 params.processController = processController; | 1001 params.processController = processController; |
965 return ctrl.sendMessageWithRequestId( | 1002 ctrl.sendMessageWithRequestId( |
966 params, | 1003 params, |
967 _processMethodSpawnName, | 1004 _processMethodSpawnName, |
968 -1, | 1005 -1, |
969 bindings.MessageHeader.kMessageExpectsResponse); | 1006 bindings.MessageHeader.kMessageExpectsResponse, |
| 1007 callback); |
970 } | 1008 } |
971 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>>
envp,file_mojom.FileInterface terminalFile,ProcessControllerInterfaceRequest pro
cessController,[Function responseFactory = null]) { | 1009 void spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>> env
p,file_mojom.FileInterface terminalFile,ProcessControllerInterfaceRequest proces
sController,void callback(types_mojom.Error error)) { |
972 var params = new _ProcessSpawnWithTerminalParams(); | 1010 var params = new _ProcessSpawnWithTerminalParams(); |
973 params.path = path; | 1011 params.path = path; |
974 params.argv = argv; | 1012 params.argv = argv; |
975 params.envp = envp; | 1013 params.envp = envp; |
976 params.terminalFile = terminalFile; | 1014 params.terminalFile = terminalFile; |
977 params.processController = processController; | 1015 params.processController = processController; |
978 return ctrl.sendMessageWithRequestId( | 1016 ctrl.sendMessageWithRequestId( |
979 params, | 1017 params, |
980 _processMethodSpawnWithTerminalName, | 1018 _processMethodSpawnWithTerminalName, |
981 -1, | 1019 -1, |
982 bindings.MessageHeader.kMessageExpectsResponse); | 1020 bindings.MessageHeader.kMessageExpectsResponse, |
| 1021 callback); |
983 } | 1022 } |
984 } | 1023 } |
985 | 1024 |
986 class _ProcessStubControl | 1025 class _ProcessStubControl |
987 extends bindings.StubMessageHandler | 1026 extends bindings.StubMessageHandler |
988 implements bindings.StubControl<Process> { | 1027 implements bindings.StubControl<Process> { |
989 Process _impl; | 1028 Process _impl; |
990 | 1029 |
991 _ProcessStubControl.fromEndpoint( | 1030 _ProcessStubControl.fromEndpoint( |
992 core.MojoMessagePipeEndpoint endpoint, [Process impl]) | 1031 core.MojoMessagePipeEndpoint endpoint, [Process impl]) |
993 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1032 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
994 _impl = impl; | 1033 _impl = impl; |
995 } | 1034 } |
996 | 1035 |
997 _ProcessStubControl.fromHandle( | 1036 _ProcessStubControl.fromHandle( |
998 core.MojoHandle handle, [Process impl]) | 1037 core.MojoHandle handle, [Process impl]) |
999 : super.fromHandle(handle, autoBegin: impl != null) { | 1038 : super.fromHandle(handle, autoBegin: impl != null) { |
1000 _impl = impl; | 1039 _impl = impl; |
1001 } | 1040 } |
1002 | 1041 |
1003 _ProcessStubControl.unbound([this._impl]) : super.unbound(); | 1042 _ProcessStubControl.unbound([this._impl]) : super.unbound(); |
1004 | 1043 |
1005 String get serviceName => Process.serviceName; | 1044 String get serviceName => Process.serviceName; |
1006 | 1045 |
1007 | 1046 |
1008 ProcessSpawnResponseParams _processSpawnResponseParamsFactory(types_mojom.Erro
r error) { | 1047 Function _processSpawnResponseParamsResponder( |
1009 var result = new ProcessSpawnResponseParams(); | 1048 int requestId) { |
1010 result.error = error; | 1049 return (types_mojom.Error error) { |
1011 return result; | 1050 var result = new ProcessSpawnResponseParams(); |
| 1051 result.error = error; |
| 1052 sendResponse(buildResponseWithId( |
| 1053 result, |
| 1054 _processMethodSpawnName, |
| 1055 requestId, |
| 1056 bindings.MessageHeader.kMessageIsResponse)); |
| 1057 }; |
1012 } | 1058 } |
1013 ProcessSpawnWithTerminalResponseParams _processSpawnWithTerminalResponseParams
Factory(types_mojom.Error error) { | 1059 Function _processSpawnWithTerminalResponseParamsResponder( |
1014 var result = new ProcessSpawnWithTerminalResponseParams(); | 1060 int requestId) { |
1015 result.error = error; | 1061 return (types_mojom.Error error) { |
1016 return result; | 1062 var result = new ProcessSpawnWithTerminalResponseParams(); |
| 1063 result.error = error; |
| 1064 sendResponse(buildResponseWithId( |
| 1065 result, |
| 1066 _processMethodSpawnWithTerminalName, |
| 1067 requestId, |
| 1068 bindings.MessageHeader.kMessageIsResponse)); |
| 1069 }; |
1017 } | 1070 } |
1018 | 1071 |
1019 dynamic handleMessage(bindings.ServiceMessage message) { | 1072 void handleMessage(bindings.ServiceMessage message) { |
1020 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 1073 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
1021 return bindings.ControlMessageHandler.handleMessage(this, | 1074 bindings.ControlMessageHandler.handleMessage( |
1022 0, | 1075 this, 0, message); |
1023 message); | 1076 return; |
1024 } | 1077 } |
1025 if (_impl == null) { | 1078 if (_impl == null) { |
1026 throw new core.MojoApiError("$this has no implementation set"); | 1079 throw new core.MojoApiError("$this has no implementation set"); |
1027 } | 1080 } |
1028 switch (message.header.type) { | 1081 switch (message.header.type) { |
1029 case _processMethodSpawnName: | 1082 case _processMethodSpawnName: |
1030 var params = _ProcessSpawnParams.deserialize( | 1083 var params = _ProcessSpawnParams.deserialize( |
1031 message.payload); | 1084 message.payload); |
1032 var response = _impl.spawn(params.path,params.argv,params.envp,params.st
dinFile,params.stdoutFile,params.stderrFile,params.processController,_processSpa
wnResponseParamsFactory); | 1085 _impl.spawn(params.path, params.argv, params.envp, params.stdinFile, par
ams.stdoutFile, params.stderrFile, params.processController, _processSpawnRespon
seParamsResponder(message.header.requestId)); |
1033 if (response is Future) { | |
1034 return response.then((response) { | |
1035 if (response != null) { | |
1036 return buildResponseWithId( | |
1037 response, | |
1038 _processMethodSpawnName, | |
1039 message.header.requestId, | |
1040 bindings.MessageHeader.kMessageIsResponse); | |
1041 } | |
1042 }); | |
1043 } else if (response != null) { | |
1044 return buildResponseWithId( | |
1045 response, | |
1046 _processMethodSpawnName, | |
1047 message.header.requestId, | |
1048 bindings.MessageHeader.kMessageIsResponse); | |
1049 } | |
1050 break; | 1086 break; |
1051 case _processMethodSpawnWithTerminalName: | 1087 case _processMethodSpawnWithTerminalName: |
1052 var params = _ProcessSpawnWithTerminalParams.deserialize( | 1088 var params = _ProcessSpawnWithTerminalParams.deserialize( |
1053 message.payload); | 1089 message.payload); |
1054 var response = _impl.spawnWithTerminal(params.path,params.argv,params.en
vp,params.terminalFile,params.processController,_processSpawnWithTerminalRespons
eParamsFactory); | 1090 _impl.spawnWithTerminal(params.path, params.argv, params.envp, params.te
rminalFile, params.processController, _processSpawnWithTerminalResponseParamsRes
ponder(message.header.requestId)); |
1055 if (response is Future) { | |
1056 return response.then((response) { | |
1057 if (response != null) { | |
1058 return buildResponseWithId( | |
1059 response, | |
1060 _processMethodSpawnWithTerminalName, | |
1061 message.header.requestId, | |
1062 bindings.MessageHeader.kMessageIsResponse); | |
1063 } | |
1064 }); | |
1065 } else if (response != null) { | |
1066 return buildResponseWithId( | |
1067 response, | |
1068 _processMethodSpawnWithTerminalName, | |
1069 message.header.requestId, | |
1070 bindings.MessageHeader.kMessageIsResponse); | |
1071 } | |
1072 break; | 1091 break; |
1073 default: | 1092 default: |
1074 throw new bindings.MojoCodecError("Unexpected message name"); | 1093 throw new bindings.MojoCodecError("Unexpected message name"); |
1075 break; | 1094 break; |
1076 } | 1095 } |
1077 return null; | |
1078 } | 1096 } |
1079 | 1097 |
1080 Process get impl => _impl; | 1098 Process get impl => _impl; |
1081 set impl(Process d) { | 1099 set impl(Process d) { |
1082 if (d == null) { | 1100 if (d == null) { |
1083 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 1101 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
1084 } | 1102 } |
1085 if (isBound && (_impl == null)) { | 1103 if (isBound && (_impl == null)) { |
1086 beginHandlingEvents(); | 1104 beginHandlingEvents(); |
1087 } | 1105 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 core.MojoHandle handle, [Process impl]) | 1139 core.MojoHandle handle, [Process impl]) |
1122 : super(new _ProcessStubControl.fromHandle(handle, impl)); | 1140 : super(new _ProcessStubControl.fromHandle(handle, impl)); |
1123 | 1141 |
1124 static ProcessStub newFromEndpoint( | 1142 static ProcessStub newFromEndpoint( |
1125 core.MojoMessagePipeEndpoint endpoint) { | 1143 core.MojoMessagePipeEndpoint endpoint) { |
1126 assert(endpoint.setDescription("For ProcessStub")); | 1144 assert(endpoint.setDescription("For ProcessStub")); |
1127 return new ProcessStub.fromEndpoint(endpoint); | 1145 return new ProcessStub.fromEndpoint(endpoint); |
1128 } | 1146 } |
1129 | 1147 |
1130 | 1148 |
1131 dynamic spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,file_mo
jom.FileInterface stdinFile,file_mojom.FileInterface stdoutFile,file_mojom.FileI
nterface stderrFile,ProcessControllerInterfaceRequest processController,[Functio
n responseFactory = null]) { | 1149 void spawn(List<int> path,List<List<int>> argv,List<List<int>> envp,file_mojom
.FileInterface stdinFile,file_mojom.FileInterface stdoutFile,file_mojom.FileInte
rface stderrFile,ProcessControllerInterfaceRequest processController,void callba
ck(types_mojom.Error error)) { |
1132 return impl.spawn(path,argv,envp,stdinFile,stdoutFile,stderrFile,processCont
roller,responseFactory); | 1150 return impl.spawn(path,argv,envp,stdinFile,stdoutFile,stderrFile,processCont
roller,callback); |
1133 } | 1151 } |
1134 dynamic spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>>
envp,file_mojom.FileInterface terminalFile,ProcessControllerInterfaceRequest pro
cessController,[Function responseFactory = null]) { | 1152 void spawnWithTerminal(List<int> path,List<List<int>> argv,List<List<int>> env
p,file_mojom.FileInterface terminalFile,ProcessControllerInterfaceRequest proces
sController,void callback(types_mojom.Error error)) { |
1135 return impl.spawnWithTerminal(path,argv,envp,terminalFile,processController,
responseFactory); | 1153 return impl.spawnWithTerminal(path,argv,envp,terminalFile,processController,
callback); |
1136 } | 1154 } |
1137 } | 1155 } |
1138 | 1156 |
1139 const int _processControllerMethodWaitName = 0; | 1157 const int _processControllerMethodWaitName = 0; |
1140 const int _processControllerMethodKillName = 1; | 1158 const int _processControllerMethodKillName = 1; |
1141 | 1159 |
1142 class _ProcessControllerServiceDescription implements service_describer.ServiceD
escription { | 1160 class _ProcessControllerServiceDescription implements service_describer.ServiceD
escription { |
1143 dynamic getTopLevelInterface([Function responseFactory]) => | 1161 void getTopLevelInterface(Function responder) { |
1144 responseFactory(null); | 1162 responder(null); |
| 1163 } |
1145 | 1164 |
1146 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 1165 void getTypeDefinition(String typeKey, Function responder) { |
1147 responseFactory(null); | 1166 responder(null); |
| 1167 } |
1148 | 1168 |
1149 dynamic getAllTypeDefinitions([Function responseFactory]) => | 1169 void getAllTypeDefinitions(Function responder) { |
1150 responseFactory(null); | 1170 responder(null); |
| 1171 } |
1151 } | 1172 } |
1152 | 1173 |
1153 abstract class ProcessController { | 1174 abstract class ProcessController { |
1154 static const String serviceName = null; | 1175 static const String serviceName = null; |
1155 | 1176 |
1156 static service_describer.ServiceDescription _cachedServiceDescription; | 1177 static service_describer.ServiceDescription _cachedServiceDescription; |
1157 static service_describer.ServiceDescription get serviceDescription { | 1178 static service_describer.ServiceDescription get serviceDescription { |
1158 if (_cachedServiceDescription == null) { | 1179 if (_cachedServiceDescription == null) { |
1159 _cachedServiceDescription = new _ProcessControllerServiceDescription(); | 1180 _cachedServiceDescription = new _ProcessControllerServiceDescription(); |
1160 } | 1181 } |
1161 return _cachedServiceDescription; | 1182 return _cachedServiceDescription; |
1162 } | 1183 } |
1163 | 1184 |
1164 static ProcessControllerProxy connectToService( | 1185 static ProcessControllerProxy connectToService( |
1165 bindings.ServiceConnector s, String url, [String serviceName]) { | 1186 bindings.ServiceConnector s, String url, [String serviceName]) { |
1166 ProcessControllerProxy p = new ProcessControllerProxy.unbound(); | 1187 ProcessControllerProxy p = new ProcessControllerProxy.unbound(); |
1167 String name = serviceName ?? ProcessController.serviceName; | 1188 String name = serviceName ?? ProcessController.serviceName; |
1168 if ((name == null) || name.isEmpty) { | 1189 if ((name == null) || name.isEmpty) { |
1169 throw new core.MojoApiError( | 1190 throw new core.MojoApiError( |
1170 "If an interface has no ServiceName, then one must be provided."); | 1191 "If an interface has no ServiceName, then one must be provided."); |
1171 } | 1192 } |
1172 s.connectToService(url, p, name); | 1193 s.connectToService(url, p, name); |
1173 return p; | 1194 return p; |
1174 } | 1195 } |
1175 dynamic wait([Function responseFactory = null]); | 1196 void wait(void callback(types_mojom.Error error, int exitStatus)); |
1176 dynamic kill(int signal,[Function responseFactory = null]); | 1197 void kill(int signal,void callback(types_mojom.Error error)); |
1177 } | 1198 } |
1178 | 1199 |
1179 abstract class ProcessControllerInterface | 1200 abstract class ProcessControllerInterface |
1180 implements bindings.MojoInterface<ProcessController>, | 1201 implements bindings.MojoInterface<ProcessController>, |
1181 ProcessController { | 1202 ProcessController { |
1182 factory ProcessControllerInterface([ProcessController impl]) => | 1203 factory ProcessControllerInterface([ProcessController impl]) => |
1183 new ProcessControllerStub.unbound(impl); | 1204 new ProcessControllerStub.unbound(impl); |
1184 factory ProcessControllerInterface.fromEndpoint( | 1205 factory ProcessControllerInterface.fromEndpoint( |
1185 core.MojoMessagePipeEndpoint endpoint, | 1206 core.MojoMessagePipeEndpoint endpoint, |
1186 [ProcessController impl]) => | 1207 [ProcessController impl]) => |
(...skipping 22 matching lines...) Expand all Loading... |
1209 | 1230 |
1210 void handleResponse(bindings.ServiceMessage message) { | 1231 void handleResponse(bindings.ServiceMessage message) { |
1211 switch (message.header.type) { | 1232 switch (message.header.type) { |
1212 case _processControllerMethodWaitName: | 1233 case _processControllerMethodWaitName: |
1213 var r = ProcessControllerWaitResponseParams.deserialize( | 1234 var r = ProcessControllerWaitResponseParams.deserialize( |
1214 message.payload); | 1235 message.payload); |
1215 if (!message.header.hasRequestId) { | 1236 if (!message.header.hasRequestId) { |
1216 proxyError("Expected a message with a valid request Id."); | 1237 proxyError("Expected a message with a valid request Id."); |
1217 return; | 1238 return; |
1218 } | 1239 } |
1219 Completer c = completerMap[message.header.requestId]; | 1240 Function callback = callbackMap[message.header.requestId]; |
1220 if (c == null) { | 1241 if (callback == null) { |
1221 proxyError( | 1242 proxyError( |
1222 "Message had unknown request Id: ${message.header.requestId}"); | 1243 "Message had unknown request Id: ${message.header.requestId}"); |
1223 return; | 1244 return; |
1224 } | 1245 } |
1225 completerMap.remove(message.header.requestId); | 1246 callbackMap.remove(message.header.requestId); |
1226 if (c.isCompleted) { | 1247 callback(r.error , r.exitStatus ); |
1227 proxyError("Response completer already completed"); | |
1228 return; | |
1229 } | |
1230 c.complete(r); | |
1231 break; | 1248 break; |
1232 case _processControllerMethodKillName: | 1249 case _processControllerMethodKillName: |
1233 var r = ProcessControllerKillResponseParams.deserialize( | 1250 var r = ProcessControllerKillResponseParams.deserialize( |
1234 message.payload); | 1251 message.payload); |
1235 if (!message.header.hasRequestId) { | 1252 if (!message.header.hasRequestId) { |
1236 proxyError("Expected a message with a valid request Id."); | 1253 proxyError("Expected a message with a valid request Id."); |
1237 return; | 1254 return; |
1238 } | 1255 } |
1239 Completer c = completerMap[message.header.requestId]; | 1256 Function callback = callbackMap[message.header.requestId]; |
1240 if (c == null) { | 1257 if (callback == null) { |
1241 proxyError( | 1258 proxyError( |
1242 "Message had unknown request Id: ${message.header.requestId}"); | 1259 "Message had unknown request Id: ${message.header.requestId}"); |
1243 return; | 1260 return; |
1244 } | 1261 } |
1245 completerMap.remove(message.header.requestId); | 1262 callbackMap.remove(message.header.requestId); |
1246 if (c.isCompleted) { | 1263 callback(r.error ); |
1247 proxyError("Response completer already completed"); | |
1248 return; | |
1249 } | |
1250 c.complete(r); | |
1251 break; | 1264 break; |
1252 default: | 1265 default: |
1253 proxyError("Unexpected message type: ${message.header.type}"); | 1266 proxyError("Unexpected message type: ${message.header.type}"); |
1254 close(immediate: true); | 1267 close(immediate: true); |
1255 break; | 1268 break; |
1256 } | 1269 } |
1257 } | 1270 } |
1258 | 1271 |
1259 ProcessController get impl => null; | 1272 ProcessController get impl => null; |
1260 set impl(ProcessController _) { | 1273 set impl(ProcessController _) { |
(...skipping 22 matching lines...) Expand all Loading... |
1283 ProcessControllerProxy.unbound() | 1296 ProcessControllerProxy.unbound() |
1284 : super(new _ProcessControllerProxyControl.unbound()); | 1297 : super(new _ProcessControllerProxyControl.unbound()); |
1285 | 1298 |
1286 static ProcessControllerProxy newFromEndpoint( | 1299 static ProcessControllerProxy newFromEndpoint( |
1287 core.MojoMessagePipeEndpoint endpoint) { | 1300 core.MojoMessagePipeEndpoint endpoint) { |
1288 assert(endpoint.setDescription("For ProcessControllerProxy")); | 1301 assert(endpoint.setDescription("For ProcessControllerProxy")); |
1289 return new ProcessControllerProxy.fromEndpoint(endpoint); | 1302 return new ProcessControllerProxy.fromEndpoint(endpoint); |
1290 } | 1303 } |
1291 | 1304 |
1292 | 1305 |
1293 dynamic wait([Function responseFactory = null]) { | 1306 void wait(void callback(types_mojom.Error error, int exitStatus)) { |
1294 var params = new _ProcessControllerWaitParams(); | 1307 var params = new _ProcessControllerWaitParams(); |
1295 return ctrl.sendMessageWithRequestId( | 1308 ctrl.sendMessageWithRequestId( |
1296 params, | 1309 params, |
1297 _processControllerMethodWaitName, | 1310 _processControllerMethodWaitName, |
1298 -1, | 1311 -1, |
1299 bindings.MessageHeader.kMessageExpectsResponse); | 1312 bindings.MessageHeader.kMessageExpectsResponse, |
| 1313 callback); |
1300 } | 1314 } |
1301 dynamic kill(int signal,[Function responseFactory = null]) { | 1315 void kill(int signal,void callback(types_mojom.Error error)) { |
1302 var params = new _ProcessControllerKillParams(); | 1316 var params = new _ProcessControllerKillParams(); |
1303 params.signal = signal; | 1317 params.signal = signal; |
1304 return ctrl.sendMessageWithRequestId( | 1318 ctrl.sendMessageWithRequestId( |
1305 params, | 1319 params, |
1306 _processControllerMethodKillName, | 1320 _processControllerMethodKillName, |
1307 -1, | 1321 -1, |
1308 bindings.MessageHeader.kMessageExpectsResponse); | 1322 bindings.MessageHeader.kMessageExpectsResponse, |
| 1323 callback); |
1309 } | 1324 } |
1310 } | 1325 } |
1311 | 1326 |
1312 class _ProcessControllerStubControl | 1327 class _ProcessControllerStubControl |
1313 extends bindings.StubMessageHandler | 1328 extends bindings.StubMessageHandler |
1314 implements bindings.StubControl<ProcessController> { | 1329 implements bindings.StubControl<ProcessController> { |
1315 ProcessController _impl; | 1330 ProcessController _impl; |
1316 | 1331 |
1317 _ProcessControllerStubControl.fromEndpoint( | 1332 _ProcessControllerStubControl.fromEndpoint( |
1318 core.MojoMessagePipeEndpoint endpoint, [ProcessController impl]) | 1333 core.MojoMessagePipeEndpoint endpoint, [ProcessController impl]) |
1319 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 1334 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
1320 _impl = impl; | 1335 _impl = impl; |
1321 } | 1336 } |
1322 | 1337 |
1323 _ProcessControllerStubControl.fromHandle( | 1338 _ProcessControllerStubControl.fromHandle( |
1324 core.MojoHandle handle, [ProcessController impl]) | 1339 core.MojoHandle handle, [ProcessController impl]) |
1325 : super.fromHandle(handle, autoBegin: impl != null) { | 1340 : super.fromHandle(handle, autoBegin: impl != null) { |
1326 _impl = impl; | 1341 _impl = impl; |
1327 } | 1342 } |
1328 | 1343 |
1329 _ProcessControllerStubControl.unbound([this._impl]) : super.unbound(); | 1344 _ProcessControllerStubControl.unbound([this._impl]) : super.unbound(); |
1330 | 1345 |
1331 String get serviceName => ProcessController.serviceName; | 1346 String get serviceName => ProcessController.serviceName; |
1332 | 1347 |
1333 | 1348 |
1334 ProcessControllerWaitResponseParams _processControllerWaitResponseParamsFactor
y(types_mojom.Error error, int exitStatus) { | 1349 Function _processControllerWaitResponseParamsResponder( |
1335 var result = new ProcessControllerWaitResponseParams(); | 1350 int requestId) { |
1336 result.error = error; | 1351 return (types_mojom.Error error, int exitStatus) { |
1337 result.exitStatus = exitStatus; | 1352 var result = new ProcessControllerWaitResponseParams(); |
1338 return result; | 1353 result.error = error; |
| 1354 result.exitStatus = exitStatus; |
| 1355 sendResponse(buildResponseWithId( |
| 1356 result, |
| 1357 _processControllerMethodWaitName, |
| 1358 requestId, |
| 1359 bindings.MessageHeader.kMessageIsResponse)); |
| 1360 }; |
1339 } | 1361 } |
1340 ProcessControllerKillResponseParams _processControllerKillResponseParamsFactor
y(types_mojom.Error error) { | 1362 Function _processControllerKillResponseParamsResponder( |
1341 var result = new ProcessControllerKillResponseParams(); | 1363 int requestId) { |
1342 result.error = error; | 1364 return (types_mojom.Error error) { |
1343 return result; | 1365 var result = new ProcessControllerKillResponseParams(); |
| 1366 result.error = error; |
| 1367 sendResponse(buildResponseWithId( |
| 1368 result, |
| 1369 _processControllerMethodKillName, |
| 1370 requestId, |
| 1371 bindings.MessageHeader.kMessageIsResponse)); |
| 1372 }; |
1344 } | 1373 } |
1345 | 1374 |
1346 dynamic handleMessage(bindings.ServiceMessage message) { | 1375 void handleMessage(bindings.ServiceMessage message) { |
1347 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 1376 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
1348 return bindings.ControlMessageHandler.handleMessage(this, | 1377 bindings.ControlMessageHandler.handleMessage( |
1349 0, | 1378 this, 0, message); |
1350 message); | 1379 return; |
1351 } | 1380 } |
1352 if (_impl == null) { | 1381 if (_impl == null) { |
1353 throw new core.MojoApiError("$this has no implementation set"); | 1382 throw new core.MojoApiError("$this has no implementation set"); |
1354 } | 1383 } |
1355 switch (message.header.type) { | 1384 switch (message.header.type) { |
1356 case _processControllerMethodWaitName: | 1385 case _processControllerMethodWaitName: |
1357 var response = _impl.wait(_processControllerWaitResponseParamsFactory); | 1386 _impl.wait(_processControllerWaitResponseParamsResponder(message.header.
requestId)); |
1358 if (response is Future) { | |
1359 return response.then((response) { | |
1360 if (response != null) { | |
1361 return buildResponseWithId( | |
1362 response, | |
1363 _processControllerMethodWaitName, | |
1364 message.header.requestId, | |
1365 bindings.MessageHeader.kMessageIsResponse); | |
1366 } | |
1367 }); | |
1368 } else if (response != null) { | |
1369 return buildResponseWithId( | |
1370 response, | |
1371 _processControllerMethodWaitName, | |
1372 message.header.requestId, | |
1373 bindings.MessageHeader.kMessageIsResponse); | |
1374 } | |
1375 break; | 1387 break; |
1376 case _processControllerMethodKillName: | 1388 case _processControllerMethodKillName: |
1377 var params = _ProcessControllerKillParams.deserialize( | 1389 var params = _ProcessControllerKillParams.deserialize( |
1378 message.payload); | 1390 message.payload); |
1379 var response = _impl.kill(params.signal,_processControllerKillResponsePa
ramsFactory); | 1391 _impl.kill(params.signal, _processControllerKillResponseParamsResponder(
message.header.requestId)); |
1380 if (response is Future) { | |
1381 return response.then((response) { | |
1382 if (response != null) { | |
1383 return buildResponseWithId( | |
1384 response, | |
1385 _processControllerMethodKillName, | |
1386 message.header.requestId, | |
1387 bindings.MessageHeader.kMessageIsResponse); | |
1388 } | |
1389 }); | |
1390 } else if (response != null) { | |
1391 return buildResponseWithId( | |
1392 response, | |
1393 _processControllerMethodKillName, | |
1394 message.header.requestId, | |
1395 bindings.MessageHeader.kMessageIsResponse); | |
1396 } | |
1397 break; | 1392 break; |
1398 default: | 1393 default: |
1399 throw new bindings.MojoCodecError("Unexpected message name"); | 1394 throw new bindings.MojoCodecError("Unexpected message name"); |
1400 break; | 1395 break; |
1401 } | 1396 } |
1402 return null; | |
1403 } | 1397 } |
1404 | 1398 |
1405 ProcessController get impl => _impl; | 1399 ProcessController get impl => _impl; |
1406 set impl(ProcessController d) { | 1400 set impl(ProcessController d) { |
1407 if (d == null) { | 1401 if (d == null) { |
1408 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 1402 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
1409 } | 1403 } |
1410 if (isBound && (_impl == null)) { | 1404 if (isBound && (_impl == null)) { |
1411 beginHandlingEvents(); | 1405 beginHandlingEvents(); |
1412 } | 1406 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 core.MojoHandle handle, [ProcessController impl]) | 1440 core.MojoHandle handle, [ProcessController impl]) |
1447 : super(new _ProcessControllerStubControl.fromHandle(handle, impl)); | 1441 : super(new _ProcessControllerStubControl.fromHandle(handle, impl)); |
1448 | 1442 |
1449 static ProcessControllerStub newFromEndpoint( | 1443 static ProcessControllerStub newFromEndpoint( |
1450 core.MojoMessagePipeEndpoint endpoint) { | 1444 core.MojoMessagePipeEndpoint endpoint) { |
1451 assert(endpoint.setDescription("For ProcessControllerStub")); | 1445 assert(endpoint.setDescription("For ProcessControllerStub")); |
1452 return new ProcessControllerStub.fromEndpoint(endpoint); | 1446 return new ProcessControllerStub.fromEndpoint(endpoint); |
1453 } | 1447 } |
1454 | 1448 |
1455 | 1449 |
1456 dynamic wait([Function responseFactory = null]) { | 1450 void wait(void callback(types_mojom.Error error, int exitStatus)) { |
1457 return impl.wait(responseFactory); | 1451 return impl.wait(callback); |
1458 } | 1452 } |
1459 dynamic kill(int signal,[Function responseFactory = null]) { | 1453 void kill(int signal,void callback(types_mojom.Error error)) { |
1460 return impl.kill(signal,responseFactory); | 1454 return impl.kill(signal,callback); |
1461 } | 1455 } |
1462 } | 1456 } |
1463 | 1457 |
1464 | 1458 |
1465 | 1459 |
OLD | NEW |