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 scheduling_mojom; | 5 library scheduling_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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 262 |
263 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 263 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
264 responseFactory(null); | 264 responseFactory(null); |
265 | 265 |
266 dynamic getAllTypeDefinitions([Function responseFactory]) => | 266 dynamic getAllTypeDefinitions([Function responseFactory]) => |
267 responseFactory(null); | 267 responseFactory(null); |
268 } | 268 } |
269 | 269 |
270 abstract class FrameScheduler { | 270 abstract class FrameScheduler { |
271 static const String serviceName = null; | 271 static const String serviceName = null; |
| 272 |
| 273 static service_describer.ServiceDescription _cachedServiceDescription; |
| 274 static service_describer.ServiceDescription get serviceDescription { |
| 275 if (_cachedServiceDescription == null) { |
| 276 _cachedServiceDescription = new _FrameSchedulerServiceDescription(); |
| 277 } |
| 278 return _cachedServiceDescription; |
| 279 } |
| 280 |
| 281 static FrameSchedulerProxy connectToService( |
| 282 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 283 FrameSchedulerProxy p = new FrameSchedulerProxy.unbound(); |
| 284 String name = serviceName ?? FrameScheduler.serviceName; |
| 285 if ((name == null) || name.isEmpty) { |
| 286 throw new core.MojoApiError( |
| 287 "If an interface has no ServiceName, then one must be provided."); |
| 288 } |
| 289 s.connectToService(url, p, name); |
| 290 return p; |
| 291 } |
272 dynamic scheduleFrame([Function responseFactory = null]); | 292 dynamic scheduleFrame([Function responseFactory = null]); |
273 } | 293 } |
274 | 294 |
| 295 abstract class FrameSchedulerInterface |
| 296 implements bindings.MojoInterface<FrameScheduler>, |
| 297 FrameScheduler { |
| 298 factory FrameSchedulerInterface([FrameScheduler impl]) => |
| 299 new FrameSchedulerStub.unbound(impl); |
| 300 factory FrameSchedulerInterface.fromEndpoint( |
| 301 core.MojoMessagePipeEndpoint endpoint, |
| 302 [FrameScheduler impl]) => |
| 303 new FrameSchedulerStub.fromEndpoint(endpoint, impl); |
| 304 } |
| 305 |
| 306 abstract class FrameSchedulerInterfaceRequest |
| 307 implements bindings.MojoInterface<FrameScheduler>, |
| 308 FrameScheduler { |
| 309 factory FrameSchedulerInterfaceRequest() => |
| 310 new FrameSchedulerProxy.unbound(); |
| 311 } |
| 312 |
275 class _FrameSchedulerProxyControl | 313 class _FrameSchedulerProxyControl |
276 extends bindings.ProxyMessageHandler | 314 extends bindings.ProxyMessageHandler |
277 implements bindings.ProxyControl { | 315 implements bindings.ProxyControl<FrameScheduler> { |
278 _FrameSchedulerProxyControl.fromEndpoint( | 316 _FrameSchedulerProxyControl.fromEndpoint( |
279 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 317 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
280 | 318 |
281 _FrameSchedulerProxyControl.fromHandle( | 319 _FrameSchedulerProxyControl.fromHandle( |
282 core.MojoHandle handle) : super.fromHandle(handle); | 320 core.MojoHandle handle) : super.fromHandle(handle); |
283 | 321 |
284 _FrameSchedulerProxyControl.unbound() : super.unbound(); | 322 _FrameSchedulerProxyControl.unbound() : super.unbound(); |
285 | 323 |
286 service_describer.ServiceDescription get serviceDescription => | |
287 new _FrameSchedulerServiceDescription(); | |
288 | |
289 String get serviceName => FrameScheduler.serviceName; | 324 String get serviceName => FrameScheduler.serviceName; |
290 | 325 |
291 void handleResponse(bindings.ServiceMessage message) { | 326 void handleResponse(bindings.ServiceMessage message) { |
292 switch (message.header.type) { | 327 switch (message.header.type) { |
293 case _frameSchedulerMethodScheduleFrameName: | 328 case _frameSchedulerMethodScheduleFrameName: |
294 var r = FrameSchedulerScheduleFrameResponseParams.deserialize( | 329 var r = FrameSchedulerScheduleFrameResponseParams.deserialize( |
295 message.payload); | 330 message.payload); |
296 if (!message.header.hasRequestId) { | 331 if (!message.header.hasRequestId) { |
297 proxyError("Expected a message with a valid request Id."); | 332 proxyError("Expected a message with a valid request Id."); |
298 return; | 333 return; |
(...skipping 11 matching lines...) Expand all Loading... |
310 } | 345 } |
311 c.complete(r); | 346 c.complete(r); |
312 break; | 347 break; |
313 default: | 348 default: |
314 proxyError("Unexpected message type: ${message.header.type}"); | 349 proxyError("Unexpected message type: ${message.header.type}"); |
315 close(immediate: true); | 350 close(immediate: true); |
316 break; | 351 break; |
317 } | 352 } |
318 } | 353 } |
319 | 354 |
| 355 FrameScheduler get impl => null; |
| 356 set impl(FrameScheduler _) { |
| 357 throw new core.MojoApiError("The impl of a Proxy cannot be set."); |
| 358 } |
| 359 |
320 @override | 360 @override |
321 String toString() { | 361 String toString() { |
322 var superString = super.toString(); | 362 var superString = super.toString(); |
323 return "_FrameSchedulerProxyControl($superString)"; | 363 return "_FrameSchedulerProxyControl($superString)"; |
324 } | 364 } |
325 } | 365 } |
326 | 366 |
327 class FrameSchedulerProxy | 367 class FrameSchedulerProxy |
328 extends bindings.Proxy | 368 extends bindings.Proxy<FrameScheduler> |
329 implements FrameScheduler { | 369 implements FrameScheduler, |
| 370 FrameSchedulerInterface, |
| 371 FrameSchedulerInterfaceRequest { |
330 FrameSchedulerProxy.fromEndpoint( | 372 FrameSchedulerProxy.fromEndpoint( |
331 core.MojoMessagePipeEndpoint endpoint) | 373 core.MojoMessagePipeEndpoint endpoint) |
332 : super(new _FrameSchedulerProxyControl.fromEndpoint(endpoint)); | 374 : super(new _FrameSchedulerProxyControl.fromEndpoint(endpoint)); |
333 | 375 |
334 FrameSchedulerProxy.fromHandle(core.MojoHandle handle) | 376 FrameSchedulerProxy.fromHandle(core.MojoHandle handle) |
335 : super(new _FrameSchedulerProxyControl.fromHandle(handle)); | 377 : super(new _FrameSchedulerProxyControl.fromHandle(handle)); |
336 | 378 |
337 FrameSchedulerProxy.unbound() | 379 FrameSchedulerProxy.unbound() |
338 : super(new _FrameSchedulerProxyControl.unbound()); | 380 : super(new _FrameSchedulerProxyControl.unbound()); |
339 | 381 |
340 static FrameSchedulerProxy newFromEndpoint( | 382 static FrameSchedulerProxy newFromEndpoint( |
341 core.MojoMessagePipeEndpoint endpoint) { | 383 core.MojoMessagePipeEndpoint endpoint) { |
342 assert(endpoint.setDescription("For FrameSchedulerProxy")); | 384 assert(endpoint.setDescription("For FrameSchedulerProxy")); |
343 return new FrameSchedulerProxy.fromEndpoint(endpoint); | 385 return new FrameSchedulerProxy.fromEndpoint(endpoint); |
344 } | 386 } |
345 | 387 |
346 factory FrameSchedulerProxy.connectToService( | |
347 bindings.ServiceConnector s, String url, [String serviceName]) { | |
348 FrameSchedulerProxy p = new FrameSchedulerProxy.unbound(); | |
349 s.connectToService(url, p, serviceName); | |
350 return p; | |
351 } | |
352 | |
353 | 388 |
354 dynamic scheduleFrame([Function responseFactory = null]) { | 389 dynamic scheduleFrame([Function responseFactory = null]) { |
355 var params = new _FrameSchedulerScheduleFrameParams(); | 390 var params = new _FrameSchedulerScheduleFrameParams(); |
356 return ctrl.sendMessageWithRequestId( | 391 return ctrl.sendMessageWithRequestId( |
357 params, | 392 params, |
358 _frameSchedulerMethodScheduleFrameName, | 393 _frameSchedulerMethodScheduleFrameName, |
359 -1, | 394 -1, |
360 bindings.MessageHeader.kMessageExpectsResponse); | 395 bindings.MessageHeader.kMessageExpectsResponse); |
361 } | 396 } |
362 } | 397 } |
(...skipping 10 matching lines...) Expand all Loading... |
373 } | 408 } |
374 | 409 |
375 _FrameSchedulerStubControl.fromHandle( | 410 _FrameSchedulerStubControl.fromHandle( |
376 core.MojoHandle handle, [FrameScheduler impl]) | 411 core.MojoHandle handle, [FrameScheduler impl]) |
377 : super.fromHandle(handle, autoBegin: impl != null) { | 412 : super.fromHandle(handle, autoBegin: impl != null) { |
378 _impl = impl; | 413 _impl = impl; |
379 } | 414 } |
380 | 415 |
381 _FrameSchedulerStubControl.unbound([this._impl]) : super.unbound(); | 416 _FrameSchedulerStubControl.unbound([this._impl]) : super.unbound(); |
382 | 417 |
| 418 String get serviceName => FrameScheduler.serviceName; |
| 419 |
383 | 420 |
384 FrameSchedulerScheduleFrameResponseParams _frameSchedulerScheduleFrameResponse
ParamsFactory(FrameInfo frameInfo) { | 421 FrameSchedulerScheduleFrameResponseParams _frameSchedulerScheduleFrameResponse
ParamsFactory(FrameInfo frameInfo) { |
385 var result = new FrameSchedulerScheduleFrameResponseParams(); | 422 var result = new FrameSchedulerScheduleFrameResponseParams(); |
386 result.frameInfo = frameInfo; | 423 result.frameInfo = frameInfo; |
387 return result; | 424 return result; |
388 } | 425 } |
389 | 426 |
390 dynamic handleMessage(bindings.ServiceMessage message) { | 427 dynamic handleMessage(bindings.ServiceMessage message) { |
391 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 428 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
392 return bindings.ControlMessageHandler.handleMessage(this, | 429 return bindings.ControlMessageHandler.handleMessage(this, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 } | 480 } |
444 } | 481 } |
445 | 482 |
446 @override | 483 @override |
447 String toString() { | 484 String toString() { |
448 var superString = super.toString(); | 485 var superString = super.toString(); |
449 return "_FrameSchedulerStubControl($superString)"; | 486 return "_FrameSchedulerStubControl($superString)"; |
450 } | 487 } |
451 | 488 |
452 int get version => 0; | 489 int get version => 0; |
453 | |
454 static service_describer.ServiceDescription _cachedServiceDescription; | |
455 static service_describer.ServiceDescription get serviceDescription { | |
456 if (_cachedServiceDescription == null) { | |
457 _cachedServiceDescription = new _FrameSchedulerServiceDescription(); | |
458 } | |
459 return _cachedServiceDescription; | |
460 } | |
461 } | 490 } |
462 | 491 |
463 class FrameSchedulerStub | 492 class FrameSchedulerStub |
464 extends bindings.Stub<FrameScheduler> | 493 extends bindings.Stub<FrameScheduler> |
465 implements FrameScheduler { | 494 implements FrameScheduler, |
| 495 FrameSchedulerInterface, |
| 496 FrameSchedulerInterfaceRequest { |
| 497 FrameSchedulerStub.unbound([FrameScheduler impl]) |
| 498 : super(new _FrameSchedulerStubControl.unbound(impl)); |
| 499 |
466 FrameSchedulerStub.fromEndpoint( | 500 FrameSchedulerStub.fromEndpoint( |
467 core.MojoMessagePipeEndpoint endpoint, [FrameScheduler impl]) | 501 core.MojoMessagePipeEndpoint endpoint, [FrameScheduler impl]) |
468 : super(new _FrameSchedulerStubControl.fromEndpoint(endpoint, impl)); | 502 : super(new _FrameSchedulerStubControl.fromEndpoint(endpoint, impl)); |
469 | 503 |
470 FrameSchedulerStub.fromHandle( | 504 FrameSchedulerStub.fromHandle( |
471 core.MojoHandle handle, [FrameScheduler impl]) | 505 core.MojoHandle handle, [FrameScheduler impl]) |
472 : super(new _FrameSchedulerStubControl.fromHandle(handle, impl)); | 506 : super(new _FrameSchedulerStubControl.fromHandle(handle, impl)); |
473 | 507 |
474 FrameSchedulerStub.unbound([FrameScheduler impl]) | |
475 : super(new _FrameSchedulerStubControl.unbound(impl)); | |
476 | |
477 static FrameSchedulerStub newFromEndpoint( | 508 static FrameSchedulerStub newFromEndpoint( |
478 core.MojoMessagePipeEndpoint endpoint) { | 509 core.MojoMessagePipeEndpoint endpoint) { |
479 assert(endpoint.setDescription("For FrameSchedulerStub")); | 510 assert(endpoint.setDescription("For FrameSchedulerStub")); |
480 return new FrameSchedulerStub.fromEndpoint(endpoint); | 511 return new FrameSchedulerStub.fromEndpoint(endpoint); |
481 } | 512 } |
482 | 513 |
483 static service_describer.ServiceDescription get serviceDescription => | |
484 _FrameSchedulerStubControl.serviceDescription; | |
485 | |
486 | 514 |
487 dynamic scheduleFrame([Function responseFactory = null]) { | 515 dynamic scheduleFrame([Function responseFactory = null]) { |
488 return impl.scheduleFrame(responseFactory); | 516 return impl.scheduleFrame(responseFactory); |
489 } | 517 } |
490 } | 518 } |
491 | 519 |
492 | 520 |
493 | 521 |
OLD | NEW |