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

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

Issue 1948003003: Dart: Wait to handle events on a Stub until it makes sense to do it. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add test Created 4 years, 7 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 // 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 input_mojom; 5 library input_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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 impl.requireVersion(requiredVersion); 337 impl.requireVersion(requiredVersion);
338 } 338 }
339 339
340 String toString() { 340 String toString() {
341 return "InputClientProxy($impl)"; 341 return "InputClientProxy($impl)";
342 } 342 }
343 } 343 }
344 344
345 345
346 class InputClientStub extends bindings.Stub { 346 class InputClientStub extends bindings.Stub {
347 InputClient _impl = null; 347 InputClient _impl;
348 348
349 InputClientStub.fromEndpoint( 349 InputClientStub.fromEndpoint(
350 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 350 core.MojoMessagePipeEndpoint endpoint, [InputClient impl])
351 : super.fromEndpoint(endpoint); 351 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
352 _impl = impl;
353 }
352 354
353 InputClientStub.fromHandle(core.MojoHandle handle, [this._impl]) 355 InputClientStub.fromHandle(
354 : super.fromHandle(handle); 356 core.MojoHandle handle, [InputClient impl])
357 : super.fromHandle(handle, autoBegin: impl != null) {
358 _impl = impl;
359 }
355 360
356 InputClientStub.unbound() : super.unbound(); 361 InputClientStub.unbound() : super.unbound();
357 362
358 static InputClientStub newFromEndpoint( 363 static InputClientStub newFromEndpoint(
359 core.MojoMessagePipeEndpoint endpoint) { 364 core.MojoMessagePipeEndpoint endpoint) {
360 assert(endpoint.setDescription("For InputClientStub")); 365 assert(endpoint.setDescription("For InputClientStub"));
361 return new InputClientStub.fromEndpoint(endpoint); 366 return new InputClientStub.fromEndpoint(endpoint);
362 } 367 }
363 368
364 369
365 InputClientOnBackButtonResponseParams _inputClientOnBackButtonResponseParamsFa ctory() { 370 InputClientOnBackButtonResponseParams _inputClientOnBackButtonResponseParamsFa ctory() {
366 var result = new InputClientOnBackButtonResponseParams(); 371 var result = new InputClientOnBackButtonResponseParams();
367 return result; 372 return result;
368 } 373 }
369 374
370 dynamic handleMessage(bindings.ServiceMessage message) { 375 dynamic handleMessage(bindings.ServiceMessage message) {
371 if (bindings.ControlMessageHandler.isControlMessage(message)) { 376 if (bindings.ControlMessageHandler.isControlMessage(message)) {
372 return bindings.ControlMessageHandler.handleMessage(this, 377 return bindings.ControlMessageHandler.handleMessage(this,
373 0, 378 0,
374 message); 379 message);
375 } 380 }
376 assert(_impl != null); 381 if (_impl == null) {
382 throw new core.MojoApiError("$this has no implementation set");
383 }
377 switch (message.header.type) { 384 switch (message.header.type) {
378 case _inputClientMethodOnBackButtonName: 385 case _inputClientMethodOnBackButtonName:
379 var response = _impl.onBackButton(_inputClientOnBackButtonResponseParams Factory); 386 var response = _impl.onBackButton(_inputClientOnBackButtonResponseParams Factory);
380 if (response is Future) { 387 if (response is Future) {
381 return response.then((response) { 388 return response.then((response) {
382 if (response != null) { 389 if (response != null) {
383 return buildResponseWithId( 390 return buildResponseWithId(
384 response, 391 response,
385 _inputClientMethodOnBackButtonName, 392 _inputClientMethodOnBackButtonName,
386 message.header.requestId, 393 message.header.requestId,
(...skipping 10 matching lines...) Expand all
397 break; 404 break;
398 default: 405 default:
399 throw new bindings.MojoCodecError("Unexpected message name"); 406 throw new bindings.MojoCodecError("Unexpected message name");
400 break; 407 break;
401 } 408 }
402 return null; 409 return null;
403 } 410 }
404 411
405 InputClient get impl => _impl; 412 InputClient get impl => _impl;
406 set impl(InputClient d) { 413 set impl(InputClient d) {
407 assert(_impl == null); 414 if (d == null) {
415 throw new core.MojoApiError("$this: Cannot set a null implementation");
416 }
417 if (isBound && (_impl == null)) {
418 beginHandlingEvents();
419 }
408 _impl = d; 420 _impl = d;
409 } 421 }
410 422
423 @override
424 void bind(core.MojoMessagePipeEndpoint endpoint) {
425 super.bind(endpoint);
426 if (!isOpen && (_impl != null)) {
427 beginHandlingEvents();
428 }
429 }
430
411 String toString() { 431 String toString() {
412 var superString = super.toString(); 432 var superString = super.toString();
413 return "InputClientStub($superString)"; 433 return "InputClientStub($superString)";
414 } 434 }
415 435
416 int get version => 0; 436 int get version => 0;
417 437
418 static service_describer.ServiceDescription _cachedServiceDescription; 438 static service_describer.ServiceDescription _cachedServiceDescription;
419 static service_describer.ServiceDescription get serviceDescription { 439 static service_describer.ServiceDescription get serviceDescription {
420 if (_cachedServiceDescription == null) { 440 if (_cachedServiceDescription == null) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 impl.requireVersion(requiredVersion); 566 impl.requireVersion(requiredVersion);
547 } 567 }
548 568
549 String toString() { 569 String toString() {
550 return "InputServiceProxy($impl)"; 570 return "InputServiceProxy($impl)";
551 } 571 }
552 } 572 }
553 573
554 574
555 class InputServiceStub extends bindings.Stub { 575 class InputServiceStub extends bindings.Stub {
556 InputService _impl = null; 576 InputService _impl;
557 577
558 InputServiceStub.fromEndpoint( 578 InputServiceStub.fromEndpoint(
559 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 579 core.MojoMessagePipeEndpoint endpoint, [InputService impl])
560 : super.fromEndpoint(endpoint); 580 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
581 _impl = impl;
582 }
561 583
562 InputServiceStub.fromHandle(core.MojoHandle handle, [this._impl]) 584 InputServiceStub.fromHandle(
563 : super.fromHandle(handle); 585 core.MojoHandle handle, [InputService impl])
586 : super.fromHandle(handle, autoBegin: impl != null) {
587 _impl = impl;
588 }
564 589
565 InputServiceStub.unbound() : super.unbound(); 590 InputServiceStub.unbound() : super.unbound();
566 591
567 static InputServiceStub newFromEndpoint( 592 static InputServiceStub newFromEndpoint(
568 core.MojoMessagePipeEndpoint endpoint) { 593 core.MojoMessagePipeEndpoint endpoint) {
569 assert(endpoint.setDescription("For InputServiceStub")); 594 assert(endpoint.setDescription("For InputServiceStub"));
570 return new InputServiceStub.fromEndpoint(endpoint); 595 return new InputServiceStub.fromEndpoint(endpoint);
571 } 596 }
572 597
573 598
574 599
575 dynamic handleMessage(bindings.ServiceMessage message) { 600 dynamic handleMessage(bindings.ServiceMessage message) {
576 if (bindings.ControlMessageHandler.isControlMessage(message)) { 601 if (bindings.ControlMessageHandler.isControlMessage(message)) {
577 return bindings.ControlMessageHandler.handleMessage(this, 602 return bindings.ControlMessageHandler.handleMessage(this,
578 0, 603 0,
579 message); 604 message);
580 } 605 }
581 assert(_impl != null); 606 if (_impl == null) {
607 throw new core.MojoApiError("$this has no implementation set");
608 }
582 switch (message.header.type) { 609 switch (message.header.type) {
583 case _inputServiceMethodSetClientName: 610 case _inputServiceMethodSetClientName:
584 var params = _InputServiceSetClientParams.deserialize( 611 var params = _InputServiceSetClientParams.deserialize(
585 message.payload); 612 message.payload);
586 _impl.setClient(params.client); 613 _impl.setClient(params.client);
587 break; 614 break;
588 default: 615 default:
589 throw new bindings.MojoCodecError("Unexpected message name"); 616 throw new bindings.MojoCodecError("Unexpected message name");
590 break; 617 break;
591 } 618 }
592 return null; 619 return null;
593 } 620 }
594 621
595 InputService get impl => _impl; 622 InputService get impl => _impl;
596 set impl(InputService d) { 623 set impl(InputService d) {
597 assert(_impl == null); 624 if (d == null) {
625 throw new core.MojoApiError("$this: Cannot set a null implementation");
626 }
627 if (isBound && (_impl == null)) {
628 beginHandlingEvents();
629 }
598 _impl = d; 630 _impl = d;
599 } 631 }
600 632
633 @override
634 void bind(core.MojoMessagePipeEndpoint endpoint) {
635 super.bind(endpoint);
636 if (!isOpen && (_impl != null)) {
637 beginHandlingEvents();
638 }
639 }
640
601 String toString() { 641 String toString() {
602 var superString = super.toString(); 642 var superString = super.toString();
603 return "InputServiceStub($superString)"; 643 return "InputServiceStub($superString)";
604 } 644 }
605 645
606 int get version => 0; 646 int get version => 0;
607 647
608 static service_describer.ServiceDescription _cachedServiceDescription; 648 static service_describer.ServiceDescription _cachedServiceDescription;
609 static service_describer.ServiceDescription get serviceDescription { 649 static service_describer.ServiceDescription get serviceDescription {
610 if (_cachedServiceDescription == null) { 650 if (_cachedServiceDescription == null) {
611 _cachedServiceDescription = new _InputServiceServiceDescription(); 651 _cachedServiceDescription = new _InputServiceServiceDescription();
612 } 652 }
613 return _cachedServiceDescription; 653 return _cachedServiceDescription;
614 } 654 }
615 } 655 }
616 656
617 657
618 658
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698