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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 367 |
368 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 368 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
369 responseFactory(null); | 369 responseFactory(null); |
370 | 370 |
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 |
| 378 static service_describer.ServiceDescription _cachedServiceDescription; |
| 379 static service_describer.ServiceDescription get serviceDescription { |
| 380 if (_cachedServiceDescription == null) { |
| 381 _cachedServiceDescription = new _PredictionServiceServiceDescription(); |
| 382 } |
| 383 return _cachedServiceDescription; |
| 384 } |
| 385 |
| 386 static PredictionServiceProxy connectToService( |
| 387 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 388 PredictionServiceProxy p = new PredictionServiceProxy.unbound(); |
| 389 String name = serviceName ?? PredictionService.serviceName; |
| 390 if ((name == null) || name.isEmpty) { |
| 391 throw new core.MojoApiError( |
| 392 "If an interface has no ServiceName, then one must be provided."); |
| 393 } |
| 394 s.connectToService(url, p, name); |
| 395 return p; |
| 396 } |
377 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]); | 397 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]); |
378 } | 398 } |
379 | 399 |
| 400 abstract class PredictionServiceInterface |
| 401 implements bindings.MojoInterface<PredictionService>, |
| 402 PredictionService { |
| 403 factory PredictionServiceInterface([PredictionService impl]) => |
| 404 new PredictionServiceStub.unbound(impl); |
| 405 factory PredictionServiceInterface.fromEndpoint( |
| 406 core.MojoMessagePipeEndpoint endpoint, |
| 407 [PredictionService impl]) => |
| 408 new PredictionServiceStub.fromEndpoint(endpoint, impl); |
| 409 } |
| 410 |
| 411 abstract class PredictionServiceInterfaceRequest |
| 412 implements bindings.MojoInterface<PredictionService>, |
| 413 PredictionService { |
| 414 factory PredictionServiceInterfaceRequest() => |
| 415 new PredictionServiceProxy.unbound(); |
| 416 } |
| 417 |
380 class _PredictionServiceProxyControl | 418 class _PredictionServiceProxyControl |
381 extends bindings.ProxyMessageHandler | 419 extends bindings.ProxyMessageHandler |
382 implements bindings.ProxyControl { | 420 implements bindings.ProxyControl<PredictionService> { |
383 _PredictionServiceProxyControl.fromEndpoint( | 421 _PredictionServiceProxyControl.fromEndpoint( |
384 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 422 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
385 | 423 |
386 _PredictionServiceProxyControl.fromHandle( | 424 _PredictionServiceProxyControl.fromHandle( |
387 core.MojoHandle handle) : super.fromHandle(handle); | 425 core.MojoHandle handle) : super.fromHandle(handle); |
388 | 426 |
389 _PredictionServiceProxyControl.unbound() : super.unbound(); | 427 _PredictionServiceProxyControl.unbound() : super.unbound(); |
390 | 428 |
391 service_describer.ServiceDescription get serviceDescription => | |
392 new _PredictionServiceServiceDescription(); | |
393 | |
394 String get serviceName => PredictionService.serviceName; | 429 String get serviceName => PredictionService.serviceName; |
395 | 430 |
396 void handleResponse(bindings.ServiceMessage message) { | 431 void handleResponse(bindings.ServiceMessage message) { |
397 switch (message.header.type) { | 432 switch (message.header.type) { |
398 case _predictionServiceMethodGetPredictionListName: | 433 case _predictionServiceMethodGetPredictionListName: |
399 var r = PredictionServiceGetPredictionListResponseParams.deserialize( | 434 var r = PredictionServiceGetPredictionListResponseParams.deserialize( |
400 message.payload); | 435 message.payload); |
401 if (!message.header.hasRequestId) { | 436 if (!message.header.hasRequestId) { |
402 proxyError("Expected a message with a valid request Id."); | 437 proxyError("Expected a message with a valid request Id."); |
403 return; | 438 return; |
(...skipping 11 matching lines...) Expand all Loading... |
415 } | 450 } |
416 c.complete(r); | 451 c.complete(r); |
417 break; | 452 break; |
418 default: | 453 default: |
419 proxyError("Unexpected message type: ${message.header.type}"); | 454 proxyError("Unexpected message type: ${message.header.type}"); |
420 close(immediate: true); | 455 close(immediate: true); |
421 break; | 456 break; |
422 } | 457 } |
423 } | 458 } |
424 | 459 |
| 460 PredictionService get impl => null; |
| 461 set impl(PredictionService _) { |
| 462 throw new core.MojoApiError("The impl of a Proxy cannot be set."); |
| 463 } |
| 464 |
425 @override | 465 @override |
426 String toString() { | 466 String toString() { |
427 var superString = super.toString(); | 467 var superString = super.toString(); |
428 return "_PredictionServiceProxyControl($superString)"; | 468 return "_PredictionServiceProxyControl($superString)"; |
429 } | 469 } |
430 } | 470 } |
431 | 471 |
432 class PredictionServiceProxy | 472 class PredictionServiceProxy |
433 extends bindings.Proxy | 473 extends bindings.Proxy<PredictionService> |
434 implements PredictionService { | 474 implements PredictionService, |
| 475 PredictionServiceInterface, |
| 476 PredictionServiceInterfaceRequest { |
435 PredictionServiceProxy.fromEndpoint( | 477 PredictionServiceProxy.fromEndpoint( |
436 core.MojoMessagePipeEndpoint endpoint) | 478 core.MojoMessagePipeEndpoint endpoint) |
437 : super(new _PredictionServiceProxyControl.fromEndpoint(endpoint)); | 479 : super(new _PredictionServiceProxyControl.fromEndpoint(endpoint)); |
438 | 480 |
439 PredictionServiceProxy.fromHandle(core.MojoHandle handle) | 481 PredictionServiceProxy.fromHandle(core.MojoHandle handle) |
440 : super(new _PredictionServiceProxyControl.fromHandle(handle)); | 482 : super(new _PredictionServiceProxyControl.fromHandle(handle)); |
441 | 483 |
442 PredictionServiceProxy.unbound() | 484 PredictionServiceProxy.unbound() |
443 : super(new _PredictionServiceProxyControl.unbound()); | 485 : super(new _PredictionServiceProxyControl.unbound()); |
444 | 486 |
445 static PredictionServiceProxy newFromEndpoint( | 487 static PredictionServiceProxy newFromEndpoint( |
446 core.MojoMessagePipeEndpoint endpoint) { | 488 core.MojoMessagePipeEndpoint endpoint) { |
447 assert(endpoint.setDescription("For PredictionServiceProxy")); | 489 assert(endpoint.setDescription("For PredictionServiceProxy")); |
448 return new PredictionServiceProxy.fromEndpoint(endpoint); | 490 return new PredictionServiceProxy.fromEndpoint(endpoint); |
449 } | 491 } |
450 | 492 |
451 factory PredictionServiceProxy.connectToService( | |
452 bindings.ServiceConnector s, String url, [String serviceName]) { | |
453 PredictionServiceProxy p = new PredictionServiceProxy.unbound(); | |
454 s.connectToService(url, p, serviceName); | |
455 return p; | |
456 } | |
457 | |
458 | 493 |
459 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]) { | 494 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]) { |
460 var params = new _PredictionServiceGetPredictionListParams(); | 495 var params = new _PredictionServiceGetPredictionListParams(); |
461 params.predictionInfo = predictionInfo; | 496 params.predictionInfo = predictionInfo; |
462 return ctrl.sendMessageWithRequestId( | 497 return ctrl.sendMessageWithRequestId( |
463 params, | 498 params, |
464 _predictionServiceMethodGetPredictionListName, | 499 _predictionServiceMethodGetPredictionListName, |
465 -1, | 500 -1, |
466 bindings.MessageHeader.kMessageExpectsResponse); | 501 bindings.MessageHeader.kMessageExpectsResponse); |
467 } | 502 } |
(...skipping 11 matching lines...) Expand all Loading... |
479 } | 514 } |
480 | 515 |
481 _PredictionServiceStubControl.fromHandle( | 516 _PredictionServiceStubControl.fromHandle( |
482 core.MojoHandle handle, [PredictionService impl]) | 517 core.MojoHandle handle, [PredictionService impl]) |
483 : super.fromHandle(handle, autoBegin: impl != null) { | 518 : super.fromHandle(handle, autoBegin: impl != null) { |
484 _impl = impl; | 519 _impl = impl; |
485 } | 520 } |
486 | 521 |
487 _PredictionServiceStubControl.unbound([this._impl]) : super.unbound(); | 522 _PredictionServiceStubControl.unbound([this._impl]) : super.unbound(); |
488 | 523 |
| 524 String get serviceName => PredictionService.serviceName; |
| 525 |
489 | 526 |
490 PredictionServiceGetPredictionListResponseParams _predictionServiceGetPredicti
onListResponseParamsFactory(List<String> predictionList) { | 527 PredictionServiceGetPredictionListResponseParams _predictionServiceGetPredicti
onListResponseParamsFactory(List<String> predictionList) { |
491 var result = new PredictionServiceGetPredictionListResponseParams(); | 528 var result = new PredictionServiceGetPredictionListResponseParams(); |
492 result.predictionList = predictionList; | 529 result.predictionList = predictionList; |
493 return result; | 530 return result; |
494 } | 531 } |
495 | 532 |
496 dynamic handleMessage(bindings.ServiceMessage message) { | 533 dynamic handleMessage(bindings.ServiceMessage message) { |
497 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 534 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
498 return bindings.ControlMessageHandler.handleMessage(this, | 535 return bindings.ControlMessageHandler.handleMessage(this, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 588 } |
552 } | 589 } |
553 | 590 |
554 @override | 591 @override |
555 String toString() { | 592 String toString() { |
556 var superString = super.toString(); | 593 var superString = super.toString(); |
557 return "_PredictionServiceStubControl($superString)"; | 594 return "_PredictionServiceStubControl($superString)"; |
558 } | 595 } |
559 | 596 |
560 int get version => 0; | 597 int get version => 0; |
561 | |
562 static service_describer.ServiceDescription _cachedServiceDescription; | |
563 static service_describer.ServiceDescription get serviceDescription { | |
564 if (_cachedServiceDescription == null) { | |
565 _cachedServiceDescription = new _PredictionServiceServiceDescription(); | |
566 } | |
567 return _cachedServiceDescription; | |
568 } | |
569 } | 598 } |
570 | 599 |
571 class PredictionServiceStub | 600 class PredictionServiceStub |
572 extends bindings.Stub<PredictionService> | 601 extends bindings.Stub<PredictionService> |
573 implements PredictionService { | 602 implements PredictionService, |
| 603 PredictionServiceInterface, |
| 604 PredictionServiceInterfaceRequest { |
| 605 PredictionServiceStub.unbound([PredictionService impl]) |
| 606 : super(new _PredictionServiceStubControl.unbound(impl)); |
| 607 |
574 PredictionServiceStub.fromEndpoint( | 608 PredictionServiceStub.fromEndpoint( |
575 core.MojoMessagePipeEndpoint endpoint, [PredictionService impl]) | 609 core.MojoMessagePipeEndpoint endpoint, [PredictionService impl]) |
576 : super(new _PredictionServiceStubControl.fromEndpoint(endpoint, impl)); | 610 : super(new _PredictionServiceStubControl.fromEndpoint(endpoint, impl)); |
577 | 611 |
578 PredictionServiceStub.fromHandle( | 612 PredictionServiceStub.fromHandle( |
579 core.MojoHandle handle, [PredictionService impl]) | 613 core.MojoHandle handle, [PredictionService impl]) |
580 : super(new _PredictionServiceStubControl.fromHandle(handle, impl)); | 614 : super(new _PredictionServiceStubControl.fromHandle(handle, impl)); |
581 | 615 |
582 PredictionServiceStub.unbound([PredictionService impl]) | |
583 : super(new _PredictionServiceStubControl.unbound(impl)); | |
584 | |
585 static PredictionServiceStub newFromEndpoint( | 616 static PredictionServiceStub newFromEndpoint( |
586 core.MojoMessagePipeEndpoint endpoint) { | 617 core.MojoMessagePipeEndpoint endpoint) { |
587 assert(endpoint.setDescription("For PredictionServiceStub")); | 618 assert(endpoint.setDescription("For PredictionServiceStub")); |
588 return new PredictionServiceStub.fromEndpoint(endpoint); | 619 return new PredictionServiceStub.fromEndpoint(endpoint); |
589 } | 620 } |
590 | 621 |
591 static service_describer.ServiceDescription get serviceDescription => | |
592 _PredictionServiceStubControl.serviceDescription; | |
593 | |
594 | 622 |
595 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]) { | 623 dynamic getPredictionList(PredictionInfo predictionInfo,[Function responseFact
ory = null]) { |
596 return impl.getPredictionList(predictionInfo,responseFactory); | 624 return impl.getPredictionList(predictionInfo,responseFactory); |
597 } | 625 } |
598 } | 626 } |
599 | 627 |
600 | 628 |
601 | 629 |
OLD | NEW |