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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/tracing/tracing.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 tracing_mojom; 5 library tracing_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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 impl.requireVersion(requiredVersion); 498 impl.requireVersion(requiredVersion);
499 } 499 }
500 500
501 String toString() { 501 String toString() {
502 return "TraceProviderProxy($impl)"; 502 return "TraceProviderProxy($impl)";
503 } 503 }
504 } 504 }
505 505
506 506
507 class TraceProviderStub extends bindings.Stub { 507 class TraceProviderStub extends bindings.Stub {
508 TraceProvider _impl = null; 508 TraceProvider _impl;
509 509
510 TraceProviderStub.fromEndpoint( 510 TraceProviderStub.fromEndpoint(
511 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 511 core.MojoMessagePipeEndpoint endpoint, [TraceProvider impl])
512 : super.fromEndpoint(endpoint); 512 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
513 _impl = impl;
514 }
513 515
514 TraceProviderStub.fromHandle(core.MojoHandle handle, [this._impl]) 516 TraceProviderStub.fromHandle(
515 : super.fromHandle(handle); 517 core.MojoHandle handle, [TraceProvider impl])
518 : super.fromHandle(handle, autoBegin: impl != null) {
519 _impl = impl;
520 }
516 521
517 TraceProviderStub.unbound() : super.unbound(); 522 TraceProviderStub.unbound() : super.unbound();
518 523
519 static TraceProviderStub newFromEndpoint( 524 static TraceProviderStub newFromEndpoint(
520 core.MojoMessagePipeEndpoint endpoint) { 525 core.MojoMessagePipeEndpoint endpoint) {
521 assert(endpoint.setDescription("For TraceProviderStub")); 526 assert(endpoint.setDescription("For TraceProviderStub"));
522 return new TraceProviderStub.fromEndpoint(endpoint); 527 return new TraceProviderStub.fromEndpoint(endpoint);
523 } 528 }
524 529
525 530
526 531
527 dynamic handleMessage(bindings.ServiceMessage message) { 532 dynamic handleMessage(bindings.ServiceMessage message) {
528 if (bindings.ControlMessageHandler.isControlMessage(message)) { 533 if (bindings.ControlMessageHandler.isControlMessage(message)) {
529 return bindings.ControlMessageHandler.handleMessage(this, 534 return bindings.ControlMessageHandler.handleMessage(this,
530 0, 535 0,
531 message); 536 message);
532 } 537 }
533 assert(_impl != null); 538 if (_impl == null) {
539 throw new core.MojoApiError("$this has no implementation set");
540 }
534 switch (message.header.type) { 541 switch (message.header.type) {
535 case _traceProviderMethodStartTracingName: 542 case _traceProviderMethodStartTracingName:
536 var params = _TraceProviderStartTracingParams.deserialize( 543 var params = _TraceProviderStartTracingParams.deserialize(
537 message.payload); 544 message.payload);
538 _impl.startTracing(params.categories, params.recorder); 545 _impl.startTracing(params.categories, params.recorder);
539 break; 546 break;
540 case _traceProviderMethodStopTracingName: 547 case _traceProviderMethodStopTracingName:
541 _impl.stopTracing(); 548 _impl.stopTracing();
542 break; 549 break;
543 default: 550 default:
544 throw new bindings.MojoCodecError("Unexpected message name"); 551 throw new bindings.MojoCodecError("Unexpected message name");
545 break; 552 break;
546 } 553 }
547 return null; 554 return null;
548 } 555 }
549 556
550 TraceProvider get impl => _impl; 557 TraceProvider get impl => _impl;
551 set impl(TraceProvider d) { 558 set impl(TraceProvider d) {
552 assert(_impl == null); 559 if (d == null) {
560 throw new core.MojoApiError("$this: Cannot set a null implementation");
561 }
562 if (isBound && (_impl == null)) {
563 beginHandlingEvents();
564 }
553 _impl = d; 565 _impl = d;
554 } 566 }
555 567
568 @override
569 void bind(core.MojoMessagePipeEndpoint endpoint) {
570 super.bind(endpoint);
571 if (!isOpen && (_impl != null)) {
572 beginHandlingEvents();
573 }
574 }
575
556 String toString() { 576 String toString() {
557 var superString = super.toString(); 577 var superString = super.toString();
558 return "TraceProviderStub($superString)"; 578 return "TraceProviderStub($superString)";
559 } 579 }
560 580
561 int get version => 0; 581 int get version => 0;
562 582
563 static service_describer.ServiceDescription _cachedServiceDescription; 583 static service_describer.ServiceDescription _cachedServiceDescription;
564 static service_describer.ServiceDescription get serviceDescription { 584 static service_describer.ServiceDescription get serviceDescription {
565 if (_cachedServiceDescription == null) { 585 if (_cachedServiceDescription == null) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 impl.requireVersion(requiredVersion); 711 impl.requireVersion(requiredVersion);
692 } 712 }
693 713
694 String toString() { 714 String toString() {
695 return "TraceRecorderProxy($impl)"; 715 return "TraceRecorderProxy($impl)";
696 } 716 }
697 } 717 }
698 718
699 719
700 class TraceRecorderStub extends bindings.Stub { 720 class TraceRecorderStub extends bindings.Stub {
701 TraceRecorder _impl = null; 721 TraceRecorder _impl;
702 722
703 TraceRecorderStub.fromEndpoint( 723 TraceRecorderStub.fromEndpoint(
704 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 724 core.MojoMessagePipeEndpoint endpoint, [TraceRecorder impl])
705 : super.fromEndpoint(endpoint); 725 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
726 _impl = impl;
727 }
706 728
707 TraceRecorderStub.fromHandle(core.MojoHandle handle, [this._impl]) 729 TraceRecorderStub.fromHandle(
708 : super.fromHandle(handle); 730 core.MojoHandle handle, [TraceRecorder impl])
731 : super.fromHandle(handle, autoBegin: impl != null) {
732 _impl = impl;
733 }
709 734
710 TraceRecorderStub.unbound() : super.unbound(); 735 TraceRecorderStub.unbound() : super.unbound();
711 736
712 static TraceRecorderStub newFromEndpoint( 737 static TraceRecorderStub newFromEndpoint(
713 core.MojoMessagePipeEndpoint endpoint) { 738 core.MojoMessagePipeEndpoint endpoint) {
714 assert(endpoint.setDescription("For TraceRecorderStub")); 739 assert(endpoint.setDescription("For TraceRecorderStub"));
715 return new TraceRecorderStub.fromEndpoint(endpoint); 740 return new TraceRecorderStub.fromEndpoint(endpoint);
716 } 741 }
717 742
718 743
719 744
720 dynamic handleMessage(bindings.ServiceMessage message) { 745 dynamic handleMessage(bindings.ServiceMessage message) {
721 if (bindings.ControlMessageHandler.isControlMessage(message)) { 746 if (bindings.ControlMessageHandler.isControlMessage(message)) {
722 return bindings.ControlMessageHandler.handleMessage(this, 747 return bindings.ControlMessageHandler.handleMessage(this,
723 0, 748 0,
724 message); 749 message);
725 } 750 }
726 assert(_impl != null); 751 if (_impl == null) {
752 throw new core.MojoApiError("$this has no implementation set");
753 }
727 switch (message.header.type) { 754 switch (message.header.type) {
728 case _traceRecorderMethodRecordName: 755 case _traceRecorderMethodRecordName:
729 var params = _TraceRecorderRecordParams.deserialize( 756 var params = _TraceRecorderRecordParams.deserialize(
730 message.payload); 757 message.payload);
731 _impl.record(params.json); 758 _impl.record(params.json);
732 break; 759 break;
733 default: 760 default:
734 throw new bindings.MojoCodecError("Unexpected message name"); 761 throw new bindings.MojoCodecError("Unexpected message name");
735 break; 762 break;
736 } 763 }
737 return null; 764 return null;
738 } 765 }
739 766
740 TraceRecorder get impl => _impl; 767 TraceRecorder get impl => _impl;
741 set impl(TraceRecorder d) { 768 set impl(TraceRecorder d) {
742 assert(_impl == null); 769 if (d == null) {
770 throw new core.MojoApiError("$this: Cannot set a null implementation");
771 }
772 if (isBound && (_impl == null)) {
773 beginHandlingEvents();
774 }
743 _impl = d; 775 _impl = d;
744 } 776 }
745 777
778 @override
779 void bind(core.MojoMessagePipeEndpoint endpoint) {
780 super.bind(endpoint);
781 if (!isOpen && (_impl != null)) {
782 beginHandlingEvents();
783 }
784 }
785
746 String toString() { 786 String toString() {
747 var superString = super.toString(); 787 var superString = super.toString();
748 return "TraceRecorderStub($superString)"; 788 return "TraceRecorderStub($superString)";
749 } 789 }
750 790
751 int get version => 0; 791 int get version => 0;
752 792
753 static service_describer.ServiceDescription _cachedServiceDescription; 793 static service_describer.ServiceDescription _cachedServiceDescription;
754 static service_describer.ServiceDescription get serviceDescription { 794 static service_describer.ServiceDescription get serviceDescription {
755 if (_cachedServiceDescription == null) { 795 if (_cachedServiceDescription == null) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 impl.requireVersion(requiredVersion); 932 impl.requireVersion(requiredVersion);
893 } 933 }
894 934
895 String toString() { 935 String toString() {
896 return "TraceCollectorProxy($impl)"; 936 return "TraceCollectorProxy($impl)";
897 } 937 }
898 } 938 }
899 939
900 940
901 class TraceCollectorStub extends bindings.Stub { 941 class TraceCollectorStub extends bindings.Stub {
902 TraceCollector _impl = null; 942 TraceCollector _impl;
903 943
904 TraceCollectorStub.fromEndpoint( 944 TraceCollectorStub.fromEndpoint(
905 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 945 core.MojoMessagePipeEndpoint endpoint, [TraceCollector impl])
906 : super.fromEndpoint(endpoint); 946 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
947 _impl = impl;
948 }
907 949
908 TraceCollectorStub.fromHandle(core.MojoHandle handle, [this._impl]) 950 TraceCollectorStub.fromHandle(
909 : super.fromHandle(handle); 951 core.MojoHandle handle, [TraceCollector impl])
952 : super.fromHandle(handle, autoBegin: impl != null) {
953 _impl = impl;
954 }
910 955
911 TraceCollectorStub.unbound() : super.unbound(); 956 TraceCollectorStub.unbound() : super.unbound();
912 957
913 static TraceCollectorStub newFromEndpoint( 958 static TraceCollectorStub newFromEndpoint(
914 core.MojoMessagePipeEndpoint endpoint) { 959 core.MojoMessagePipeEndpoint endpoint) {
915 assert(endpoint.setDescription("For TraceCollectorStub")); 960 assert(endpoint.setDescription("For TraceCollectorStub"));
916 return new TraceCollectorStub.fromEndpoint(endpoint); 961 return new TraceCollectorStub.fromEndpoint(endpoint);
917 } 962 }
918 963
919 964
920 965
921 dynamic handleMessage(bindings.ServiceMessage message) { 966 dynamic handleMessage(bindings.ServiceMessage message) {
922 if (bindings.ControlMessageHandler.isControlMessage(message)) { 967 if (bindings.ControlMessageHandler.isControlMessage(message)) {
923 return bindings.ControlMessageHandler.handleMessage(this, 968 return bindings.ControlMessageHandler.handleMessage(this,
924 0, 969 0,
925 message); 970 message);
926 } 971 }
927 assert(_impl != null); 972 if (_impl == null) {
973 throw new core.MojoApiError("$this has no implementation set");
974 }
928 switch (message.header.type) { 975 switch (message.header.type) {
929 case _traceCollectorMethodStartName: 976 case _traceCollectorMethodStartName:
930 var params = _TraceCollectorStartParams.deserialize( 977 var params = _TraceCollectorStartParams.deserialize(
931 message.payload); 978 message.payload);
932 _impl.start(params.stream, params.categories); 979 _impl.start(params.stream, params.categories);
933 break; 980 break;
934 case _traceCollectorMethodStopAndFlushName: 981 case _traceCollectorMethodStopAndFlushName:
935 _impl.stopAndFlush(); 982 _impl.stopAndFlush();
936 break; 983 break;
937 default: 984 default:
938 throw new bindings.MojoCodecError("Unexpected message name"); 985 throw new bindings.MojoCodecError("Unexpected message name");
939 break; 986 break;
940 } 987 }
941 return null; 988 return null;
942 } 989 }
943 990
944 TraceCollector get impl => _impl; 991 TraceCollector get impl => _impl;
945 set impl(TraceCollector d) { 992 set impl(TraceCollector d) {
946 assert(_impl == null); 993 if (d == null) {
994 throw new core.MojoApiError("$this: Cannot set a null implementation");
995 }
996 if (isBound && (_impl == null)) {
997 beginHandlingEvents();
998 }
947 _impl = d; 999 _impl = d;
948 } 1000 }
949 1001
1002 @override
1003 void bind(core.MojoMessagePipeEndpoint endpoint) {
1004 super.bind(endpoint);
1005 if (!isOpen && (_impl != null)) {
1006 beginHandlingEvents();
1007 }
1008 }
1009
950 String toString() { 1010 String toString() {
951 var superString = super.toString(); 1011 var superString = super.toString();
952 return "TraceCollectorStub($superString)"; 1012 return "TraceCollectorStub($superString)";
953 } 1013 }
954 1014
955 int get version => 0; 1015 int get version => 0;
956 1016
957 static service_describer.ServiceDescription _cachedServiceDescription; 1017 static service_describer.ServiceDescription _cachedServiceDescription;
958 static service_describer.ServiceDescription get serviceDescription { 1018 static service_describer.ServiceDescription get serviceDescription {
959 if (_cachedServiceDescription == null) { 1019 if (_cachedServiceDescription == null) {
960 _cachedServiceDescription = new _TraceCollectorServiceDescription(); 1020 _cachedServiceDescription = new _TraceCollectorServiceDescription();
961 } 1021 }
962 return _cachedServiceDescription; 1022 return _cachedServiceDescription;
963 } 1023 }
964 } 1024 }
965 1025
966 1026
967 1027
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698