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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/mojo/gfx/composition/scheduling.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 scheduling_mojom; 4 library scheduling_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 9
10 10
11 11
12 class FrameInfo extends bindings.Struct { 12 class FrameInfo extends bindings.Struct {
13 static const List<bindings.StructDataHeader> kVersions = const [ 13 static const List<bindings.StructDataHeader> kVersions = const [
14 const bindings.StructDataHeader(40, 0) 14 const bindings.StructDataHeader(40, 0)
15 ]; 15 ];
16 int frameTime = 0; 16 int frameTime = 0;
17 int frameInterval = 0; 17 int frameInterval = 0;
18 int frameDeadline = 0; 18 int frameDeadline = 0;
19 int presentationTime = 0; 19 int presentationTime = 0;
20 20
21 FrameInfo() : super(kVersions.last.size); 21 FrameInfo() : super(kVersions.last.size);
22 22
23 FrameInfo.init(
24 int this.frameTime,
25 int this.frameInterval,
26 int this.frameDeadline,
27 int this.presentationTime
28 ) : super(kVersions.last.size);
29
23 static FrameInfo deserialize(bindings.Message message) { 30 static FrameInfo deserialize(bindings.Message message) {
24 var decoder = new bindings.Decoder(message); 31 var decoder = new bindings.Decoder(message);
25 var result = decode(decoder); 32 var result = decode(decoder);
26 if (decoder.excessHandles != null) { 33 if (decoder.excessHandles != null) {
27 decoder.excessHandles.forEach((h) => h.close()); 34 decoder.excessHandles.forEach((h) => h.close());
28 } 35 }
29 return result; 36 return result;
30 } 37 }
31 38
32 static FrameInfo decode(bindings.Decoder decoder0) { 39 static FrameInfo decode(bindings.Decoder decoder0) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 130 }
124 131
125 132
126 class _FrameSchedulerScheduleFrameParams extends bindings.Struct { 133 class _FrameSchedulerScheduleFrameParams extends bindings.Struct {
127 static const List<bindings.StructDataHeader> kVersions = const [ 134 static const List<bindings.StructDataHeader> kVersions = const [
128 const bindings.StructDataHeader(8, 0) 135 const bindings.StructDataHeader(8, 0)
129 ]; 136 ];
130 137
131 _FrameSchedulerScheduleFrameParams() : super(kVersions.last.size); 138 _FrameSchedulerScheduleFrameParams() : super(kVersions.last.size);
132 139
140 _FrameSchedulerScheduleFrameParams.init(
141 ) : super(kVersions.last.size);
142
133 static _FrameSchedulerScheduleFrameParams deserialize(bindings.Message message ) { 143 static _FrameSchedulerScheduleFrameParams deserialize(bindings.Message message ) {
134 var decoder = new bindings.Decoder(message); 144 var decoder = new bindings.Decoder(message);
135 var result = decode(decoder); 145 var result = decode(decoder);
136 if (decoder.excessHandles != null) { 146 if (decoder.excessHandles != null) {
137 decoder.excessHandles.forEach((h) => h.close()); 147 decoder.excessHandles.forEach((h) => h.close());
138 } 148 }
139 return result; 149 return result;
140 } 150 }
141 151
142 static _FrameSchedulerScheduleFrameParams decode(bindings.Decoder decoder0) { 152 static _FrameSchedulerScheduleFrameParams decode(bindings.Decoder decoder0) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 192
183 193
184 class FrameSchedulerScheduleFrameResponseParams extends bindings.Struct { 194 class FrameSchedulerScheduleFrameResponseParams extends bindings.Struct {
185 static const List<bindings.StructDataHeader> kVersions = const [ 195 static const List<bindings.StructDataHeader> kVersions = const [
186 const bindings.StructDataHeader(16, 0) 196 const bindings.StructDataHeader(16, 0)
187 ]; 197 ];
188 FrameInfo frameInfo = null; 198 FrameInfo frameInfo = null;
189 199
190 FrameSchedulerScheduleFrameResponseParams() : super(kVersions.last.size); 200 FrameSchedulerScheduleFrameResponseParams() : super(kVersions.last.size);
191 201
202 FrameSchedulerScheduleFrameResponseParams.init(
203 FrameInfo this.frameInfo
204 ) : super(kVersions.last.size);
205
192 static FrameSchedulerScheduleFrameResponseParams deserialize(bindings.Message message) { 206 static FrameSchedulerScheduleFrameResponseParams deserialize(bindings.Message message) {
193 var decoder = new bindings.Decoder(message); 207 var decoder = new bindings.Decoder(message);
194 var result = decode(decoder); 208 var result = decode(decoder);
195 if (decoder.excessHandles != null) { 209 if (decoder.excessHandles != null) {
196 decoder.excessHandles.forEach((h) => h.close()); 210 decoder.excessHandles.forEach((h) => h.close());
197 } 211 }
198 return result; 212 return result;
199 } 213 }
200 214
201 static FrameSchedulerScheduleFrameResponseParams decode(bindings.Decoder decod er0) { 215 static FrameSchedulerScheduleFrameResponseParams decode(bindings.Decoder decod er0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 Map toJson() { 263 Map toJson() {
250 Map map = new Map(); 264 Map map = new Map();
251 map["frameInfo"] = frameInfo; 265 map["frameInfo"] = frameInfo;
252 return map; 266 return map;
253 } 267 }
254 } 268 }
255 269
256 const int _frameSchedulerMethodScheduleFrameName = 0; 270 const int _frameSchedulerMethodScheduleFrameName = 0;
257 271
258 class _FrameSchedulerServiceDescription implements service_describer.ServiceDesc ription { 272 class _FrameSchedulerServiceDescription implements service_describer.ServiceDesc ription {
259 dynamic getTopLevelInterface([Function responseFactory]) => 273 void getTopLevelInterface(Function responder) {
260 responseFactory(null); 274 responder(null);
275 }
261 276
262 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 277 void getTypeDefinition(String typeKey, Function responder) {
263 responseFactory(null); 278 responder(null);
279 }
264 280
265 dynamic getAllTypeDefinitions([Function responseFactory]) => 281 void getAllTypeDefinitions(Function responder) {
266 responseFactory(null); 282 responder(null);
283 }
267 } 284 }
268 285
269 abstract class FrameScheduler { 286 abstract class FrameScheduler {
270 static const String serviceName = null; 287 static const String serviceName = null;
271 288
272 static service_describer.ServiceDescription _cachedServiceDescription; 289 static service_describer.ServiceDescription _cachedServiceDescription;
273 static service_describer.ServiceDescription get serviceDescription { 290 static service_describer.ServiceDescription get serviceDescription {
274 if (_cachedServiceDescription == null) { 291 if (_cachedServiceDescription == null) {
275 _cachedServiceDescription = new _FrameSchedulerServiceDescription(); 292 _cachedServiceDescription = new _FrameSchedulerServiceDescription();
276 } 293 }
277 return _cachedServiceDescription; 294 return _cachedServiceDescription;
278 } 295 }
279 296
280 static FrameSchedulerProxy connectToService( 297 static FrameSchedulerProxy connectToService(
281 bindings.ServiceConnector s, String url, [String serviceName]) { 298 bindings.ServiceConnector s, String url, [String serviceName]) {
282 FrameSchedulerProxy p = new FrameSchedulerProxy.unbound(); 299 FrameSchedulerProxy p = new FrameSchedulerProxy.unbound();
283 String name = serviceName ?? FrameScheduler.serviceName; 300 String name = serviceName ?? FrameScheduler.serviceName;
284 if ((name == null) || name.isEmpty) { 301 if ((name == null) || name.isEmpty) {
285 throw new core.MojoApiError( 302 throw new core.MojoApiError(
286 "If an interface has no ServiceName, then one must be provided."); 303 "If an interface has no ServiceName, then one must be provided.");
287 } 304 }
288 s.connectToService(url, p, name); 305 s.connectToService(url, p, name);
289 return p; 306 return p;
290 } 307 }
291 dynamic scheduleFrame([Function responseFactory = null]); 308 void scheduleFrame(void callback(FrameInfo frameInfo));
292 } 309 }
293 310
294 abstract class FrameSchedulerInterface 311 abstract class FrameSchedulerInterface
295 implements bindings.MojoInterface<FrameScheduler>, 312 implements bindings.MojoInterface<FrameScheduler>,
296 FrameScheduler { 313 FrameScheduler {
297 factory FrameSchedulerInterface([FrameScheduler impl]) => 314 factory FrameSchedulerInterface([FrameScheduler impl]) =>
298 new FrameSchedulerStub.unbound(impl); 315 new FrameSchedulerStub.unbound(impl);
299 316
300 factory FrameSchedulerInterface.fromEndpoint( 317 factory FrameSchedulerInterface.fromEndpoint(
301 core.MojoMessagePipeEndpoint endpoint, 318 core.MojoMessagePipeEndpoint endpoint,
(...skipping 29 matching lines...) Expand all
331 348
332 void handleResponse(bindings.ServiceMessage message) { 349 void handleResponse(bindings.ServiceMessage message) {
333 switch (message.header.type) { 350 switch (message.header.type) {
334 case _frameSchedulerMethodScheduleFrameName: 351 case _frameSchedulerMethodScheduleFrameName:
335 var r = FrameSchedulerScheduleFrameResponseParams.deserialize( 352 var r = FrameSchedulerScheduleFrameResponseParams.deserialize(
336 message.payload); 353 message.payload);
337 if (!message.header.hasRequestId) { 354 if (!message.header.hasRequestId) {
338 proxyError("Expected a message with a valid request Id."); 355 proxyError("Expected a message with a valid request Id.");
339 return; 356 return;
340 } 357 }
341 Completer c = completerMap[message.header.requestId]; 358 Function callback = callbackMap[message.header.requestId];
342 if (c == null) { 359 if (callback == null) {
343 proxyError( 360 proxyError(
344 "Message had unknown request Id: ${message.header.requestId}"); 361 "Message had unknown request Id: ${message.header.requestId}");
345 return; 362 return;
346 } 363 }
347 completerMap.remove(message.header.requestId); 364 callbackMap.remove(message.header.requestId);
348 if (c.isCompleted) { 365 callback(r.frameInfo );
349 proxyError("Response completer already completed");
350 return;
351 }
352 c.complete(r);
353 break; 366 break;
354 default: 367 default:
355 proxyError("Unexpected message type: ${message.header.type}"); 368 proxyError("Unexpected message type: ${message.header.type}");
356 close(immediate: true); 369 close(immediate: true);
357 break; 370 break;
358 } 371 }
359 } 372 }
360 373
361 @override 374 @override
362 String toString() { 375 String toString() {
(...skipping 24 matching lines...) Expand all
387 return newMockedProxy; 400 return newMockedProxy;
388 } 401 }
389 402
390 static FrameSchedulerProxy newFromEndpoint( 403 static FrameSchedulerProxy newFromEndpoint(
391 core.MojoMessagePipeEndpoint endpoint) { 404 core.MojoMessagePipeEndpoint endpoint) {
392 assert(endpoint.setDescription("For FrameSchedulerProxy")); 405 assert(endpoint.setDescription("For FrameSchedulerProxy"));
393 return new FrameSchedulerProxy.fromEndpoint(endpoint); 406 return new FrameSchedulerProxy.fromEndpoint(endpoint);
394 } 407 }
395 408
396 409
397 dynamic scheduleFrame([Function responseFactory = null]) { 410 void scheduleFrame(void callback(FrameInfo frameInfo)) {
398 if (impl != null) { 411 if (impl != null) {
399 return new Future(() => impl.scheduleFrame(_FrameSchedulerStubControl._fra meSchedulerScheduleFrameResponseParamsFactory)); 412 impl.scheduleFrame(callback);
413 return;
400 } 414 }
401 var params = new _FrameSchedulerScheduleFrameParams(); 415 var params = new _FrameSchedulerScheduleFrameParams();
402 return ctrl.sendMessageWithRequestId( 416 ctrl.sendMessageWithRequestId(
403 params, 417 params,
404 _frameSchedulerMethodScheduleFrameName, 418 _frameSchedulerMethodScheduleFrameName,
405 -1, 419 -1,
406 bindings.MessageHeader.kMessageExpectsResponse); 420 bindings.MessageHeader.kMessageExpectsResponse,
421 callback);
407 } 422 }
408 } 423 }
409 424
410 class _FrameSchedulerStubControl 425 class _FrameSchedulerStubControl
411 extends bindings.StubMessageHandler 426 extends bindings.StubMessageHandler
412 implements bindings.StubControl<FrameScheduler> { 427 implements bindings.StubControl<FrameScheduler> {
413 FrameScheduler _impl; 428 FrameScheduler _impl;
414 429
415 _FrameSchedulerStubControl.fromEndpoint( 430 _FrameSchedulerStubControl.fromEndpoint(
416 core.MojoMessagePipeEndpoint endpoint, [FrameScheduler impl]) 431 core.MojoMessagePipeEndpoint endpoint, [FrameScheduler impl])
417 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 432 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
418 _impl = impl; 433 _impl = impl;
419 } 434 }
420 435
421 _FrameSchedulerStubControl.fromHandle( 436 _FrameSchedulerStubControl.fromHandle(
422 core.MojoHandle handle, [FrameScheduler impl]) 437 core.MojoHandle handle, [FrameScheduler impl])
423 : super.fromHandle(handle, autoBegin: impl != null) { 438 : super.fromHandle(handle, autoBegin: impl != null) {
424 _impl = impl; 439 _impl = impl;
425 } 440 }
426 441
427 _FrameSchedulerStubControl.unbound([this._impl]) : super.unbound(); 442 _FrameSchedulerStubControl.unbound([this._impl]) : super.unbound();
428 443
429 String get serviceName => FrameScheduler.serviceName; 444 String get serviceName => FrameScheduler.serviceName;
430 445
431 446
432 static FrameSchedulerScheduleFrameResponseParams _frameSchedulerScheduleFrameR esponseParamsFactory(FrameInfo frameInfo) { 447 Function _frameSchedulerScheduleFrameResponseParamsResponder(
433 var result = new FrameSchedulerScheduleFrameResponseParams(); 448 int requestId) {
434 result.frameInfo = frameInfo; 449 return (FrameInfo frameInfo) {
435 return result; 450 var result = new FrameSchedulerScheduleFrameResponseParams();
451 result.frameInfo = frameInfo;
452 sendResponse(buildResponseWithId(
453 result,
454 _frameSchedulerMethodScheduleFrameName,
455 requestId,
456 bindings.MessageHeader.kMessageIsResponse));
457 };
436 } 458 }
437 459
438 dynamic handleMessage(bindings.ServiceMessage message) { 460 void handleMessage(bindings.ServiceMessage message) {
439 if (bindings.ControlMessageHandler.isControlMessage(message)) { 461 if (bindings.ControlMessageHandler.isControlMessage(message)) {
440 return bindings.ControlMessageHandler.handleMessage(this, 462 bindings.ControlMessageHandler.handleMessage(
441 0, 463 this, 0, message);
442 message); 464 return;
443 } 465 }
444 if (_impl == null) { 466 if (_impl == null) {
445 throw new core.MojoApiError("$this has no implementation set"); 467 throw new core.MojoApiError("$this has no implementation set");
446 } 468 }
447 switch (message.header.type) { 469 switch (message.header.type) {
448 case _frameSchedulerMethodScheduleFrameName: 470 case _frameSchedulerMethodScheduleFrameName:
449 var response = _impl.scheduleFrame(_frameSchedulerScheduleFrameResponseP aramsFactory); 471 _impl.scheduleFrame(_frameSchedulerScheduleFrameResponseParamsResponder( message.header.requestId));
450 if (response is Future) {
451 return response.then((response) {
452 if (response != null) {
453 return buildResponseWithId(
454 response,
455 _frameSchedulerMethodScheduleFrameName,
456 message.header.requestId,
457 bindings.MessageHeader.kMessageIsResponse);
458 }
459 });
460 } else if (response != null) {
461 return buildResponseWithId(
462 response,
463 _frameSchedulerMethodScheduleFrameName,
464 message.header.requestId,
465 bindings.MessageHeader.kMessageIsResponse);
466 }
467 break; 472 break;
468 default: 473 default:
469 throw new bindings.MojoCodecError("Unexpected message name"); 474 throw new bindings.MojoCodecError("Unexpected message name");
470 break; 475 break;
471 } 476 }
472 return null;
473 } 477 }
474 478
475 FrameScheduler get impl => _impl; 479 FrameScheduler get impl => _impl;
476 set impl(FrameScheduler d) { 480 set impl(FrameScheduler d) {
477 if (d == null) { 481 if (d == null) {
478 throw new core.MojoApiError("$this: Cannot set a null implementation"); 482 throw new core.MojoApiError("$this: Cannot set a null implementation");
479 } 483 }
480 if (isBound && (_impl == null)) { 484 if (isBound && (_impl == null)) {
481 beginHandlingEvents(); 485 beginHandlingEvents();
482 } 486 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 core.MojoHandle handle, [FrameScheduler impl]) 520 core.MojoHandle handle, [FrameScheduler impl])
517 : super(new _FrameSchedulerStubControl.fromHandle(handle, impl)); 521 : super(new _FrameSchedulerStubControl.fromHandle(handle, impl));
518 522
519 static FrameSchedulerStub newFromEndpoint( 523 static FrameSchedulerStub newFromEndpoint(
520 core.MojoMessagePipeEndpoint endpoint) { 524 core.MojoMessagePipeEndpoint endpoint) {
521 assert(endpoint.setDescription("For FrameSchedulerStub")); 525 assert(endpoint.setDescription("For FrameSchedulerStub"));
522 return new FrameSchedulerStub.fromEndpoint(endpoint); 526 return new FrameSchedulerStub.fromEndpoint(endpoint);
523 } 527 }
524 528
525 529
526 dynamic scheduleFrame([Function responseFactory = null]) { 530 void scheduleFrame(void callback(FrameInfo frameInfo)) {
527 return impl.scheduleFrame(responseFactory); 531 return impl.scheduleFrame(callback);
528 } 532 }
529 } 533 }
530 534
531 535
532 536
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698