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

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

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 6 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 // WARNING: DO NOT EDIT. This file was generated by a program. 1 // WARNING: DO NOT EDIT. This file was generated by a program.
2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py. 2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py.
3 3
4 library timelines_mojom; 4 library timelines_mojom;
5 import 'dart:async'; 5 import 'dart:async';
6 import 'package:mojo/bindings.dart' as bindings; 6 import 'package:mojo/bindings.dart' as bindings;
7 import 'package:mojo/core.dart' as core; 7 import 'package:mojo/core.dart' as core;
8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer; 8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
9 const int kUnspecifiedTime = 9223372036854775807; 9 const int kUnspecifiedTime = 9223372036854775807;
10 10
11 11
12 12
13 class TimelineTransform extends bindings.Struct { 13 class TimelineTransform extends bindings.Struct {
14 static const List<bindings.StructDataHeader> kVersions = const [ 14 static const List<bindings.StructDataHeader> kVersions = const [
15 const bindings.StructDataHeader(32, 0) 15 const bindings.StructDataHeader(32, 0)
16 ]; 16 ];
17 int referenceTime = 0; 17 int referenceTime = 0;
18 int subjectTime = 0; 18 int subjectTime = 0;
19 int referenceDelta = 1; 19 int referenceDelta = 1;
20 int subjectDelta = 0; 20 int subjectDelta = 0;
21 21
22 TimelineTransform() : super(kVersions.last.size); 22 TimelineTransform() : super(kVersions.last.size);
23 23
24 TimelineTransform.init(
25 int this.referenceTime,
26 int this.subjectTime,
27 int this.referenceDelta,
28 int this.subjectDelta
29 ) : super(kVersions.last.size);
30
24 static TimelineTransform deserialize(bindings.Message message) { 31 static TimelineTransform deserialize(bindings.Message message) {
25 var decoder = new bindings.Decoder(message); 32 var decoder = new bindings.Decoder(message);
26 var result = decode(decoder); 33 var result = decode(decoder);
27 if (decoder.excessHandles != null) { 34 if (decoder.excessHandles != null) {
28 decoder.excessHandles.forEach((h) => h.close()); 35 decoder.excessHandles.forEach((h) => h.close());
29 } 36 }
30 return result; 37 return result;
31 } 38 }
32 39
33 static TimelineTransform decode(bindings.Decoder decoder0) { 40 static TimelineTransform decode(bindings.Decoder decoder0) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const bindings.StructDataHeader(40, 0) 136 const bindings.StructDataHeader(40, 0)
130 ]; 137 ];
131 int subjectTime = 0; 138 int subjectTime = 0;
132 int referenceDelta = 0; 139 int referenceDelta = 0;
133 int subjectDelta = 0; 140 int subjectDelta = 0;
134 int effectiveReferenceTime = 0; 141 int effectiveReferenceTime = 0;
135 int effectiveSubjectTime = 0; 142 int effectiveSubjectTime = 0;
136 143
137 _TimelineConsumerSetTimelineTransformParams() : super(kVersions.last.size); 144 _TimelineConsumerSetTimelineTransformParams() : super(kVersions.last.size);
138 145
146 _TimelineConsumerSetTimelineTransformParams.init(
147 int this.subjectTime,
148 int this.referenceDelta,
149 int this.subjectDelta,
150 int this.effectiveReferenceTime,
151 int this.effectiveSubjectTime
152 ) : super(kVersions.last.size);
153
139 static _TimelineConsumerSetTimelineTransformParams deserialize(bindings.Messag e message) { 154 static _TimelineConsumerSetTimelineTransformParams deserialize(bindings.Messag e message) {
140 var decoder = new bindings.Decoder(message); 155 var decoder = new bindings.Decoder(message);
141 var result = decode(decoder); 156 var result = decode(decoder);
142 if (decoder.excessHandles != null) { 157 if (decoder.excessHandles != null) {
143 decoder.excessHandles.forEach((h) => h.close()); 158 decoder.excessHandles.forEach((h) => h.close());
144 } 159 }
145 return result; 160 return result;
146 } 161 }
147 162
148 static _TimelineConsumerSetTimelineTransformParams decode(bindings.Decoder dec oder0) { 163 static _TimelineConsumerSetTimelineTransformParams decode(bindings.Decoder dec oder0) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 268
254 269
255 class TimelineConsumerSetTimelineTransformResponseParams extends bindings.Struct { 270 class TimelineConsumerSetTimelineTransformResponseParams extends bindings.Struct {
256 static const List<bindings.StructDataHeader> kVersions = const [ 271 static const List<bindings.StructDataHeader> kVersions = const [
257 const bindings.StructDataHeader(16, 0) 272 const bindings.StructDataHeader(16, 0)
258 ]; 273 ];
259 bool completed = false; 274 bool completed = false;
260 275
261 TimelineConsumerSetTimelineTransformResponseParams() : super(kVersions.last.si ze); 276 TimelineConsumerSetTimelineTransformResponseParams() : super(kVersions.last.si ze);
262 277
278 TimelineConsumerSetTimelineTransformResponseParams.init(
279 bool this.completed
280 ) : super(kVersions.last.size);
281
263 static TimelineConsumerSetTimelineTransformResponseParams deserialize(bindings .Message message) { 282 static TimelineConsumerSetTimelineTransformResponseParams deserialize(bindings .Message message) {
264 var decoder = new bindings.Decoder(message); 283 var decoder = new bindings.Decoder(message);
265 var result = decode(decoder); 284 var result = decode(decoder);
266 if (decoder.excessHandles != null) { 285 if (decoder.excessHandles != null) {
267 decoder.excessHandles.forEach((h) => h.close()); 286 decoder.excessHandles.forEach((h) => h.close());
268 } 287 }
269 return result; 288 return result;
270 } 289 }
271 290
272 static TimelineConsumerSetTimelineTransformResponseParams decode(bindings.Deco der decoder0) { 291 static TimelineConsumerSetTimelineTransformResponseParams decode(bindings.Deco der decoder0) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 Map toJson() { 338 Map toJson() {
320 Map map = new Map(); 339 Map map = new Map();
321 map["completed"] = completed; 340 map["completed"] = completed;
322 return map; 341 return map;
323 } 342 }
324 } 343 }
325 344
326 const int _timelineConsumerMethodSetTimelineTransformName = 0; 345 const int _timelineConsumerMethodSetTimelineTransformName = 0;
327 346
328 class _TimelineConsumerServiceDescription implements service_describer.ServiceDe scription { 347 class _TimelineConsumerServiceDescription implements service_describer.ServiceDe scription {
329 dynamic getTopLevelInterface([Function responseFactory]) => 348 void getTopLevelInterface(Function responder) {
330 responseFactory(null); 349 responder(null);
350 }
331 351
332 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 352 void getTypeDefinition(String typeKey, Function responder) {
333 responseFactory(null); 353 responder(null);
354 }
334 355
335 dynamic getAllTypeDefinitions([Function responseFactory]) => 356 void getAllTypeDefinitions(Function responder) {
336 responseFactory(null); 357 responder(null);
358 }
337 } 359 }
338 360
339 abstract class TimelineConsumer { 361 abstract class TimelineConsumer {
340 static const String serviceName = null; 362 static const String serviceName = null;
341 363
342 static service_describer.ServiceDescription _cachedServiceDescription; 364 static service_describer.ServiceDescription _cachedServiceDescription;
343 static service_describer.ServiceDescription get serviceDescription { 365 static service_describer.ServiceDescription get serviceDescription {
344 if (_cachedServiceDescription == null) { 366 if (_cachedServiceDescription == null) {
345 _cachedServiceDescription = new _TimelineConsumerServiceDescription(); 367 _cachedServiceDescription = new _TimelineConsumerServiceDescription();
346 } 368 }
347 return _cachedServiceDescription; 369 return _cachedServiceDescription;
348 } 370 }
349 371
350 static TimelineConsumerProxy connectToService( 372 static TimelineConsumerProxy connectToService(
351 bindings.ServiceConnector s, String url, [String serviceName]) { 373 bindings.ServiceConnector s, String url, [String serviceName]) {
352 TimelineConsumerProxy p = new TimelineConsumerProxy.unbound(); 374 TimelineConsumerProxy p = new TimelineConsumerProxy.unbound();
353 String name = serviceName ?? TimelineConsumer.serviceName; 375 String name = serviceName ?? TimelineConsumer.serviceName;
354 if ((name == null) || name.isEmpty) { 376 if ((name == null) || name.isEmpty) {
355 throw new core.MojoApiError( 377 throw new core.MojoApiError(
356 "If an interface has no ServiceName, then one must be provided."); 378 "If an interface has no ServiceName, then one must be provided.");
357 } 379 }
358 s.connectToService(url, p, name); 380 s.connectToService(url, p, name);
359 return p; 381 return p;
360 } 382 }
361 dynamic setTimelineTransform(int subjectTime,int referenceDelta,int subjectDel ta,int effectiveReferenceTime,int effectiveSubjectTime,[Function responseFactory = null]); 383 void setTimelineTransform(int subjectTime,int referenceDelta,int subjectDelta, int effectiveReferenceTime,int effectiveSubjectTime,void callback(bool completed ));
362 } 384 }
363 385
364 abstract class TimelineConsumerInterface 386 abstract class TimelineConsumerInterface
365 implements bindings.MojoInterface<TimelineConsumer>, 387 implements bindings.MojoInterface<TimelineConsumer>,
366 TimelineConsumer { 388 TimelineConsumer {
367 factory TimelineConsumerInterface([TimelineConsumer impl]) => 389 factory TimelineConsumerInterface([TimelineConsumer impl]) =>
368 new TimelineConsumerStub.unbound(impl); 390 new TimelineConsumerStub.unbound(impl);
369 391
370 factory TimelineConsumerInterface.fromEndpoint( 392 factory TimelineConsumerInterface.fromEndpoint(
371 core.MojoMessagePipeEndpoint endpoint, 393 core.MojoMessagePipeEndpoint endpoint,
(...skipping 29 matching lines...) Expand all
401 423
402 void handleResponse(bindings.ServiceMessage message) { 424 void handleResponse(bindings.ServiceMessage message) {
403 switch (message.header.type) { 425 switch (message.header.type) {
404 case _timelineConsumerMethodSetTimelineTransformName: 426 case _timelineConsumerMethodSetTimelineTransformName:
405 var r = TimelineConsumerSetTimelineTransformResponseParams.deserialize( 427 var r = TimelineConsumerSetTimelineTransformResponseParams.deserialize(
406 message.payload); 428 message.payload);
407 if (!message.header.hasRequestId) { 429 if (!message.header.hasRequestId) {
408 proxyError("Expected a message with a valid request Id."); 430 proxyError("Expected a message with a valid request Id.");
409 return; 431 return;
410 } 432 }
411 Completer c = completerMap[message.header.requestId]; 433 Function callback = callbackMap[message.header.requestId];
412 if (c == null) { 434 if (callback == null) {
413 proxyError( 435 proxyError(
414 "Message had unknown request Id: ${message.header.requestId}"); 436 "Message had unknown request Id: ${message.header.requestId}");
415 return; 437 return;
416 } 438 }
417 completerMap.remove(message.header.requestId); 439 callbackMap.remove(message.header.requestId);
418 if (c.isCompleted) { 440 callback(r.completed );
419 proxyError("Response completer already completed");
420 return;
421 }
422 c.complete(r);
423 break; 441 break;
424 default: 442 default:
425 proxyError("Unexpected message type: ${message.header.type}"); 443 proxyError("Unexpected message type: ${message.header.type}");
426 close(immediate: true); 444 close(immediate: true);
427 break; 445 break;
428 } 446 }
429 } 447 }
430 448
431 @override 449 @override
432 String toString() { 450 String toString() {
(...skipping 24 matching lines...) Expand all
457 return newMockedProxy; 475 return newMockedProxy;
458 } 476 }
459 477
460 static TimelineConsumerProxy newFromEndpoint( 478 static TimelineConsumerProxy newFromEndpoint(
461 core.MojoMessagePipeEndpoint endpoint) { 479 core.MojoMessagePipeEndpoint endpoint) {
462 assert(endpoint.setDescription("For TimelineConsumerProxy")); 480 assert(endpoint.setDescription("For TimelineConsumerProxy"));
463 return new TimelineConsumerProxy.fromEndpoint(endpoint); 481 return new TimelineConsumerProxy.fromEndpoint(endpoint);
464 } 482 }
465 483
466 484
467 dynamic setTimelineTransform(int subjectTime,int referenceDelta,int subjectDel ta,int effectiveReferenceTime,int effectiveSubjectTime,[Function responseFactory = null]) { 485 void setTimelineTransform(int subjectTime,int referenceDelta,int subjectDelta, int effectiveReferenceTime,int effectiveSubjectTime,void callback(bool completed )) {
468 if (impl != null) { 486 if (impl != null) {
469 return new Future(() => impl.setTimelineTransform(subjectTime,referenceDel ta,subjectDelta,effectiveReferenceTime,effectiveSubjectTime,_TimelineConsumerStu bControl._timelineConsumerSetTimelineTransformResponseParamsFactory)); 487 impl.setTimelineTransform(subjectTime,referenceDelta,subjectDelta,effectiv eReferenceTime,effectiveSubjectTime,callback);
488 return;
470 } 489 }
471 var params = new _TimelineConsumerSetTimelineTransformParams(); 490 var params = new _TimelineConsumerSetTimelineTransformParams();
472 params.subjectTime = subjectTime; 491 params.subjectTime = subjectTime;
473 params.referenceDelta = referenceDelta; 492 params.referenceDelta = referenceDelta;
474 params.subjectDelta = subjectDelta; 493 params.subjectDelta = subjectDelta;
475 params.effectiveReferenceTime = effectiveReferenceTime; 494 params.effectiveReferenceTime = effectiveReferenceTime;
476 params.effectiveSubjectTime = effectiveSubjectTime; 495 params.effectiveSubjectTime = effectiveSubjectTime;
477 return ctrl.sendMessageWithRequestId( 496 ctrl.sendMessageWithRequestId(
478 params, 497 params,
479 _timelineConsumerMethodSetTimelineTransformName, 498 _timelineConsumerMethodSetTimelineTransformName,
480 -1, 499 -1,
481 bindings.MessageHeader.kMessageExpectsResponse); 500 bindings.MessageHeader.kMessageExpectsResponse,
501 callback);
482 } 502 }
483 } 503 }
484 504
485 class _TimelineConsumerStubControl 505 class _TimelineConsumerStubControl
486 extends bindings.StubMessageHandler 506 extends bindings.StubMessageHandler
487 implements bindings.StubControl<TimelineConsumer> { 507 implements bindings.StubControl<TimelineConsumer> {
488 TimelineConsumer _impl; 508 TimelineConsumer _impl;
489 509
490 _TimelineConsumerStubControl.fromEndpoint( 510 _TimelineConsumerStubControl.fromEndpoint(
491 core.MojoMessagePipeEndpoint endpoint, [TimelineConsumer impl]) 511 core.MojoMessagePipeEndpoint endpoint, [TimelineConsumer impl])
492 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 512 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
493 _impl = impl; 513 _impl = impl;
494 } 514 }
495 515
496 _TimelineConsumerStubControl.fromHandle( 516 _TimelineConsumerStubControl.fromHandle(
497 core.MojoHandle handle, [TimelineConsumer impl]) 517 core.MojoHandle handle, [TimelineConsumer impl])
498 : super.fromHandle(handle, autoBegin: impl != null) { 518 : super.fromHandle(handle, autoBegin: impl != null) {
499 _impl = impl; 519 _impl = impl;
500 } 520 }
501 521
502 _TimelineConsumerStubControl.unbound([this._impl]) : super.unbound(); 522 _TimelineConsumerStubControl.unbound([this._impl]) : super.unbound();
503 523
504 String get serviceName => TimelineConsumer.serviceName; 524 String get serviceName => TimelineConsumer.serviceName;
505 525
506 526
507 static TimelineConsumerSetTimelineTransformResponseParams _timelineConsumerSet TimelineTransformResponseParamsFactory(bool completed) { 527 Function _timelineConsumerSetTimelineTransformResponseParamsResponder(
508 var result = new TimelineConsumerSetTimelineTransformResponseParams(); 528 int requestId) {
509 result.completed = completed; 529 return (bool completed) {
510 return result; 530 var result = new TimelineConsumerSetTimelineTransformResponseParams();
531 result.completed = completed;
532 sendResponse(buildResponseWithId(
533 result,
534 _timelineConsumerMethodSetTimelineTransformName,
535 requestId,
536 bindings.MessageHeader.kMessageIsResponse));
537 };
511 } 538 }
512 539
513 dynamic handleMessage(bindings.ServiceMessage message) { 540 void handleMessage(bindings.ServiceMessage message) {
514 if (bindings.ControlMessageHandler.isControlMessage(message)) { 541 if (bindings.ControlMessageHandler.isControlMessage(message)) {
515 return bindings.ControlMessageHandler.handleMessage(this, 542 bindings.ControlMessageHandler.handleMessage(
516 0, 543 this, 0, message);
517 message); 544 return;
518 } 545 }
519 if (_impl == null) { 546 if (_impl == null) {
520 throw new core.MojoApiError("$this has no implementation set"); 547 throw new core.MojoApiError("$this has no implementation set");
521 } 548 }
522 switch (message.header.type) { 549 switch (message.header.type) {
523 case _timelineConsumerMethodSetTimelineTransformName: 550 case _timelineConsumerMethodSetTimelineTransformName:
524 var params = _TimelineConsumerSetTimelineTransformParams.deserialize( 551 var params = _TimelineConsumerSetTimelineTransformParams.deserialize(
525 message.payload); 552 message.payload);
526 var response = _impl.setTimelineTransform(params.subjectTime,params.refe renceDelta,params.subjectDelta,params.effectiveReferenceTime,params.effectiveSub jectTime,_timelineConsumerSetTimelineTransformResponseParamsFactory); 553 _impl.setTimelineTransform(params.subjectTime, params.referenceDelta, pa rams.subjectDelta, params.effectiveReferenceTime, params.effectiveSubjectTime, _ timelineConsumerSetTimelineTransformResponseParamsResponder(message.header.reque stId));
527 if (response is Future) {
528 return response.then((response) {
529 if (response != null) {
530 return buildResponseWithId(
531 response,
532 _timelineConsumerMethodSetTimelineTransformName,
533 message.header.requestId,
534 bindings.MessageHeader.kMessageIsResponse);
535 }
536 });
537 } else if (response != null) {
538 return buildResponseWithId(
539 response,
540 _timelineConsumerMethodSetTimelineTransformName,
541 message.header.requestId,
542 bindings.MessageHeader.kMessageIsResponse);
543 }
544 break; 554 break;
545 default: 555 default:
546 throw new bindings.MojoCodecError("Unexpected message name"); 556 throw new bindings.MojoCodecError("Unexpected message name");
547 break; 557 break;
548 } 558 }
549 return null;
550 } 559 }
551 560
552 TimelineConsumer get impl => _impl; 561 TimelineConsumer get impl => _impl;
553 set impl(TimelineConsumer d) { 562 set impl(TimelineConsumer d) {
554 if (d == null) { 563 if (d == null) {
555 throw new core.MojoApiError("$this: Cannot set a null implementation"); 564 throw new core.MojoApiError("$this: Cannot set a null implementation");
556 } 565 }
557 if (isBound && (_impl == null)) { 566 if (isBound && (_impl == null)) {
558 beginHandlingEvents(); 567 beginHandlingEvents();
559 } 568 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 core.MojoHandle handle, [TimelineConsumer impl]) 602 core.MojoHandle handle, [TimelineConsumer impl])
594 : super(new _TimelineConsumerStubControl.fromHandle(handle, impl)); 603 : super(new _TimelineConsumerStubControl.fromHandle(handle, impl));
595 604
596 static TimelineConsumerStub newFromEndpoint( 605 static TimelineConsumerStub newFromEndpoint(
597 core.MojoMessagePipeEndpoint endpoint) { 606 core.MojoMessagePipeEndpoint endpoint) {
598 assert(endpoint.setDescription("For TimelineConsumerStub")); 607 assert(endpoint.setDescription("For TimelineConsumerStub"));
599 return new TimelineConsumerStub.fromEndpoint(endpoint); 608 return new TimelineConsumerStub.fromEndpoint(endpoint);
600 } 609 }
601 610
602 611
603 dynamic setTimelineTransform(int subjectTime,int referenceDelta,int subjectDel ta,int effectiveReferenceTime,int effectiveSubjectTime,[Function responseFactory = null]) { 612 void setTimelineTransform(int subjectTime,int referenceDelta,int subjectDelta, int effectiveReferenceTime,int effectiveSubjectTime,void callback(bool completed )) {
604 return impl.setTimelineTransform(subjectTime,referenceDelta,subjectDelta,eff ectiveReferenceTime,effectiveSubjectTime,responseFactory); 613 return impl.setTimelineTransform(subjectTime,referenceDelta,subjectDelta,eff ectiveReferenceTime,effectiveSubjectTime,callback);
605 } 614 }
606 } 615 }
607 616
608 617
609 618
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698