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 http_server_mojom; | 5 library http_server_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_services/http_server/http_request.mojom.dart' as http_reque
st_mojom; | 13 import 'package:mojo_services/http_server/http_request.mojom.dart' as http_reque
st_mojom; |
12 import 'package:mojo_services/http_server/http_response.mojom.dart' as http_resp
onse_mojom; | 14 import 'package:mojo_services/http_server/http_response.mojom.dart' as http_resp
onse_mojom; |
13 | 15 |
14 | 16 |
15 | 17 |
16 class _HttpServerSetHandlerParams extends bindings.Struct { | 18 class _HttpServerSetHandlerParams extends bindings.Struct { |
17 static const List<bindings.StructDataHeader> kVersions = const [ | 19 static const List<bindings.StructDataHeader> kVersions = const [ |
18 const bindings.StructDataHeader(24, 0) | 20 const bindings.StructDataHeader(24, 0) |
19 ]; | 21 ]; |
20 String pattern = null; | 22 String pattern = null; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 "handler: $handler" ")"; | 82 "handler: $handler" ")"; |
81 } | 83 } |
82 | 84 |
83 Map toJson() { | 85 Map toJson() { |
84 throw new bindings.MojoCodecError( | 86 throw new bindings.MojoCodecError( |
85 'Object containing handles cannot be encoded to JSON.'); | 87 'Object containing handles cannot be encoded to JSON.'); |
86 } | 88 } |
87 } | 89 } |
88 | 90 |
89 | 91 |
| 92 |
| 93 |
90 class HttpServerSetHandlerResponseParams extends bindings.Struct { | 94 class HttpServerSetHandlerResponseParams extends bindings.Struct { |
91 static const List<bindings.StructDataHeader> kVersions = const [ | 95 static const List<bindings.StructDataHeader> kVersions = const [ |
92 const bindings.StructDataHeader(16, 0) | 96 const bindings.StructDataHeader(16, 0) |
93 ]; | 97 ]; |
94 bool success = false; | 98 bool success = false; |
95 | 99 |
96 HttpServerSetHandlerResponseParams() : super(kVersions.last.size); | 100 HttpServerSetHandlerResponseParams() : super(kVersions.last.size); |
97 | 101 |
98 static HttpServerSetHandlerResponseParams deserialize(bindings.Message message
) { | 102 static HttpServerSetHandlerResponseParams deserialize(bindings.Message message
) { |
99 var decoder = new bindings.Decoder(message); | 103 var decoder = new bindings.Decoder(message); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 151 } |
148 | 152 |
149 Map toJson() { | 153 Map toJson() { |
150 Map map = new Map(); | 154 Map map = new Map(); |
151 map["success"] = success; | 155 map["success"] = success; |
152 return map; | 156 return map; |
153 } | 157 } |
154 } | 158 } |
155 | 159 |
156 | 160 |
| 161 |
| 162 |
157 class _HttpServerGetPortParams extends bindings.Struct { | 163 class _HttpServerGetPortParams extends bindings.Struct { |
158 static const List<bindings.StructDataHeader> kVersions = const [ | 164 static const List<bindings.StructDataHeader> kVersions = const [ |
159 const bindings.StructDataHeader(8, 0) | 165 const bindings.StructDataHeader(8, 0) |
160 ]; | 166 ]; |
161 | 167 |
162 _HttpServerGetPortParams() : super(kVersions.last.size); | 168 _HttpServerGetPortParams() : super(kVersions.last.size); |
163 | 169 |
164 static _HttpServerGetPortParams deserialize(bindings.Message message) { | 170 static _HttpServerGetPortParams deserialize(bindings.Message message) { |
165 var decoder = new bindings.Decoder(message); | 171 var decoder = new bindings.Decoder(message); |
166 var result = decode(decoder); | 172 var result = decode(decoder); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return "_HttpServerGetPortParams("")"; | 211 return "_HttpServerGetPortParams("")"; |
206 } | 212 } |
207 | 213 |
208 Map toJson() { | 214 Map toJson() { |
209 Map map = new Map(); | 215 Map map = new Map(); |
210 return map; | 216 return map; |
211 } | 217 } |
212 } | 218 } |
213 | 219 |
214 | 220 |
| 221 |
| 222 |
215 class HttpServerGetPortResponseParams extends bindings.Struct { | 223 class HttpServerGetPortResponseParams extends bindings.Struct { |
216 static const List<bindings.StructDataHeader> kVersions = const [ | 224 static const List<bindings.StructDataHeader> kVersions = const [ |
217 const bindings.StructDataHeader(16, 0) | 225 const bindings.StructDataHeader(16, 0) |
218 ]; | 226 ]; |
219 int port = 0; | 227 int port = 0; |
220 | 228 |
221 HttpServerGetPortResponseParams() : super(kVersions.last.size); | 229 HttpServerGetPortResponseParams() : super(kVersions.last.size); |
222 | 230 |
223 static HttpServerGetPortResponseParams deserialize(bindings.Message message) { | 231 static HttpServerGetPortResponseParams deserialize(bindings.Message message) { |
224 var decoder = new bindings.Decoder(message); | 232 var decoder = new bindings.Decoder(message); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 280 } |
273 | 281 |
274 Map toJson() { | 282 Map toJson() { |
275 Map map = new Map(); | 283 Map map = new Map(); |
276 map["port"] = port; | 284 map["port"] = port; |
277 return map; | 285 return map; |
278 } | 286 } |
279 } | 287 } |
280 | 288 |
281 | 289 |
| 290 |
| 291 |
282 class _HttpHandlerHandleRequestParams extends bindings.Struct { | 292 class _HttpHandlerHandleRequestParams extends bindings.Struct { |
283 static const List<bindings.StructDataHeader> kVersions = const [ | 293 static const List<bindings.StructDataHeader> kVersions = const [ |
284 const bindings.StructDataHeader(16, 0) | 294 const bindings.StructDataHeader(16, 0) |
285 ]; | 295 ]; |
286 http_request_mojom.HttpRequest request = null; | 296 http_request_mojom.HttpRequest request = null; |
287 | 297 |
288 _HttpHandlerHandleRequestParams() : super(kVersions.last.size); | 298 _HttpHandlerHandleRequestParams() : super(kVersions.last.size); |
289 | 299 |
290 static _HttpHandlerHandleRequestParams deserialize(bindings.Message message) { | 300 static _HttpHandlerHandleRequestParams deserialize(bindings.Message message) { |
291 var decoder = new bindings.Decoder(message); | 301 var decoder = new bindings.Decoder(message); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 "request: $request" ")"; | 349 "request: $request" ")"; |
340 } | 350 } |
341 | 351 |
342 Map toJson() { | 352 Map toJson() { |
343 throw new bindings.MojoCodecError( | 353 throw new bindings.MojoCodecError( |
344 'Object containing handles cannot be encoded to JSON.'); | 354 'Object containing handles cannot be encoded to JSON.'); |
345 } | 355 } |
346 } | 356 } |
347 | 357 |
348 | 358 |
| 359 |
| 360 |
349 class HttpHandlerHandleRequestResponseParams extends bindings.Struct { | 361 class HttpHandlerHandleRequestResponseParams extends bindings.Struct { |
350 static const List<bindings.StructDataHeader> kVersions = const [ | 362 static const List<bindings.StructDataHeader> kVersions = const [ |
351 const bindings.StructDataHeader(16, 0) | 363 const bindings.StructDataHeader(16, 0) |
352 ]; | 364 ]; |
353 http_response_mojom.HttpResponse response = null; | 365 http_response_mojom.HttpResponse response = null; |
354 | 366 |
355 HttpHandlerHandleRequestResponseParams() : super(kVersions.last.size); | 367 HttpHandlerHandleRequestResponseParams() : super(kVersions.last.size); |
356 | 368 |
357 static HttpHandlerHandleRequestResponseParams deserialize(bindings.Message mes
sage) { | 369 static HttpHandlerHandleRequestResponseParams deserialize(bindings.Message mes
sage) { |
358 var decoder = new bindings.Decoder(message); | 370 var decoder = new bindings.Decoder(message); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 return "HttpHandlerHandleRequestResponseParams(" | 417 return "HttpHandlerHandleRequestResponseParams(" |
406 "response: $response" ")"; | 418 "response: $response" ")"; |
407 } | 419 } |
408 | 420 |
409 Map toJson() { | 421 Map toJson() { |
410 throw new bindings.MojoCodecError( | 422 throw new bindings.MojoCodecError( |
411 'Object containing handles cannot be encoded to JSON.'); | 423 'Object containing handles cannot be encoded to JSON.'); |
412 } | 424 } |
413 } | 425 } |
414 | 426 |
| 427 |
| 428 |
| 429 |
415 const int _HttpServer_setHandlerName = 0; | 430 const int _HttpServer_setHandlerName = 0; |
416 const int _HttpServer_getPortName = 1; | 431 const int _HttpServer_getPortName = 1; |
417 | 432 |
| 433 |
| 434 |
| 435 class _HttpServerServiceDescription implements service_describer.ServiceDescript
ion { |
| 436 dynamic getTopLevelInterface([Function responseFactory = null]) => null; |
| 437 |
| 438 dynamic getTypeDefinition(String typeKey, [Function responseFactory = null]) =
> |
| 439 null; |
| 440 |
| 441 dynamic getAllTypeDefinitions([Function responseFactory = null]) => null; |
| 442 } |
| 443 |
418 abstract class HttpServer { | 444 abstract class HttpServer { |
419 static const String serviceName = null; | 445 static const String serviceName = null; |
420 dynamic setHandler(String pattern,Object handler,[Function responseFactory = n
ull]); | 446 dynamic setHandler(String pattern,Object handler,[Function responseFactory = n
ull]); |
421 dynamic getPort([Function responseFactory = null]); | 447 dynamic getPort([Function responseFactory = null]); |
422 } | 448 } |
423 | 449 |
424 | 450 |
425 class _HttpServerProxyImpl extends bindings.Proxy { | 451 class _HttpServerProxyImpl extends bindings.Proxy { |
426 _HttpServerProxyImpl.fromEndpoint( | 452 _HttpServerProxyImpl.fromEndpoint( |
427 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 453 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
428 | 454 |
429 _HttpServerProxyImpl.fromHandle(core.MojoHandle handle) : | 455 _HttpServerProxyImpl.fromHandle(core.MojoHandle handle) : |
430 super.fromHandle(handle); | 456 super.fromHandle(handle); |
431 | 457 |
432 _HttpServerProxyImpl.unbound() : super.unbound(); | 458 _HttpServerProxyImpl.unbound() : super.unbound(); |
433 | 459 |
434 static _HttpServerProxyImpl newFromEndpoint( | 460 static _HttpServerProxyImpl newFromEndpoint( |
435 core.MojoMessagePipeEndpoint endpoint) { | 461 core.MojoMessagePipeEndpoint endpoint) { |
436 assert(endpoint.setDescription("For _HttpServerProxyImpl")); | 462 assert(endpoint.setDescription("For _HttpServerProxyImpl")); |
437 return new _HttpServerProxyImpl.fromEndpoint(endpoint); | 463 return new _HttpServerProxyImpl.fromEndpoint(endpoint); |
438 } | 464 } |
439 | 465 |
| 466 service_describer.ServiceDescription get serviceDescription => |
| 467 new _HttpServerServiceDescription(); |
| 468 |
440 void handleResponse(bindings.ServiceMessage message) { | 469 void handleResponse(bindings.ServiceMessage message) { |
441 switch (message.header.type) { | 470 switch (message.header.type) { |
442 case _HttpServer_setHandlerName: | 471 case _HttpServer_setHandlerName: |
443 var r = HttpServerSetHandlerResponseParams.deserialize( | 472 var r = HttpServerSetHandlerResponseParams.deserialize( |
444 message.payload); | 473 message.payload); |
445 if (!message.header.hasRequestId) { | 474 if (!message.header.hasRequestId) { |
446 proxyError("Expected a message with a valid request Id."); | 475 proxyError("Expected a message with a valid request Id."); |
447 return; | 476 return; |
448 } | 477 } |
449 Completer c = completerMap[message.header.requestId]; | 478 Completer c = completerMap[message.header.requestId]; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 assert(_impl == null); | 700 assert(_impl == null); |
672 _impl = d; | 701 _impl = d; |
673 } | 702 } |
674 | 703 |
675 String toString() { | 704 String toString() { |
676 var superString = super.toString(); | 705 var superString = super.toString(); |
677 return "HttpServerStub($superString)"; | 706 return "HttpServerStub($superString)"; |
678 } | 707 } |
679 | 708 |
680 int get version => 0; | 709 int get version => 0; |
| 710 |
| 711 service_describer.ServiceDescription get serviceDescription => |
| 712 new _HttpServerServiceDescription(); |
681 } | 713 } |
682 | 714 |
683 const int _HttpHandler_handleRequestName = 0; | 715 const int _HttpHandler_handleRequestName = 0; |
684 | 716 |
| 717 |
| 718 |
| 719 class _HttpHandlerServiceDescription implements service_describer.ServiceDescrip
tion { |
| 720 dynamic getTopLevelInterface([Function responseFactory = null]) => null; |
| 721 |
| 722 dynamic getTypeDefinition(String typeKey, [Function responseFactory = null]) =
> |
| 723 null; |
| 724 |
| 725 dynamic getAllTypeDefinitions([Function responseFactory = null]) => null; |
| 726 } |
| 727 |
685 abstract class HttpHandler { | 728 abstract class HttpHandler { |
686 static const String serviceName = null; | 729 static const String serviceName = null; |
687 dynamic handleRequest(http_request_mojom.HttpRequest request,[Function respons
eFactory = null]); | 730 dynamic handleRequest(http_request_mojom.HttpRequest request,[Function respons
eFactory = null]); |
688 } | 731 } |
689 | 732 |
690 | 733 |
691 class _HttpHandlerProxyImpl extends bindings.Proxy { | 734 class _HttpHandlerProxyImpl extends bindings.Proxy { |
692 _HttpHandlerProxyImpl.fromEndpoint( | 735 _HttpHandlerProxyImpl.fromEndpoint( |
693 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 736 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
694 | 737 |
695 _HttpHandlerProxyImpl.fromHandle(core.MojoHandle handle) : | 738 _HttpHandlerProxyImpl.fromHandle(core.MojoHandle handle) : |
696 super.fromHandle(handle); | 739 super.fromHandle(handle); |
697 | 740 |
698 _HttpHandlerProxyImpl.unbound() : super.unbound(); | 741 _HttpHandlerProxyImpl.unbound() : super.unbound(); |
699 | 742 |
700 static _HttpHandlerProxyImpl newFromEndpoint( | 743 static _HttpHandlerProxyImpl newFromEndpoint( |
701 core.MojoMessagePipeEndpoint endpoint) { | 744 core.MojoMessagePipeEndpoint endpoint) { |
702 assert(endpoint.setDescription("For _HttpHandlerProxyImpl")); | 745 assert(endpoint.setDescription("For _HttpHandlerProxyImpl")); |
703 return new _HttpHandlerProxyImpl.fromEndpoint(endpoint); | 746 return new _HttpHandlerProxyImpl.fromEndpoint(endpoint); |
704 } | 747 } |
705 | 748 |
| 749 service_describer.ServiceDescription get serviceDescription => |
| 750 new _HttpHandlerServiceDescription(); |
| 751 |
706 void handleResponse(bindings.ServiceMessage message) { | 752 void handleResponse(bindings.ServiceMessage message) { |
707 switch (message.header.type) { | 753 switch (message.header.type) { |
708 case _HttpHandler_handleRequestName: | 754 case _HttpHandler_handleRequestName: |
709 var r = HttpHandlerHandleRequestResponseParams.deserialize( | 755 var r = HttpHandlerHandleRequestResponseParams.deserialize( |
710 message.payload); | 756 message.payload); |
711 if (!message.header.hasRequestId) { | 757 if (!message.header.hasRequestId) { |
712 proxyError("Expected a message with a valid request Id."); | 758 proxyError("Expected a message with a valid request Id."); |
713 return; | 759 return; |
714 } | 760 } |
715 Completer c = completerMap[message.header.requestId]; | 761 Completer c = completerMap[message.header.requestId]; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 assert(_impl == null); | 927 assert(_impl == null); |
882 _impl = d; | 928 _impl = d; |
883 } | 929 } |
884 | 930 |
885 String toString() { | 931 String toString() { |
886 var superString = super.toString(); | 932 var superString = super.toString(); |
887 return "HttpHandlerStub($superString)"; | 933 return "HttpHandlerStub($superString)"; |
888 } | 934 } |
889 | 935 |
890 int get version => 0; | 936 int get version => 0; |
| 937 |
| 938 service_describer.ServiceDescription get serviceDescription => |
| 939 new _HttpHandlerServiceDescription(); |
891 } | 940 } |
892 | 941 |
893 | 942 |
| 943 |
| 944 |
OLD | NEW |