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

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

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Cleanup 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 // 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 sensors_mojom; 5 library sensors_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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 class SensorData extends bindings.Struct { 184 class SensorData extends bindings.Struct {
185 static const List<bindings.StructDataHeader> kVersions = const [ 185 static const List<bindings.StructDataHeader> kVersions = const [
186 const bindings.StructDataHeader(32, 0) 186 const bindings.StructDataHeader(32, 0)
187 ]; 187 ];
188 int accuracy = 0; 188 int accuracy = 0;
189 int timeStamp = 0; 189 int timeStamp = 0;
190 List<double> values = null; 190 List<double> values = null;
191 191
192 SensorData() : super(kVersions.last.size); 192 SensorData() : super(kVersions.last.size);
193 193
194 SensorData.init(
195 int this.accuracy,
196 int this.timeStamp,
197 List<double> this.values
198 ) : super(kVersions.last.size);
199
194 static SensorData deserialize(bindings.Message message) { 200 static SensorData deserialize(bindings.Message message) {
195 var decoder = new bindings.Decoder(message); 201 var decoder = new bindings.Decoder(message);
196 var result = decode(decoder); 202 var result = decode(decoder);
197 if (decoder.excessHandles != null) { 203 if (decoder.excessHandles != null) {
198 decoder.excessHandles.forEach((h) => h.close()); 204 decoder.excessHandles.forEach((h) => h.close());
199 } 205 }
200 return result; 206 return result;
201 } 207 }
202 208
203 static SensorData decode(bindings.Decoder decoder0) { 209 static SensorData decode(bindings.Decoder decoder0) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 288
283 289
284 class _SensorListenerOnAccuracyChangedParams extends bindings.Struct { 290 class _SensorListenerOnAccuracyChangedParams extends bindings.Struct {
285 static const List<bindings.StructDataHeader> kVersions = const [ 291 static const List<bindings.StructDataHeader> kVersions = const [
286 const bindings.StructDataHeader(16, 0) 292 const bindings.StructDataHeader(16, 0)
287 ]; 293 ];
288 int accuracy = 0; 294 int accuracy = 0;
289 295
290 _SensorListenerOnAccuracyChangedParams() : super(kVersions.last.size); 296 _SensorListenerOnAccuracyChangedParams() : super(kVersions.last.size);
291 297
298 _SensorListenerOnAccuracyChangedParams.init(
299 int this.accuracy
300 ) : super(kVersions.last.size);
301
292 static _SensorListenerOnAccuracyChangedParams deserialize(bindings.Message mes sage) { 302 static _SensorListenerOnAccuracyChangedParams deserialize(bindings.Message mes sage) {
293 var decoder = new bindings.Decoder(message); 303 var decoder = new bindings.Decoder(message);
294 var result = decode(decoder); 304 var result = decode(decoder);
295 if (decoder.excessHandles != null) { 305 if (decoder.excessHandles != null) {
296 decoder.excessHandles.forEach((h) => h.close()); 306 decoder.excessHandles.forEach((h) => h.close());
297 } 307 }
298 return result; 308 return result;
299 } 309 }
300 310
301 static _SensorListenerOnAccuracyChangedParams decode(bindings.Decoder decoder0 ) { 311 static _SensorListenerOnAccuracyChangedParams decode(bindings.Decoder decoder0 ) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 364
355 365
356 class _SensorListenerOnSensorChangedParams extends bindings.Struct { 366 class _SensorListenerOnSensorChangedParams extends bindings.Struct {
357 static const List<bindings.StructDataHeader> kVersions = const [ 367 static const List<bindings.StructDataHeader> kVersions = const [
358 const bindings.StructDataHeader(16, 0) 368 const bindings.StructDataHeader(16, 0)
359 ]; 369 ];
360 SensorData data = null; 370 SensorData data = null;
361 371
362 _SensorListenerOnSensorChangedParams() : super(kVersions.last.size); 372 _SensorListenerOnSensorChangedParams() : super(kVersions.last.size);
363 373
374 _SensorListenerOnSensorChangedParams.init(
375 SensorData this.data
376 ) : super(kVersions.last.size);
377
364 static _SensorListenerOnSensorChangedParams deserialize(bindings.Message messa ge) { 378 static _SensorListenerOnSensorChangedParams deserialize(bindings.Message messa ge) {
365 var decoder = new bindings.Decoder(message); 379 var decoder = new bindings.Decoder(message);
366 var result = decode(decoder); 380 var result = decode(decoder);
367 if (decoder.excessHandles != null) { 381 if (decoder.excessHandles != null) {
368 decoder.excessHandles.forEach((h) => h.close()); 382 decoder.excessHandles.forEach((h) => h.close());
369 } 383 }
370 return result; 384 return result;
371 } 385 }
372 386
373 static _SensorListenerOnSensorChangedParams decode(bindings.Decoder decoder0) { 387 static _SensorListenerOnSensorChangedParams decode(bindings.Decoder decoder0) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 442
429 class _SensorServiceAddListenerParams extends bindings.Struct { 443 class _SensorServiceAddListenerParams extends bindings.Struct {
430 static const List<bindings.StructDataHeader> kVersions = const [ 444 static const List<bindings.StructDataHeader> kVersions = const [
431 const bindings.StructDataHeader(24, 0) 445 const bindings.StructDataHeader(24, 0)
432 ]; 446 ];
433 SensorType type = null; 447 SensorType type = null;
434 SensorListenerInterface listener = null; 448 SensorListenerInterface listener = null;
435 449
436 _SensorServiceAddListenerParams() : super(kVersions.last.size); 450 _SensorServiceAddListenerParams() : super(kVersions.last.size);
437 451
452 _SensorServiceAddListenerParams.init(
453 SensorType this.type,
454 SensorListenerInterface this.listener
455 ) : super(kVersions.last.size);
456
438 static _SensorServiceAddListenerParams deserialize(bindings.Message message) { 457 static _SensorServiceAddListenerParams deserialize(bindings.Message message) {
439 var decoder = new bindings.Decoder(message); 458 var decoder = new bindings.Decoder(message);
440 var result = decode(decoder); 459 var result = decode(decoder);
441 if (decoder.excessHandles != null) { 460 if (decoder.excessHandles != null) {
442 decoder.excessHandles.forEach((h) => h.close()); 461 decoder.excessHandles.forEach((h) => h.close());
443 } 462 }
444 return result; 463 return result;
445 } 464 }
446 465
447 static _SensorServiceAddListenerParams decode(bindings.Decoder decoder0) { 466 static _SensorServiceAddListenerParams decode(bindings.Decoder decoder0) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 Map toJson() { 529 Map toJson() {
511 throw new bindings.MojoCodecError( 530 throw new bindings.MojoCodecError(
512 'Object containing handles cannot be encoded to JSON.'); 531 'Object containing handles cannot be encoded to JSON.');
513 } 532 }
514 } 533 }
515 534
516 const int _sensorListenerMethodOnAccuracyChangedName = 0; 535 const int _sensorListenerMethodOnAccuracyChangedName = 0;
517 const int _sensorListenerMethodOnSensorChangedName = 1; 536 const int _sensorListenerMethodOnSensorChangedName = 1;
518 537
519 class _SensorListenerServiceDescription implements service_describer.ServiceDesc ription { 538 class _SensorListenerServiceDescription implements service_describer.ServiceDesc ription {
520 dynamic getTopLevelInterface([Function responseFactory]) => 539 void getTopLevelInterface(Function responder) {
521 responseFactory(null); 540 responder(null);
541 }
522 542
523 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 543 void getTypeDefinition(String typeKey, Function responder) {
524 responseFactory(null); 544 responder(null);
545 }
525 546
526 dynamic getAllTypeDefinitions([Function responseFactory]) => 547 void getAllTypeDefinitions(Function responder) {
527 responseFactory(null); 548 responder(null);
549 }
528 } 550 }
529 551
530 abstract class SensorListener { 552 abstract class SensorListener {
531 static const String serviceName = null; 553 static const String serviceName = null;
532 554
533 static service_describer.ServiceDescription _cachedServiceDescription; 555 static service_describer.ServiceDescription _cachedServiceDescription;
534 static service_describer.ServiceDescription get serviceDescription { 556 static service_describer.ServiceDescription get serviceDescription {
535 if (_cachedServiceDescription == null) { 557 if (_cachedServiceDescription == null) {
536 _cachedServiceDescription = new _SensorListenerServiceDescription(); 558 _cachedServiceDescription = new _SensorListenerServiceDescription();
537 } 559 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 : super.fromHandle(handle, autoBegin: impl != null) { 704 : super.fromHandle(handle, autoBegin: impl != null) {
683 _impl = impl; 705 _impl = impl;
684 } 706 }
685 707
686 _SensorListenerStubControl.unbound([this._impl]) : super.unbound(); 708 _SensorListenerStubControl.unbound([this._impl]) : super.unbound();
687 709
688 String get serviceName => SensorListener.serviceName; 710 String get serviceName => SensorListener.serviceName;
689 711
690 712
691 713
692 dynamic handleMessage(bindings.ServiceMessage message) { 714 void handleMessage(bindings.ServiceMessage message) {
693 if (bindings.ControlMessageHandler.isControlMessage(message)) { 715 if (bindings.ControlMessageHandler.isControlMessage(message)) {
694 return bindings.ControlMessageHandler.handleMessage(this, 716 bindings.ControlMessageHandler.handleMessage(
695 0, 717 this, 0, message);
696 message); 718 return;
697 } 719 }
698 if (_impl == null) { 720 if (_impl == null) {
699 throw new core.MojoApiError("$this has no implementation set"); 721 throw new core.MojoApiError("$this has no implementation set");
700 } 722 }
701 switch (message.header.type) { 723 switch (message.header.type) {
702 case _sensorListenerMethodOnAccuracyChangedName: 724 case _sensorListenerMethodOnAccuracyChangedName:
703 var params = _SensorListenerOnAccuracyChangedParams.deserialize( 725 var params = _SensorListenerOnAccuracyChangedParams.deserialize(
704 message.payload); 726 message.payload);
705 _impl.onAccuracyChanged(params.accuracy); 727 _impl.onAccuracyChanged(params.accuracy);
706 break; 728 break;
707 case _sensorListenerMethodOnSensorChangedName: 729 case _sensorListenerMethodOnSensorChangedName:
708 var params = _SensorListenerOnSensorChangedParams.deserialize( 730 var params = _SensorListenerOnSensorChangedParams.deserialize(
709 message.payload); 731 message.payload);
710 _impl.onSensorChanged(params.data); 732 _impl.onSensorChanged(params.data);
711 break; 733 break;
712 default: 734 default:
713 throw new bindings.MojoCodecError("Unexpected message name"); 735 throw new bindings.MojoCodecError("Unexpected message name");
714 break; 736 break;
715 } 737 }
716 return null;
717 } 738 }
718 739
719 SensorListener get impl => _impl; 740 SensorListener get impl => _impl;
720 set impl(SensorListener d) { 741 set impl(SensorListener d) {
721 if (d == null) { 742 if (d == null) {
722 throw new core.MojoApiError("$this: Cannot set a null implementation"); 743 throw new core.MojoApiError("$this: Cannot set a null implementation");
723 } 744 }
724 if (isBound && (_impl == null)) { 745 if (isBound && (_impl == null)) {
725 beginHandlingEvents(); 746 beginHandlingEvents();
726 } 747 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 return impl.onAccuracyChanged(accuracy); 792 return impl.onAccuracyChanged(accuracy);
772 } 793 }
773 void onSensorChanged(SensorData data) { 794 void onSensorChanged(SensorData data) {
774 return impl.onSensorChanged(data); 795 return impl.onSensorChanged(data);
775 } 796 }
776 } 797 }
777 798
778 const int _sensorServiceMethodAddListenerName = 0; 799 const int _sensorServiceMethodAddListenerName = 0;
779 800
780 class _SensorServiceServiceDescription implements service_describer.ServiceDescr iption { 801 class _SensorServiceServiceDescription implements service_describer.ServiceDescr iption {
781 dynamic getTopLevelInterface([Function responseFactory]) => 802 void getTopLevelInterface(Function responder) {
782 responseFactory(null); 803 responder(null);
804 }
783 805
784 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 806 void getTypeDefinition(String typeKey, Function responder) {
785 responseFactory(null); 807 responder(null);
808 }
786 809
787 dynamic getAllTypeDefinitions([Function responseFactory]) => 810 void getAllTypeDefinitions(Function responder) {
788 responseFactory(null); 811 responder(null);
812 }
789 } 813 }
790 814
791 abstract class SensorService { 815 abstract class SensorService {
792 static const String serviceName = "sensors::SensorService"; 816 static const String serviceName = "sensors::SensorService";
793 817
794 static service_describer.ServiceDescription _cachedServiceDescription; 818 static service_describer.ServiceDescription _cachedServiceDescription;
795 static service_describer.ServiceDescription get serviceDescription { 819 static service_describer.ServiceDescription get serviceDescription {
796 if (_cachedServiceDescription == null) { 820 if (_cachedServiceDescription == null) {
797 _cachedServiceDescription = new _SensorServiceServiceDescription(); 821 _cachedServiceDescription = new _SensorServiceServiceDescription();
798 } 822 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 : super.fromHandle(handle, autoBegin: impl != null) { 953 : super.fromHandle(handle, autoBegin: impl != null) {
930 _impl = impl; 954 _impl = impl;
931 } 955 }
932 956
933 _SensorServiceStubControl.unbound([this._impl]) : super.unbound(); 957 _SensorServiceStubControl.unbound([this._impl]) : super.unbound();
934 958
935 String get serviceName => SensorService.serviceName; 959 String get serviceName => SensorService.serviceName;
936 960
937 961
938 962
939 dynamic handleMessage(bindings.ServiceMessage message) { 963 void handleMessage(bindings.ServiceMessage message) {
940 if (bindings.ControlMessageHandler.isControlMessage(message)) { 964 if (bindings.ControlMessageHandler.isControlMessage(message)) {
941 return bindings.ControlMessageHandler.handleMessage(this, 965 bindings.ControlMessageHandler.handleMessage(
942 0, 966 this, 0, message);
943 message); 967 return;
944 } 968 }
945 if (_impl == null) { 969 if (_impl == null) {
946 throw new core.MojoApiError("$this has no implementation set"); 970 throw new core.MojoApiError("$this has no implementation set");
947 } 971 }
948 switch (message.header.type) { 972 switch (message.header.type) {
949 case _sensorServiceMethodAddListenerName: 973 case _sensorServiceMethodAddListenerName:
950 var params = _SensorServiceAddListenerParams.deserialize( 974 var params = _SensorServiceAddListenerParams.deserialize(
951 message.payload); 975 message.payload);
952 _impl.addListener(params.type, params.listener); 976 _impl.addListener(params.type, params.listener);
953 break; 977 break;
954 default: 978 default:
955 throw new bindings.MojoCodecError("Unexpected message name"); 979 throw new bindings.MojoCodecError("Unexpected message name");
956 break; 980 break;
957 } 981 }
958 return null;
959 } 982 }
960 983
961 SensorService get impl => _impl; 984 SensorService get impl => _impl;
962 set impl(SensorService d) { 985 set impl(SensorService d) {
963 if (d == null) { 986 if (d == null) {
964 throw new core.MojoApiError("$this: Cannot set a null implementation"); 987 throw new core.MojoApiError("$this: Cannot set a null implementation");
965 } 988 }
966 if (isBound && (_impl == null)) { 989 if (isBound && (_impl == null)) {
967 beginHandlingEvents(); 990 beginHandlingEvents();
968 } 991 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 } 1032 }
1010 1033
1011 1034
1012 void addListener(SensorType type, SensorListenerInterface listener) { 1035 void addListener(SensorType type, SensorListenerInterface listener) {
1013 return impl.addListener(type, listener); 1036 return impl.addListener(type, listener);
1014 } 1037 }
1015 } 1038 }
1016 1039
1017 1040
1018 1041
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698