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

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

Issue 1449203002: Check in generated Dart bindings and add presubmit script (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 library http_server_mojom;
6
7 import 'dart:async';
8
9 import 'package:mojo/bindings.dart' as bindings;
10 import 'package:mojo/core.dart' as core;
11 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;
13
14
15
16 class HttpServerSetHandlerParams extends bindings.Struct {
17 static const List<bindings.StructDataHeader> kVersions = const [
18 const bindings.StructDataHeader(24, 0)
19 ];
20 String pattern = null;
21 Object handler = null;
22
23 HttpServerSetHandlerParams() : super(kVersions.last.size);
24
25 static HttpServerSetHandlerParams deserialize(bindings.Message message) {
26 var decoder = new bindings.Decoder(message);
27 var result = decode(decoder);
28 if (decoder.excessHandles != null) {
29 decoder.excessHandles.forEach((h) => h.close());
30 }
31 return result;
32 }
33
34 static HttpServerSetHandlerParams decode(bindings.Decoder decoder0) {
35 if (decoder0 == null) {
36 return null;
37 }
38 HttpServerSetHandlerParams result = new HttpServerSetHandlerParams();
39
40 var mainDataHeader = decoder0.decodeStructDataHeader();
41 if (mainDataHeader.version <= kVersions.last.version) {
42 // Scan in reverse order to optimize for more recent versions.
43 for (int i = kVersions.length - 1; i >= 0; --i) {
44 if (mainDataHeader.version >= kVersions[i].version) {
45 if (mainDataHeader.size == kVersions[i].size) {
46 // Found a match.
47 break;
48 }
49 throw new bindings.MojoCodecError(
50 'Header size doesn\'t correspond to known version size.');
51 }
52 }
53 } else if (mainDataHeader.size < kVersions.last.size) {
54 throw new bindings.MojoCodecError(
55 'Message newer than the last known version cannot be shorter than '
56 'required by the last known version.');
57 }
58 if (mainDataHeader.version >= 0) {
59
60 result.pattern = decoder0.decodeString(8, false);
61 }
62 if (mainDataHeader.version >= 0) {
63
64 result.handler = decoder0.decodeServiceInterface(16, false, HttpHandlerPro xy.newFromEndpoint);
65 }
66 return result;
67 }
68
69 void encode(bindings.Encoder encoder) {
70 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
71
72 encoder0.encodeString(pattern, 8, false);
73
74 encoder0.encodeInterface(handler, 16, false);
75 }
76
77 String toString() {
78 return "HttpServerSetHandlerParams("
79 "pattern: $pattern" ", "
80 "handler: $handler" ")";
81 }
82
83 Map toJson() {
84 throw new bindings.MojoCodecError(
85 'Object containing handles cannot be encoded to JSON.');
86 }
87 }
88
89
90 class HttpServerSetHandlerResponseParams extends bindings.Struct {
91 static const List<bindings.StructDataHeader> kVersions = const [
92 const bindings.StructDataHeader(16, 0)
93 ];
94 bool success = false;
95
96 HttpServerSetHandlerResponseParams() : super(kVersions.last.size);
97
98 static HttpServerSetHandlerResponseParams deserialize(bindings.Message message ) {
99 var decoder = new bindings.Decoder(message);
100 var result = decode(decoder);
101 if (decoder.excessHandles != null) {
102 decoder.excessHandles.forEach((h) => h.close());
103 }
104 return result;
105 }
106
107 static HttpServerSetHandlerResponseParams decode(bindings.Decoder decoder0) {
108 if (decoder0 == null) {
109 return null;
110 }
111 HttpServerSetHandlerResponseParams result = new HttpServerSetHandlerResponse Params();
112
113 var mainDataHeader = decoder0.decodeStructDataHeader();
114 if (mainDataHeader.version <= kVersions.last.version) {
115 // Scan in reverse order to optimize for more recent versions.
116 for (int i = kVersions.length - 1; i >= 0; --i) {
117 if (mainDataHeader.version >= kVersions[i].version) {
118 if (mainDataHeader.size == kVersions[i].size) {
119 // Found a match.
120 break;
121 }
122 throw new bindings.MojoCodecError(
123 'Header size doesn\'t correspond to known version size.');
124 }
125 }
126 } else if (mainDataHeader.size < kVersions.last.size) {
127 throw new bindings.MojoCodecError(
128 'Message newer than the last known version cannot be shorter than '
129 'required by the last known version.');
130 }
131 if (mainDataHeader.version >= 0) {
132
133 result.success = decoder0.decodeBool(8, 0);
134 }
135 return result;
136 }
137
138 void encode(bindings.Encoder encoder) {
139 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
140
141 encoder0.encodeBool(success, 8, 0);
142 }
143
144 String toString() {
145 return "HttpServerSetHandlerResponseParams("
146 "success: $success" ")";
147 }
148
149 Map toJson() {
150 Map map = new Map();
151 map["success"] = success;
152 return map;
153 }
154 }
155
156
157 class HttpServerGetPortParams extends bindings.Struct {
158 static const List<bindings.StructDataHeader> kVersions = const [
159 const bindings.StructDataHeader(8, 0)
160 ];
161
162 HttpServerGetPortParams() : super(kVersions.last.size);
163
164 static HttpServerGetPortParams deserialize(bindings.Message message) {
165 var decoder = new bindings.Decoder(message);
166 var result = decode(decoder);
167 if (decoder.excessHandles != null) {
168 decoder.excessHandles.forEach((h) => h.close());
169 }
170 return result;
171 }
172
173 static HttpServerGetPortParams decode(bindings.Decoder decoder0) {
174 if (decoder0 == null) {
175 return null;
176 }
177 HttpServerGetPortParams result = new HttpServerGetPortParams();
178
179 var mainDataHeader = decoder0.decodeStructDataHeader();
180 if (mainDataHeader.version <= kVersions.last.version) {
181 // Scan in reverse order to optimize for more recent versions.
182 for (int i = kVersions.length - 1; i >= 0; --i) {
183 if (mainDataHeader.version >= kVersions[i].version) {
184 if (mainDataHeader.size == kVersions[i].size) {
185 // Found a match.
186 break;
187 }
188 throw new bindings.MojoCodecError(
189 'Header size doesn\'t correspond to known version size.');
190 }
191 }
192 } else if (mainDataHeader.size < kVersions.last.size) {
193 throw new bindings.MojoCodecError(
194 'Message newer than the last known version cannot be shorter than '
195 'required by the last known version.');
196 }
197 return result;
198 }
199
200 void encode(bindings.Encoder encoder) {
201 encoder.getStructEncoderAtOffset(kVersions.last);
202 }
203
204 String toString() {
205 return "HttpServerGetPortParams("")";
206 }
207
208 Map toJson() {
209 Map map = new Map();
210 return map;
211 }
212 }
213
214
215 class HttpServerGetPortResponseParams extends bindings.Struct {
216 static const List<bindings.StructDataHeader> kVersions = const [
217 const bindings.StructDataHeader(16, 0)
218 ];
219 int port = 0;
220
221 HttpServerGetPortResponseParams() : super(kVersions.last.size);
222
223 static HttpServerGetPortResponseParams deserialize(bindings.Message message) {
224 var decoder = new bindings.Decoder(message);
225 var result = decode(decoder);
226 if (decoder.excessHandles != null) {
227 decoder.excessHandles.forEach((h) => h.close());
228 }
229 return result;
230 }
231
232 static HttpServerGetPortResponseParams decode(bindings.Decoder decoder0) {
233 if (decoder0 == null) {
234 return null;
235 }
236 HttpServerGetPortResponseParams result = new HttpServerGetPortResponseParams ();
237
238 var mainDataHeader = decoder0.decodeStructDataHeader();
239 if (mainDataHeader.version <= kVersions.last.version) {
240 // Scan in reverse order to optimize for more recent versions.
241 for (int i = kVersions.length - 1; i >= 0; --i) {
242 if (mainDataHeader.version >= kVersions[i].version) {
243 if (mainDataHeader.size == kVersions[i].size) {
244 // Found a match.
245 break;
246 }
247 throw new bindings.MojoCodecError(
248 'Header size doesn\'t correspond to known version size.');
249 }
250 }
251 } else if (mainDataHeader.size < kVersions.last.size) {
252 throw new bindings.MojoCodecError(
253 'Message newer than the last known version cannot be shorter than '
254 'required by the last known version.');
255 }
256 if (mainDataHeader.version >= 0) {
257
258 result.port = decoder0.decodeUint16(8);
259 }
260 return result;
261 }
262
263 void encode(bindings.Encoder encoder) {
264 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
265
266 encoder0.encodeUint16(port, 8);
267 }
268
269 String toString() {
270 return "HttpServerGetPortResponseParams("
271 "port: $port" ")";
272 }
273
274 Map toJson() {
275 Map map = new Map();
276 map["port"] = port;
277 return map;
278 }
279 }
280
281
282 class HttpHandlerHandleRequestParams extends bindings.Struct {
283 static const List<bindings.StructDataHeader> kVersions = const [
284 const bindings.StructDataHeader(16, 0)
285 ];
286 http_request_mojom.HttpRequest request = null;
287
288 HttpHandlerHandleRequestParams() : super(kVersions.last.size);
289
290 static HttpHandlerHandleRequestParams deserialize(bindings.Message message) {
291 var decoder = new bindings.Decoder(message);
292 var result = decode(decoder);
293 if (decoder.excessHandles != null) {
294 decoder.excessHandles.forEach((h) => h.close());
295 }
296 return result;
297 }
298
299 static HttpHandlerHandleRequestParams decode(bindings.Decoder decoder0) {
300 if (decoder0 == null) {
301 return null;
302 }
303 HttpHandlerHandleRequestParams result = new HttpHandlerHandleRequestParams() ;
304
305 var mainDataHeader = decoder0.decodeStructDataHeader();
306 if (mainDataHeader.version <= kVersions.last.version) {
307 // Scan in reverse order to optimize for more recent versions.
308 for (int i = kVersions.length - 1; i >= 0; --i) {
309 if (mainDataHeader.version >= kVersions[i].version) {
310 if (mainDataHeader.size == kVersions[i].size) {
311 // Found a match.
312 break;
313 }
314 throw new bindings.MojoCodecError(
315 'Header size doesn\'t correspond to known version size.');
316 }
317 }
318 } else if (mainDataHeader.size < kVersions.last.size) {
319 throw new bindings.MojoCodecError(
320 'Message newer than the last known version cannot be shorter than '
321 'required by the last known version.');
322 }
323 if (mainDataHeader.version >= 0) {
324
325 var decoder1 = decoder0.decodePointer(8, false);
326 result.request = http_request_mojom.HttpRequest.decode(decoder1);
327 }
328 return result;
329 }
330
331 void encode(bindings.Encoder encoder) {
332 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
333
334 encoder0.encodeStruct(request, 8, false);
335 }
336
337 String toString() {
338 return "HttpHandlerHandleRequestParams("
339 "request: $request" ")";
340 }
341
342 Map toJson() {
343 throw new bindings.MojoCodecError(
344 'Object containing handles cannot be encoded to JSON.');
345 }
346 }
347
348
349 class HttpHandlerHandleRequestResponseParams extends bindings.Struct {
350 static const List<bindings.StructDataHeader> kVersions = const [
351 const bindings.StructDataHeader(16, 0)
352 ];
353 http_response_mojom.HttpResponse response = null;
354
355 HttpHandlerHandleRequestResponseParams() : super(kVersions.last.size);
356
357 static HttpHandlerHandleRequestResponseParams deserialize(bindings.Message mes sage) {
358 var decoder = new bindings.Decoder(message);
359 var result = decode(decoder);
360 if (decoder.excessHandles != null) {
361 decoder.excessHandles.forEach((h) => h.close());
362 }
363 return result;
364 }
365
366 static HttpHandlerHandleRequestResponseParams decode(bindings.Decoder decoder0 ) {
367 if (decoder0 == null) {
368 return null;
369 }
370 HttpHandlerHandleRequestResponseParams result = new HttpHandlerHandleRequest ResponseParams();
371
372 var mainDataHeader = decoder0.decodeStructDataHeader();
373 if (mainDataHeader.version <= kVersions.last.version) {
374 // Scan in reverse order to optimize for more recent versions.
375 for (int i = kVersions.length - 1; i >= 0; --i) {
376 if (mainDataHeader.version >= kVersions[i].version) {
377 if (mainDataHeader.size == kVersions[i].size) {
378 // Found a match.
379 break;
380 }
381 throw new bindings.MojoCodecError(
382 'Header size doesn\'t correspond to known version size.');
383 }
384 }
385 } else if (mainDataHeader.size < kVersions.last.size) {
386 throw new bindings.MojoCodecError(
387 'Message newer than the last known version cannot be shorter than '
388 'required by the last known version.');
389 }
390 if (mainDataHeader.version >= 0) {
391
392 var decoder1 = decoder0.decodePointer(8, false);
393 result.response = http_response_mojom.HttpResponse.decode(decoder1);
394 }
395 return result;
396 }
397
398 void encode(bindings.Encoder encoder) {
399 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
400
401 encoder0.encodeStruct(response, 8, false);
402 }
403
404 String toString() {
405 return "HttpHandlerHandleRequestResponseParams("
406 "response: $response" ")";
407 }
408
409 Map toJson() {
410 throw new bindings.MojoCodecError(
411 'Object containing handles cannot be encoded to JSON.');
412 }
413 }
414
415 const int kHttpServer_setHandler_name = 0;
416 const int kHttpServer_getPort_name = 1;
417
418 const String HttpServerName =
419 'http_server::HttpServer';
420
421 abstract class HttpServer {
422 dynamic setHandler(String pattern,Object handler,[Function responseFactory = n ull]);
423 dynamic getPort([Function responseFactory = null]);
424
425 }
426
427
428 class HttpServerProxyImpl extends bindings.Proxy {
429 HttpServerProxyImpl.fromEndpoint(
430 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
431
432 HttpServerProxyImpl.fromHandle(core.MojoHandle handle) :
433 super.fromHandle(handle);
434
435 HttpServerProxyImpl.unbound() : super.unbound();
436
437 static HttpServerProxyImpl newFromEndpoint(
438 core.MojoMessagePipeEndpoint endpoint) {
439 assert(endpoint.setDescription("For HttpServerProxyImpl"));
440 return new HttpServerProxyImpl.fromEndpoint(endpoint);
441 }
442
443 String get name => HttpServerName;
444
445 void handleResponse(bindings.ServiceMessage message) {
446 switch (message.header.type) {
447 case kHttpServer_setHandler_name:
448 var r = HttpServerSetHandlerResponseParams.deserialize(
449 message.payload);
450 if (!message.header.hasRequestId) {
451 proxyError("Expected a message with a valid request Id.");
452 return;
453 }
454 Completer c = completerMap[message.header.requestId];
455 if (c == null) {
456 proxyError(
457 "Message had unknown request Id: ${message.header.requestId}");
458 return;
459 }
460 completerMap.remove(message.header.requestId);
461 if (c.isCompleted) {
462 proxyError("Response completer already completed");
463 return;
464 }
465 c.complete(r);
466 break;
467 case kHttpServer_getPort_name:
468 var r = HttpServerGetPortResponseParams.deserialize(
469 message.payload);
470 if (!message.header.hasRequestId) {
471 proxyError("Expected a message with a valid request Id.");
472 return;
473 }
474 Completer c = completerMap[message.header.requestId];
475 if (c == null) {
476 proxyError(
477 "Message had unknown request Id: ${message.header.requestId}");
478 return;
479 }
480 completerMap.remove(message.header.requestId);
481 if (c.isCompleted) {
482 proxyError("Response completer already completed");
483 return;
484 }
485 c.complete(r);
486 break;
487 default:
488 proxyError("Unexpected message type: ${message.header.type}");
489 close(immediate: true);
490 break;
491 }
492 }
493
494 String toString() {
495 var superString = super.toString();
496 return "HttpServerProxyImpl($superString)";
497 }
498 }
499
500
501 class _HttpServerProxyCalls implements HttpServer {
502 HttpServerProxyImpl _proxyImpl;
503
504 _HttpServerProxyCalls(this._proxyImpl);
505 dynamic setHandler(String pattern,Object handler,[Function responseFactory = null]) {
506 var params = new HttpServerSetHandlerParams();
507 params.pattern = pattern;
508 params.handler = handler;
509 return _proxyImpl.sendMessageWithRequestId(
510 params,
511 kHttpServer_setHandler_name,
512 -1,
513 bindings.MessageHeader.kMessageExpectsResponse);
514 }
515 dynamic getPort([Function responseFactory = null]) {
516 var params = new HttpServerGetPortParams();
517 return _proxyImpl.sendMessageWithRequestId(
518 params,
519 kHttpServer_getPort_name,
520 -1,
521 bindings.MessageHeader.kMessageExpectsResponse);
522 }
523 }
524
525
526 class HttpServerProxy implements bindings.ProxyBase {
527 final bindings.Proxy impl;
528 HttpServer ptr;
529 final String name = HttpServerName;
530
531 HttpServerProxy(HttpServerProxyImpl proxyImpl) :
532 impl = proxyImpl,
533 ptr = new _HttpServerProxyCalls(proxyImpl);
534
535 HttpServerProxy.fromEndpoint(
536 core.MojoMessagePipeEndpoint endpoint) :
537 impl = new HttpServerProxyImpl.fromEndpoint(endpoint) {
538 ptr = new _HttpServerProxyCalls(impl);
539 }
540
541 HttpServerProxy.fromHandle(core.MojoHandle handle) :
542 impl = new HttpServerProxyImpl.fromHandle(handle) {
543 ptr = new _HttpServerProxyCalls(impl);
544 }
545
546 HttpServerProxy.unbound() :
547 impl = new HttpServerProxyImpl.unbound() {
548 ptr = new _HttpServerProxyCalls(impl);
549 }
550
551 factory HttpServerProxy.connectToService(
552 bindings.ServiceConnector s, String url) {
553 HttpServerProxy p = new HttpServerProxy.unbound();
554 s.connectToService(url, p);
555 return p;
556 }
557
558 static HttpServerProxy newFromEndpoint(
559 core.MojoMessagePipeEndpoint endpoint) {
560 assert(endpoint.setDescription("For HttpServerProxy"));
561 return new HttpServerProxy.fromEndpoint(endpoint);
562 }
563
564 Future close({bool immediate: false}) => impl.close(immediate: immediate);
565
566 Future responseOrError(Future f) => impl.responseOrError(f);
567
568 Future get errorFuture => impl.errorFuture;
569
570 int get version => impl.version;
571
572 Future<int> queryVersion() => impl.queryVersion();
573
574 void requireVersion(int requiredVersion) {
575 impl.requireVersion(requiredVersion);
576 }
577
578 String toString() {
579 return "HttpServerProxy($impl)";
580 }
581 }
582
583
584 class HttpServerStub extends bindings.Stub {
585 HttpServer _impl = null;
586
587 HttpServerStub.fromEndpoint(
588 core.MojoMessagePipeEndpoint endpoint, [this._impl])
589 : super.fromEndpoint(endpoint);
590
591 HttpServerStub.fromHandle(core.MojoHandle handle, [this._impl])
592 : super.fromHandle(handle);
593
594 HttpServerStub.unbound() : super.unbound();
595
596 static HttpServerStub newFromEndpoint(
597 core.MojoMessagePipeEndpoint endpoint) {
598 assert(endpoint.setDescription("For HttpServerStub"));
599 return new HttpServerStub.fromEndpoint(endpoint);
600 }
601
602 static const String name = HttpServerName;
603
604
605 HttpServerSetHandlerResponseParams _HttpServerSetHandlerResponseParamsFactory( bool success) {
606 var result = new HttpServerSetHandlerResponseParams();
607 result.success = success;
608 return result;
609 }
610 HttpServerGetPortResponseParams _HttpServerGetPortResponseParamsFactory(int po rt) {
611 var result = new HttpServerGetPortResponseParams();
612 result.port = port;
613 return result;
614 }
615
616 dynamic handleMessage(bindings.ServiceMessage message) {
617 if (bindings.ControlMessageHandler.isControlMessage(message)) {
618 return bindings.ControlMessageHandler.handleMessage(this,
619 0,
620 message);
621 }
622 assert(_impl != null);
623 switch (message.header.type) {
624 case kHttpServer_setHandler_name:
625 var params = HttpServerSetHandlerParams.deserialize(
626 message.payload);
627 var response = _impl.setHandler(params.pattern,params.handler,_HttpServe rSetHandlerResponseParamsFactory);
628 if (response is Future) {
629 return response.then((response) {
630 if (response != null) {
631 return buildResponseWithId(
632 response,
633 kHttpServer_setHandler_name,
634 message.header.requestId,
635 bindings.MessageHeader.kMessageIsResponse);
636 }
637 });
638 } else if (response != null) {
639 return buildResponseWithId(
640 response,
641 kHttpServer_setHandler_name,
642 message.header.requestId,
643 bindings.MessageHeader.kMessageIsResponse);
644 }
645 break;
646 case kHttpServer_getPort_name:
647 var params = HttpServerGetPortParams.deserialize(
648 message.payload);
649 var response = _impl.getPort(_HttpServerGetPortResponseParamsFactory);
650 if (response is Future) {
651 return response.then((response) {
652 if (response != null) {
653 return buildResponseWithId(
654 response,
655 kHttpServer_getPort_name,
656 message.header.requestId,
657 bindings.MessageHeader.kMessageIsResponse);
658 }
659 });
660 } else if (response != null) {
661 return buildResponseWithId(
662 response,
663 kHttpServer_getPort_name,
664 message.header.requestId,
665 bindings.MessageHeader.kMessageIsResponse);
666 }
667 break;
668 default:
669 throw new bindings.MojoCodecError("Unexpected message name");
670 break;
671 }
672 return null;
673 }
674
675 HttpServer get impl => _impl;
676 set impl(HttpServer d) {
677 assert(_impl == null);
678 _impl = d;
679 }
680
681 String toString() {
682 var superString = super.toString();
683 return "HttpServerStub($superString)";
684 }
685
686 int get version => 0;
687 }
688
689 const int kHttpHandler_handleRequest_name = 0;
690
691 const String HttpHandlerName =
692 'http_server::HttpHandler';
693
694 abstract class HttpHandler {
695 dynamic handleRequest(http_request_mojom.HttpRequest request,[Function respons eFactory = null]);
696
697 }
698
699
700 class HttpHandlerProxyImpl extends bindings.Proxy {
701 HttpHandlerProxyImpl.fromEndpoint(
702 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
703
704 HttpHandlerProxyImpl.fromHandle(core.MojoHandle handle) :
705 super.fromHandle(handle);
706
707 HttpHandlerProxyImpl.unbound() : super.unbound();
708
709 static HttpHandlerProxyImpl newFromEndpoint(
710 core.MojoMessagePipeEndpoint endpoint) {
711 assert(endpoint.setDescription("For HttpHandlerProxyImpl"));
712 return new HttpHandlerProxyImpl.fromEndpoint(endpoint);
713 }
714
715 String get name => HttpHandlerName;
716
717 void handleResponse(bindings.ServiceMessage message) {
718 switch (message.header.type) {
719 case kHttpHandler_handleRequest_name:
720 var r = HttpHandlerHandleRequestResponseParams.deserialize(
721 message.payload);
722 if (!message.header.hasRequestId) {
723 proxyError("Expected a message with a valid request Id.");
724 return;
725 }
726 Completer c = completerMap[message.header.requestId];
727 if (c == null) {
728 proxyError(
729 "Message had unknown request Id: ${message.header.requestId}");
730 return;
731 }
732 completerMap.remove(message.header.requestId);
733 if (c.isCompleted) {
734 proxyError("Response completer already completed");
735 return;
736 }
737 c.complete(r);
738 break;
739 default:
740 proxyError("Unexpected message type: ${message.header.type}");
741 close(immediate: true);
742 break;
743 }
744 }
745
746 String toString() {
747 var superString = super.toString();
748 return "HttpHandlerProxyImpl($superString)";
749 }
750 }
751
752
753 class _HttpHandlerProxyCalls implements HttpHandler {
754 HttpHandlerProxyImpl _proxyImpl;
755
756 _HttpHandlerProxyCalls(this._proxyImpl);
757 dynamic handleRequest(http_request_mojom.HttpRequest request,[Function respo nseFactory = null]) {
758 var params = new HttpHandlerHandleRequestParams();
759 params.request = request;
760 return _proxyImpl.sendMessageWithRequestId(
761 params,
762 kHttpHandler_handleRequest_name,
763 -1,
764 bindings.MessageHeader.kMessageExpectsResponse);
765 }
766 }
767
768
769 class HttpHandlerProxy implements bindings.ProxyBase {
770 final bindings.Proxy impl;
771 HttpHandler ptr;
772 final String name = HttpHandlerName;
773
774 HttpHandlerProxy(HttpHandlerProxyImpl proxyImpl) :
775 impl = proxyImpl,
776 ptr = new _HttpHandlerProxyCalls(proxyImpl);
777
778 HttpHandlerProxy.fromEndpoint(
779 core.MojoMessagePipeEndpoint endpoint) :
780 impl = new HttpHandlerProxyImpl.fromEndpoint(endpoint) {
781 ptr = new _HttpHandlerProxyCalls(impl);
782 }
783
784 HttpHandlerProxy.fromHandle(core.MojoHandle handle) :
785 impl = new HttpHandlerProxyImpl.fromHandle(handle) {
786 ptr = new _HttpHandlerProxyCalls(impl);
787 }
788
789 HttpHandlerProxy.unbound() :
790 impl = new HttpHandlerProxyImpl.unbound() {
791 ptr = new _HttpHandlerProxyCalls(impl);
792 }
793
794 factory HttpHandlerProxy.connectToService(
795 bindings.ServiceConnector s, String url) {
796 HttpHandlerProxy p = new HttpHandlerProxy.unbound();
797 s.connectToService(url, p);
798 return p;
799 }
800
801 static HttpHandlerProxy newFromEndpoint(
802 core.MojoMessagePipeEndpoint endpoint) {
803 assert(endpoint.setDescription("For HttpHandlerProxy"));
804 return new HttpHandlerProxy.fromEndpoint(endpoint);
805 }
806
807 Future close({bool immediate: false}) => impl.close(immediate: immediate);
808
809 Future responseOrError(Future f) => impl.responseOrError(f);
810
811 Future get errorFuture => impl.errorFuture;
812
813 int get version => impl.version;
814
815 Future<int> queryVersion() => impl.queryVersion();
816
817 void requireVersion(int requiredVersion) {
818 impl.requireVersion(requiredVersion);
819 }
820
821 String toString() {
822 return "HttpHandlerProxy($impl)";
823 }
824 }
825
826
827 class HttpHandlerStub extends bindings.Stub {
828 HttpHandler _impl = null;
829
830 HttpHandlerStub.fromEndpoint(
831 core.MojoMessagePipeEndpoint endpoint, [this._impl])
832 : super.fromEndpoint(endpoint);
833
834 HttpHandlerStub.fromHandle(core.MojoHandle handle, [this._impl])
835 : super.fromHandle(handle);
836
837 HttpHandlerStub.unbound() : super.unbound();
838
839 static HttpHandlerStub newFromEndpoint(
840 core.MojoMessagePipeEndpoint endpoint) {
841 assert(endpoint.setDescription("For HttpHandlerStub"));
842 return new HttpHandlerStub.fromEndpoint(endpoint);
843 }
844
845 static const String name = HttpHandlerName;
846
847
848 HttpHandlerHandleRequestResponseParams _HttpHandlerHandleRequestResponseParams Factory(http_response_mojom.HttpResponse response) {
849 var result = new HttpHandlerHandleRequestResponseParams();
850 result.response = response;
851 return result;
852 }
853
854 dynamic handleMessage(bindings.ServiceMessage message) {
855 if (bindings.ControlMessageHandler.isControlMessage(message)) {
856 return bindings.ControlMessageHandler.handleMessage(this,
857 0,
858 message);
859 }
860 assert(_impl != null);
861 switch (message.header.type) {
862 case kHttpHandler_handleRequest_name:
863 var params = HttpHandlerHandleRequestParams.deserialize(
864 message.payload);
865 var response = _impl.handleRequest(params.request,_HttpHandlerHandleRequ estResponseParamsFactory);
866 if (response is Future) {
867 return response.then((response) {
868 if (response != null) {
869 return buildResponseWithId(
870 response,
871 kHttpHandler_handleRequest_name,
872 message.header.requestId,
873 bindings.MessageHeader.kMessageIsResponse);
874 }
875 });
876 } else if (response != null) {
877 return buildResponseWithId(
878 response,
879 kHttpHandler_handleRequest_name,
880 message.header.requestId,
881 bindings.MessageHeader.kMessageIsResponse);
882 }
883 break;
884 default:
885 throw new bindings.MojoCodecError("Unexpected message name");
886 break;
887 }
888 return null;
889 }
890
891 HttpHandler get impl => _impl;
892 set impl(HttpHandler d) {
893 assert(_impl == null);
894 _impl = d;
895 }
896
897 String toString() {
898 var superString = super.toString();
899 return "HttpHandlerStub($superString)";
900 }
901
902 int get version => 0;
903 }
904
905
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698