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

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

Issue 1539673003: Generate Mojom Types in Dart (Take 2) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Merge with master Created 4 years, 10 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 web_socket_mojom; 5 library web_socket_mojom;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:mojo/bindings.dart' as bindings; 9 import 'package:mojo/bindings.dart' as bindings;
10 import 'package:mojo/core.dart' as core; 10 import 'package:mojo/core.dart' as core;
11 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types;
12 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
11 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; 13 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom;
12 14
13 15
14 16
15 class _WebSocketConnectParams extends bindings.Struct { 17 class _WebSocketConnectParams extends bindings.Struct {
16 static const List<bindings.StructDataHeader> kVersions = const [ 18 static const List<bindings.StructDataHeader> kVersions = const [
17 const bindings.StructDataHeader(48, 0) 19 const bindings.StructDataHeader(48, 0)
18 ]; 20 ];
19 String url = null; 21 String url = null;
20 List<String> protocols = null; 22 List<String> protocols = null;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 "client: $client" ")"; 121 "client: $client" ")";
120 } 122 }
121 123
122 Map toJson() { 124 Map toJson() {
123 throw new bindings.MojoCodecError( 125 throw new bindings.MojoCodecError(
124 'Object containing handles cannot be encoded to JSON.'); 126 'Object containing handles cannot be encoded to JSON.');
125 } 127 }
126 } 128 }
127 129
128 130
131
132
129 class _WebSocketSendParams extends bindings.Struct { 133 class _WebSocketSendParams extends bindings.Struct {
130 static const List<bindings.StructDataHeader> kVersions = const [ 134 static const List<bindings.StructDataHeader> kVersions = const [
131 const bindings.StructDataHeader(24, 0) 135 const bindings.StructDataHeader(24, 0)
132 ]; 136 ];
133 bool fin = false; 137 bool fin = false;
134 WebSocketMessageType type = null; 138 WebSocketMessageType type = null;
135 int numBytes = 0; 139 int numBytes = 0;
136 140
137 _WebSocketSendParams() : super(kVersions.last.size); 141 _WebSocketSendParams() : super(kVersions.last.size);
138 142
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 Map toJson() { 212 Map toJson() {
209 Map map = new Map(); 213 Map map = new Map();
210 map["fin"] = fin; 214 map["fin"] = fin;
211 map["type"] = type; 215 map["type"] = type;
212 map["numBytes"] = numBytes; 216 map["numBytes"] = numBytes;
213 return map; 217 return map;
214 } 218 }
215 } 219 }
216 220
217 221
222
223
218 class _WebSocketFlowControlParams extends bindings.Struct { 224 class _WebSocketFlowControlParams extends bindings.Struct {
219 static const List<bindings.StructDataHeader> kVersions = const [ 225 static const List<bindings.StructDataHeader> kVersions = const [
220 const bindings.StructDataHeader(16, 0) 226 const bindings.StructDataHeader(16, 0)
221 ]; 227 ];
222 int quota = 0; 228 int quota = 0;
223 229
224 _WebSocketFlowControlParams() : super(kVersions.last.size); 230 _WebSocketFlowControlParams() : super(kVersions.last.size);
225 231
226 static _WebSocketFlowControlParams deserialize(bindings.Message message) { 232 static _WebSocketFlowControlParams deserialize(bindings.Message message) {
227 var decoder = new bindings.Decoder(message); 233 var decoder = new bindings.Decoder(message);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 281 }
276 282
277 Map toJson() { 283 Map toJson() {
278 Map map = new Map(); 284 Map map = new Map();
279 map["quota"] = quota; 285 map["quota"] = quota;
280 return map; 286 return map;
281 } 287 }
282 } 288 }
283 289
284 290
291
292
285 class _WebSocketCloseParams extends bindings.Struct { 293 class _WebSocketCloseParams extends bindings.Struct {
286 static const List<bindings.StructDataHeader> kVersions = const [ 294 static const List<bindings.StructDataHeader> kVersions = const [
287 const bindings.StructDataHeader(24, 0) 295 const bindings.StructDataHeader(24, 0)
288 ]; 296 ];
289 int code = 0; 297 int code = 0;
290 String reason = null; 298 String reason = null;
291 299
292 _WebSocketCloseParams() : super(kVersions.last.size); 300 _WebSocketCloseParams() : super(kVersions.last.size);
293 301
294 static _WebSocketCloseParams deserialize(bindings.Message message) { 302 static _WebSocketCloseParams deserialize(bindings.Message message) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 359
352 Map toJson() { 360 Map toJson() {
353 Map map = new Map(); 361 Map map = new Map();
354 map["code"] = code; 362 map["code"] = code;
355 map["reason"] = reason; 363 map["reason"] = reason;
356 return map; 364 return map;
357 } 365 }
358 } 366 }
359 367
360 368
369
370
361 class _WebSocketClientDidConnectParams extends bindings.Struct { 371 class _WebSocketClientDidConnectParams extends bindings.Struct {
362 static const List<bindings.StructDataHeader> kVersions = const [ 372 static const List<bindings.StructDataHeader> kVersions = const [
363 const bindings.StructDataHeader(32, 0) 373 const bindings.StructDataHeader(32, 0)
364 ]; 374 ];
365 String selectedSubprotocol = null; 375 String selectedSubprotocol = null;
366 String extensions = null; 376 String extensions = null;
367 core.MojoDataPipeConsumer receiveStream = null; 377 core.MojoDataPipeConsumer receiveStream = null;
368 378
369 _WebSocketClientDidConnectParams() : super(kVersions.last.size); 379 _WebSocketClientDidConnectParams() : super(kVersions.last.size);
370 380
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 "receiveStream: $receiveStream" ")"; 443 "receiveStream: $receiveStream" ")";
434 } 444 }
435 445
436 Map toJson() { 446 Map toJson() {
437 throw new bindings.MojoCodecError( 447 throw new bindings.MojoCodecError(
438 'Object containing handles cannot be encoded to JSON.'); 448 'Object containing handles cannot be encoded to JSON.');
439 } 449 }
440 } 450 }
441 451
442 452
453
454
443 class _WebSocketClientDidReceiveDataParams extends bindings.Struct { 455 class _WebSocketClientDidReceiveDataParams extends bindings.Struct {
444 static const List<bindings.StructDataHeader> kVersions = const [ 456 static const List<bindings.StructDataHeader> kVersions = const [
445 const bindings.StructDataHeader(24, 0) 457 const bindings.StructDataHeader(24, 0)
446 ]; 458 ];
447 bool fin = false; 459 bool fin = false;
448 WebSocketMessageType type = null; 460 WebSocketMessageType type = null;
449 int numBytes = 0; 461 int numBytes = 0;
450 462
451 _WebSocketClientDidReceiveDataParams() : super(kVersions.last.size); 463 _WebSocketClientDidReceiveDataParams() : super(kVersions.last.size);
452 464
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 Map toJson() { 534 Map toJson() {
523 Map map = new Map(); 535 Map map = new Map();
524 map["fin"] = fin; 536 map["fin"] = fin;
525 map["type"] = type; 537 map["type"] = type;
526 map["numBytes"] = numBytes; 538 map["numBytes"] = numBytes;
527 return map; 539 return map;
528 } 540 }
529 } 541 }
530 542
531 543
544
545
532 class _WebSocketClientDidReceiveFlowControlParams extends bindings.Struct { 546 class _WebSocketClientDidReceiveFlowControlParams extends bindings.Struct {
533 static const List<bindings.StructDataHeader> kVersions = const [ 547 static const List<bindings.StructDataHeader> kVersions = const [
534 const bindings.StructDataHeader(16, 0) 548 const bindings.StructDataHeader(16, 0)
535 ]; 549 ];
536 int quota = 0; 550 int quota = 0;
537 551
538 _WebSocketClientDidReceiveFlowControlParams() : super(kVersions.last.size); 552 _WebSocketClientDidReceiveFlowControlParams() : super(kVersions.last.size);
539 553
540 static _WebSocketClientDidReceiveFlowControlParams deserialize(bindings.Messag e message) { 554 static _WebSocketClientDidReceiveFlowControlParams deserialize(bindings.Messag e message) {
541 var decoder = new bindings.Decoder(message); 555 var decoder = new bindings.Decoder(message);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 603 }
590 604
591 Map toJson() { 605 Map toJson() {
592 Map map = new Map(); 606 Map map = new Map();
593 map["quota"] = quota; 607 map["quota"] = quota;
594 return map; 608 return map;
595 } 609 }
596 } 610 }
597 611
598 612
613
614
599 class _WebSocketClientDidFailParams extends bindings.Struct { 615 class _WebSocketClientDidFailParams extends bindings.Struct {
600 static const List<bindings.StructDataHeader> kVersions = const [ 616 static const List<bindings.StructDataHeader> kVersions = const [
601 const bindings.StructDataHeader(16, 0) 617 const bindings.StructDataHeader(16, 0)
602 ]; 618 ];
603 String message = null; 619 String message = null;
604 620
605 _WebSocketClientDidFailParams() : super(kVersions.last.size); 621 _WebSocketClientDidFailParams() : super(kVersions.last.size);
606 622
607 static _WebSocketClientDidFailParams deserialize(bindings.Message message) { 623 static _WebSocketClientDidFailParams deserialize(bindings.Message message) {
608 var decoder = new bindings.Decoder(message); 624 var decoder = new bindings.Decoder(message);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 672 }
657 673
658 Map toJson() { 674 Map toJson() {
659 Map map = new Map(); 675 Map map = new Map();
660 map["message"] = message; 676 map["message"] = message;
661 return map; 677 return map;
662 } 678 }
663 } 679 }
664 680
665 681
682
683
666 class _WebSocketClientDidCloseParams extends bindings.Struct { 684 class _WebSocketClientDidCloseParams extends bindings.Struct {
667 static const List<bindings.StructDataHeader> kVersions = const [ 685 static const List<bindings.StructDataHeader> kVersions = const [
668 const bindings.StructDataHeader(24, 0) 686 const bindings.StructDataHeader(24, 0)
669 ]; 687 ];
670 bool wasClean = false; 688 bool wasClean = false;
671 int code = 0; 689 int code = 0;
672 String reason = null; 690 String reason = null;
673 691
674 _WebSocketClientDidCloseParams() : super(kVersions.last.size); 692 _WebSocketClientDidCloseParams() : super(kVersions.last.size);
675 693
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 758
741 Map toJson() { 759 Map toJson() {
742 Map map = new Map(); 760 Map map = new Map();
743 map["wasClean"] = wasClean; 761 map["wasClean"] = wasClean;
744 map["code"] = code; 762 map["code"] = code;
745 map["reason"] = reason; 763 map["reason"] = reason;
746 return map; 764 return map;
747 } 765 }
748 } 766 }
749 767
768
769
770
750 const int _WebSocket_connectName = 0; 771 const int _WebSocket_connectName = 0;
751 const int _WebSocket_sendName = 1; 772 const int _WebSocket_sendName = 1;
752 const int _WebSocket_flowControlName = 2; 773 const int _WebSocket_flowControlName = 2;
753 const int _WebSocket_closeName = 3; 774 const int _WebSocket_closeName = 3;
754 775
755 class WebSocketMessageType extends bindings.MojoEnum { 776 class WebSocketMessageType extends bindings.MojoEnum {
756 static const WebSocketMessageType continuation = const WebSocketMessageType._( 0); 777 static const WebSocketMessageType continuation = const WebSocketMessageType._( 0);
757 static const WebSocketMessageType text = const WebSocketMessageType._(1); 778 static const WebSocketMessageType text = const WebSocketMessageType._(1);
758 static const WebSocketMessageType binary = const WebSocketMessageType._(2); 779 static const WebSocketMessageType binary = const WebSocketMessageType._(2);
759 780
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 817 }
797 818
798 String toString() { 819 String toString() {
799 switch(this) { 820 switch(this) {
800 case continuation: 821 case continuation:
801 return 'WebSocketMessageType.continuation'; 822 return 'WebSocketMessageType.continuation';
802 case text: 823 case text:
803 return 'WebSocketMessageType.text'; 824 return 'WebSocketMessageType.text';
804 case binary: 825 case binary:
805 return 'WebSocketMessageType.binary'; 826 return 'WebSocketMessageType.binary';
827 default:
828 return null;
806 } 829 }
807 } 830 }
808 831
809 int toJson() => mojoEnumValue; 832 int toJson() => mojoEnumValue;
810 } 833 }
811 834
835
836
837
838
839 class _WebSocketServiceDescription implements service_describer.ServiceDescripti on {
840 dynamic getTopLevelInterface([Function responseFactory]) => null;
841
842 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => null;
843
844 dynamic getAllTypeDefinitions([Function responseFactory]) => null;
845 }
846
812 abstract class WebSocket { 847 abstract class WebSocket {
813 static const String serviceName = null; 848 static const String serviceName = null;
814 void connect(String url, List<String> protocols, String origin, core.MojoDataP ipeConsumer sendStream, Object client); 849 void connect(String url, List<String> protocols, String origin, core.MojoDataP ipeConsumer sendStream, Object client);
815 void send(bool fin, WebSocketMessageType type, int numBytes); 850 void send(bool fin, WebSocketMessageType type, int numBytes);
816 void flowControl(int quota); 851 void flowControl(int quota);
817 void close(int code, String reason); 852 void close(int code, String reason);
818 static const int kAbnormalCloseCode = 1006; 853 static const int kAbnormalCloseCode = 1006;
819 } 854 }
820 855
821 856
822 class _WebSocketProxyImpl extends bindings.Proxy { 857 class _WebSocketProxyImpl extends bindings.Proxy {
823 _WebSocketProxyImpl.fromEndpoint( 858 _WebSocketProxyImpl.fromEndpoint(
824 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 859 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
825 860
826 _WebSocketProxyImpl.fromHandle(core.MojoHandle handle) : 861 _WebSocketProxyImpl.fromHandle(core.MojoHandle handle) :
827 super.fromHandle(handle); 862 super.fromHandle(handle);
828 863
829 _WebSocketProxyImpl.unbound() : super.unbound(); 864 _WebSocketProxyImpl.unbound() : super.unbound();
830 865
831 static _WebSocketProxyImpl newFromEndpoint( 866 static _WebSocketProxyImpl newFromEndpoint(
832 core.MojoMessagePipeEndpoint endpoint) { 867 core.MojoMessagePipeEndpoint endpoint) {
833 assert(endpoint.setDescription("For _WebSocketProxyImpl")); 868 assert(endpoint.setDescription("For _WebSocketProxyImpl"));
834 return new _WebSocketProxyImpl.fromEndpoint(endpoint); 869 return new _WebSocketProxyImpl.fromEndpoint(endpoint);
835 } 870 }
836 871
872 service_describer.ServiceDescription get serviceDescription =>
873 new _WebSocketServiceDescription();
874
837 void handleResponse(bindings.ServiceMessage message) { 875 void handleResponse(bindings.ServiceMessage message) {
838 switch (message.header.type) { 876 switch (message.header.type) {
839 default: 877 default:
840 proxyError("Unexpected message type: ${message.header.type}"); 878 proxyError("Unexpected message type: ${message.header.type}");
841 close(immediate: true); 879 close(immediate: true);
842 break; 880 break;
843 } 881 }
844 } 882 }
845 883
846 String toString() { 884 String toString() {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 assert(_impl == null); 1057 assert(_impl == null);
1020 _impl = d; 1058 _impl = d;
1021 } 1059 }
1022 1060
1023 String toString() { 1061 String toString() {
1024 var superString = super.toString(); 1062 var superString = super.toString();
1025 return "WebSocketStub($superString)"; 1063 return "WebSocketStub($superString)";
1026 } 1064 }
1027 1065
1028 int get version => 0; 1066 int get version => 0;
1067
1068 service_describer.ServiceDescription get serviceDescription =>
1069 new _WebSocketServiceDescription();
1029 } 1070 }
1030 1071
1031 const int _WebSocketClient_didConnectName = 0; 1072 const int _WebSocketClient_didConnectName = 0;
1032 const int _WebSocketClient_didReceiveDataName = 1; 1073 const int _WebSocketClient_didReceiveDataName = 1;
1033 const int _WebSocketClient_didReceiveFlowControlName = 2; 1074 const int _WebSocketClient_didReceiveFlowControlName = 2;
1034 const int _WebSocketClient_didFailName = 3; 1075 const int _WebSocketClient_didFailName = 3;
1035 const int _WebSocketClient_didCloseName = 4; 1076 const int _WebSocketClient_didCloseName = 4;
1036 1077
1078
1079
1080 class _WebSocketClientServiceDescription implements service_describer.ServiceDes cription {
1081 dynamic getTopLevelInterface([Function responseFactory]) => null;
1082
1083 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => null;
1084
1085 dynamic getAllTypeDefinitions([Function responseFactory]) => null;
1086 }
1087
1037 abstract class WebSocketClient { 1088 abstract class WebSocketClient {
1038 static const String serviceName = null; 1089 static const String serviceName = null;
1039 void didConnect(String selectedSubprotocol, String extensions, core.MojoDataPi peConsumer receiveStream); 1090 void didConnect(String selectedSubprotocol, String extensions, core.MojoDataPi peConsumer receiveStream);
1040 void didReceiveData(bool fin, WebSocketMessageType type, int numBytes); 1091 void didReceiveData(bool fin, WebSocketMessageType type, int numBytes);
1041 void didReceiveFlowControl(int quota); 1092 void didReceiveFlowControl(int quota);
1042 void didFail(String message); 1093 void didFail(String message);
1043 void didClose(bool wasClean, int code, String reason); 1094 void didClose(bool wasClean, int code, String reason);
1044 } 1095 }
1045 1096
1046 1097
1047 class _WebSocketClientProxyImpl extends bindings.Proxy { 1098 class _WebSocketClientProxyImpl extends bindings.Proxy {
1048 _WebSocketClientProxyImpl.fromEndpoint( 1099 _WebSocketClientProxyImpl.fromEndpoint(
1049 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 1100 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
1050 1101
1051 _WebSocketClientProxyImpl.fromHandle(core.MojoHandle handle) : 1102 _WebSocketClientProxyImpl.fromHandle(core.MojoHandle handle) :
1052 super.fromHandle(handle); 1103 super.fromHandle(handle);
1053 1104
1054 _WebSocketClientProxyImpl.unbound() : super.unbound(); 1105 _WebSocketClientProxyImpl.unbound() : super.unbound();
1055 1106
1056 static _WebSocketClientProxyImpl newFromEndpoint( 1107 static _WebSocketClientProxyImpl newFromEndpoint(
1057 core.MojoMessagePipeEndpoint endpoint) { 1108 core.MojoMessagePipeEndpoint endpoint) {
1058 assert(endpoint.setDescription("For _WebSocketClientProxyImpl")); 1109 assert(endpoint.setDescription("For _WebSocketClientProxyImpl"));
1059 return new _WebSocketClientProxyImpl.fromEndpoint(endpoint); 1110 return new _WebSocketClientProxyImpl.fromEndpoint(endpoint);
1060 } 1111 }
1061 1112
1113 service_describer.ServiceDescription get serviceDescription =>
1114 new _WebSocketClientServiceDescription();
1115
1062 void handleResponse(bindings.ServiceMessage message) { 1116 void handleResponse(bindings.ServiceMessage message) {
1063 switch (message.header.type) { 1117 switch (message.header.type) {
1064 default: 1118 default:
1065 proxyError("Unexpected message type: ${message.header.type}"); 1119 proxyError("Unexpected message type: ${message.header.type}");
1066 close(immediate: true); 1120 close(immediate: true);
1067 break; 1121 break;
1068 } 1122 }
1069 } 1123 }
1070 1124
1071 String toString() { 1125 String toString() {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 assert(_impl == null); 1311 assert(_impl == null);
1258 _impl = d; 1312 _impl = d;
1259 } 1313 }
1260 1314
1261 String toString() { 1315 String toString() {
1262 var superString = super.toString(); 1316 var superString = super.toString();
1263 return "WebSocketClientStub($superString)"; 1317 return "WebSocketClientStub($superString)";
1264 } 1318 }
1265 1319
1266 int get version => 0; 1320 int get version => 0;
1321
1322 service_describer.ServiceDescription get serviceDescription =>
1323 new _WebSocketClientServiceDescription();
1267 } 1324 }
1268 1325
1269 1326
1327
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698