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 prediction_mojom; | 5 library prediction_mojom; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
10 | 10 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 dynamic getAllTypeDefinitions([Function responseFactory]) => | 371 dynamic getAllTypeDefinitions([Function responseFactory]) => |
372 responseFactory(null); | 372 responseFactory(null); |
373 } | 373 } |
374 | 374 |
375 abstract class PredictionService { | 375 abstract class PredictionService { |
376 static const String serviceName = "prediction::PredictionService"; | 376 static const String serviceName = "prediction::PredictionService"; |
377 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]); | 377 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]); |
378 } | 378 } |
379 | 379 |
380 | 380 |
381 class _PredictionServiceProxyImpl extends bindings.Proxy { | 381 class _PredictionServiceProxyControl extends bindings.ProxyMessageHandler |
382 _PredictionServiceProxyImpl.fromEndpoint( | 382 implements bindings.ProxyControl { |
| 383 _PredictionServiceProxyControl.fromEndpoint( |
383 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 384 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
384 | 385 |
385 _PredictionServiceProxyImpl.fromHandle(core.MojoHandle handle) : | 386 _PredictionServiceProxyControl.fromHandle( |
386 super.fromHandle(handle); | 387 core.MojoHandle handle) : super.fromHandle(handle); |
387 | 388 |
388 _PredictionServiceProxyImpl.unbound() : super.unbound(); | 389 _PredictionServiceProxyControl.unbound() : super.unbound(); |
389 | |
390 static _PredictionServiceProxyImpl newFromEndpoint( | |
391 core.MojoMessagePipeEndpoint endpoint) { | |
392 assert(endpoint.setDescription("For _PredictionServiceProxyImpl")); | |
393 return new _PredictionServiceProxyImpl.fromEndpoint(endpoint); | |
394 } | |
395 | 390 |
396 service_describer.ServiceDescription get serviceDescription => | 391 service_describer.ServiceDescription get serviceDescription => |
397 new _PredictionServiceServiceDescription(); | 392 new _PredictionServiceServiceDescription(); |
398 | 393 |
| 394 String get serviceName => PredictionService.serviceName; |
| 395 |
| 396 @override |
399 void handleResponse(bindings.ServiceMessage message) { | 397 void handleResponse(bindings.ServiceMessage message) { |
400 switch (message.header.type) { | 398 switch (message.header.type) { |
401 case _predictionServiceMethodGetPredictionListName: | 399 case _predictionServiceMethodGetPredictionListName: |
402 var r = PredictionServiceGetPredictionListResponseParams.deserialize( | 400 var r = PredictionServiceGetPredictionListResponseParams.deserialize( |
403 message.payload); | 401 message.payload); |
404 if (!message.header.hasRequestId) { | 402 if (!message.header.hasRequestId) { |
405 proxyError("Expected a message with a valid request Id."); | 403 proxyError("Expected a message with a valid request Id."); |
406 return; | 404 return; |
407 } | 405 } |
408 Completer c = completerMap[message.header.requestId]; | 406 Completer c = completerMap[message.header.requestId]; |
409 if (c == null) { | 407 if (c == null) { |
410 proxyError( | 408 proxyError( |
411 "Message had unknown request Id: ${message.header.requestId}"); | 409 "Message had unknown request Id: ${message.header.requestId}"); |
412 return; | 410 return; |
413 } | 411 } |
414 completerMap.remove(message.header.requestId); | 412 completerMap.remove(message.header.requestId); |
415 if (c.isCompleted) { | 413 if (c.isCompleted) { |
416 proxyError("Response completer already completed"); | 414 proxyError("Response completer already completed"); |
417 return; | 415 return; |
418 } | 416 } |
419 c.complete(r); | 417 c.complete(r); |
420 break; | 418 break; |
421 default: | 419 default: |
422 proxyError("Unexpected message type: ${message.header.type}"); | 420 proxyError("Unexpected message type: ${message.header.type}"); |
423 close(immediate: true); | 421 close(immediate: true); |
424 break; | 422 break; |
425 } | 423 } |
426 } | 424 } |
427 | 425 |
| 426 @override |
428 String toString() { | 427 String toString() { |
429 var superString = super.toString(); | 428 var superString = super.toString(); |
430 return "_PredictionServiceProxyImpl($superString)"; | 429 return "_PredictionServiceProxyControl($superString)"; |
431 } | 430 } |
432 } | 431 } |
433 | 432 |
434 | 433 |
435 class _PredictionServiceProxyCalls implements PredictionService { | 434 class PredictionServiceProxy extends bindings.Proxy |
436 _PredictionServiceProxyImpl _proxyImpl; | 435 implements PredictionService { |
| 436 PredictionServiceProxy.fromEndpoint( |
| 437 core.MojoMessagePipeEndpoint endpoint) |
| 438 : super(new _PredictionServiceProxyControl.fromEndpoint(endpoint)); |
437 | 439 |
438 _PredictionServiceProxyCalls(this._proxyImpl); | 440 PredictionServiceProxy.fromHandle(core.MojoHandle handle) |
439 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFa
ctory = null]) { | 441 : super(new _PredictionServiceProxyControl.fromHandle(handle)); |
440 var params = new _PredictionServiceGetPredictionListParams(); | |
441 params.predictionInfo = predictionInfo; | |
442 return _proxyImpl.sendMessageWithRequestId( | |
443 params, | |
444 _predictionServiceMethodGetPredictionListName, | |
445 -1, | |
446 bindings.MessageHeader.kMessageExpectsResponse); | |
447 } | |
448 } | |
449 | 442 |
| 443 PredictionServiceProxy.unbound() |
| 444 : super(new _PredictionServiceProxyControl.unbound()); |
450 | 445 |
451 class PredictionServiceProxy implements bindings.ProxyBase { | 446 static PredictionServiceProxy newFromEndpoint( |
452 final bindings.Proxy impl; | 447 core.MojoMessagePipeEndpoint endpoint) { |
453 PredictionService ptr; | 448 assert(endpoint.setDescription("For PredictionServiceProxy")); |
454 | 449 return new PredictionServiceProxy.fromEndpoint(endpoint); |
455 PredictionServiceProxy(_PredictionServiceProxyImpl proxyImpl) : | |
456 impl = proxyImpl, | |
457 ptr = new _PredictionServiceProxyCalls(proxyImpl); | |
458 | |
459 PredictionServiceProxy.fromEndpoint( | |
460 core.MojoMessagePipeEndpoint endpoint) : | |
461 impl = new _PredictionServiceProxyImpl.fromEndpoint(endpoint) { | |
462 ptr = new _PredictionServiceProxyCalls(impl); | |
463 } | |
464 | |
465 PredictionServiceProxy.fromHandle(core.MojoHandle handle) : | |
466 impl = new _PredictionServiceProxyImpl.fromHandle(handle) { | |
467 ptr = new _PredictionServiceProxyCalls(impl); | |
468 } | |
469 | |
470 PredictionServiceProxy.unbound() : | |
471 impl = new _PredictionServiceProxyImpl.unbound() { | |
472 ptr = new _PredictionServiceProxyCalls(impl); | |
473 } | 450 } |
474 | 451 |
475 factory PredictionServiceProxy.connectToService( | 452 factory PredictionServiceProxy.connectToService( |
476 bindings.ServiceConnector s, String url, [String serviceName]) { | 453 bindings.ServiceConnector s, String url, [String serviceName]) { |
477 PredictionServiceProxy p = new PredictionServiceProxy.unbound(); | 454 PredictionServiceProxy p = new PredictionServiceProxy.unbound(); |
478 s.connectToService(url, p, serviceName); | 455 s.connectToService(url, p, serviceName); |
479 return p; | 456 return p; |
480 } | 457 } |
481 | 458 |
482 static PredictionServiceProxy newFromEndpoint( | |
483 core.MojoMessagePipeEndpoint endpoint) { | |
484 assert(endpoint.setDescription("For PredictionServiceProxy")); | |
485 return new PredictionServiceProxy.fromEndpoint(endpoint); | |
486 } | |
487 | 459 |
488 String get serviceName => PredictionService.serviceName; | 460 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]) { |
489 | 461 var params = new _PredictionServiceGetPredictionListParams(); |
490 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 462 params.predictionInfo = predictionInfo; |
491 | 463 return ctrl.sendMessageWithRequestId( |
492 Future responseOrError(Future f) => impl.responseOrError(f); | 464 params, |
493 | 465 _predictionServiceMethodGetPredictionListName, |
494 Future get errorFuture => impl.errorFuture; | 466 -1, |
495 | 467 bindings.MessageHeader.kMessageExpectsResponse); |
496 int get version => impl.version; | |
497 | |
498 Future<int> queryVersion() => impl.queryVersion(); | |
499 | |
500 void requireVersion(int requiredVersion) { | |
501 impl.requireVersion(requiredVersion); | |
502 } | |
503 | |
504 String toString() { | |
505 return "PredictionServiceProxy($impl)"; | |
506 } | 468 } |
507 } | 469 } |
508 | 470 |
509 | 471 |
510 class PredictionServiceStub extends bindings.Stub { | 472 class PredictionServiceStub extends bindings.Stub { |
511 PredictionService _impl; | 473 PredictionService _impl; |
512 | 474 |
513 PredictionServiceStub.fromEndpoint( | 475 PredictionServiceStub.fromEndpoint( |
514 core.MojoMessagePipeEndpoint endpoint, [PredictionService impl]) | 476 core.MojoMessagePipeEndpoint endpoint, [PredictionService impl]) |
515 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 477 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 static service_describer.ServiceDescription get serviceDescription { | 568 static service_describer.ServiceDescription get serviceDescription { |
607 if (_cachedServiceDescription == null) { | 569 if (_cachedServiceDescription == null) { |
608 _cachedServiceDescription = new _PredictionServiceServiceDescription(); | 570 _cachedServiceDescription = new _PredictionServiceServiceDescription(); |
609 } | 571 } |
610 return _cachedServiceDescription; | 572 return _cachedServiceDescription; |
611 } | 573 } |
612 } | 574 } |
613 | 575 |
614 | 576 |
615 | 577 |
OLD | NEW |