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

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: Move code from mojo_patch to proxy.dart 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 : super.fromHandle(handle, autoBegin: impl != null) { 687 : super.fromHandle(handle, autoBegin: impl != null) {
666 _impl = impl; 688 _impl = impl;
667 } 689 }
668 690
669 _SensorListenerStubControl.unbound([this._impl]) : super.unbound(); 691 _SensorListenerStubControl.unbound([this._impl]) : super.unbound();
670 692
671 String get serviceName => SensorListener.serviceName; 693 String get serviceName => SensorListener.serviceName;
672 694
673 695
674 696
675 dynamic handleMessage(bindings.ServiceMessage message) { 697 void handleMessage(bindings.ServiceMessage message) {
676 if (bindings.ControlMessageHandler.isControlMessage(message)) { 698 if (bindings.ControlMessageHandler.isControlMessage(message)) {
677 return bindings.ControlMessageHandler.handleMessage(this, 699 bindings.ControlMessageHandler.handleMessage(
678 0, 700 this, 0, message);
679 message); 701 return;
680 } 702 }
681 if (_impl == null) { 703 if (_impl == null) {
682 throw new core.MojoApiError("$this has no implementation set"); 704 throw new core.MojoApiError("$this has no implementation set");
683 } 705 }
684 switch (message.header.type) { 706 switch (message.header.type) {
685 case _sensorListenerMethodOnAccuracyChangedName: 707 case _sensorListenerMethodOnAccuracyChangedName:
686 var params = _SensorListenerOnAccuracyChangedParams.deserialize( 708 var params = _SensorListenerOnAccuracyChangedParams.deserialize(
687 message.payload); 709 message.payload);
688 _impl.onAccuracyChanged(params.accuracy); 710 _impl.onAccuracyChanged(params.accuracy);
689 break; 711 break;
690 case _sensorListenerMethodOnSensorChangedName: 712 case _sensorListenerMethodOnSensorChangedName:
691 var params = _SensorListenerOnSensorChangedParams.deserialize( 713 var params = _SensorListenerOnSensorChangedParams.deserialize(
692 message.payload); 714 message.payload);
693 _impl.onSensorChanged(params.data); 715 _impl.onSensorChanged(params.data);
694 break; 716 break;
695 default: 717 default:
696 throw new bindings.MojoCodecError("Unexpected message name"); 718 throw new bindings.MojoCodecError("Unexpected message name");
697 break; 719 break;
698 } 720 }
699 return null;
700 } 721 }
701 722
702 SensorListener get impl => _impl; 723 SensorListener get impl => _impl;
703 set impl(SensorListener d) { 724 set impl(SensorListener d) {
704 if (d == null) { 725 if (d == null) {
705 throw new core.MojoApiError("$this: Cannot set a null implementation"); 726 throw new core.MojoApiError("$this: Cannot set a null implementation");
706 } 727 }
707 if (isBound && (_impl == null)) { 728 if (isBound && (_impl == null)) {
708 beginHandlingEvents(); 729 beginHandlingEvents();
709 } 730 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 return impl.onAccuracyChanged(accuracy); 775 return impl.onAccuracyChanged(accuracy);
755 } 776 }
756 void onSensorChanged(SensorData data) { 777 void onSensorChanged(SensorData data) {
757 return impl.onSensorChanged(data); 778 return impl.onSensorChanged(data);
758 } 779 }
759 } 780 }
760 781
761 const int _sensorServiceMethodAddListenerName = 0; 782 const int _sensorServiceMethodAddListenerName = 0;
762 783
763 class _SensorServiceServiceDescription implements service_describer.ServiceDescr iption { 784 class _SensorServiceServiceDescription implements service_describer.ServiceDescr iption {
764 dynamic getTopLevelInterface([Function responseFactory]) => 785 void getTopLevelInterface(Function responder) {
765 responseFactory(null); 786 responder(null);
787 }
766 788
767 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 789 void getTypeDefinition(String typeKey, Function responder) {
768 responseFactory(null); 790 responder(null);
791 }
769 792
770 dynamic getAllTypeDefinitions([Function responseFactory]) => 793 void getAllTypeDefinitions(Function responder) {
771 responseFactory(null); 794 responder(null);
795 }
772 } 796 }
773 797
774 abstract class SensorService { 798 abstract class SensorService {
775 static const String serviceName = "sensors::SensorService"; 799 static const String serviceName = "sensors::SensorService";
776 800
777 static service_describer.ServiceDescription _cachedServiceDescription; 801 static service_describer.ServiceDescription _cachedServiceDescription;
778 static service_describer.ServiceDescription get serviceDescription { 802 static service_describer.ServiceDescription get serviceDescription {
779 if (_cachedServiceDescription == null) { 803 if (_cachedServiceDescription == null) {
780 _cachedServiceDescription = new _SensorServiceServiceDescription(); 804 _cachedServiceDescription = new _SensorServiceServiceDescription();
781 } 805 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 : super.fromHandle(handle, autoBegin: impl != null) { 923 : super.fromHandle(handle, autoBegin: impl != null) {
900 _impl = impl; 924 _impl = impl;
901 } 925 }
902 926
903 _SensorServiceStubControl.unbound([this._impl]) : super.unbound(); 927 _SensorServiceStubControl.unbound([this._impl]) : super.unbound();
904 928
905 String get serviceName => SensorService.serviceName; 929 String get serviceName => SensorService.serviceName;
906 930
907 931
908 932
909 dynamic handleMessage(bindings.ServiceMessage message) { 933 void handleMessage(bindings.ServiceMessage message) {
910 if (bindings.ControlMessageHandler.isControlMessage(message)) { 934 if (bindings.ControlMessageHandler.isControlMessage(message)) {
911 return bindings.ControlMessageHandler.handleMessage(this, 935 bindings.ControlMessageHandler.handleMessage(
912 0, 936 this, 0, message);
913 message); 937 return;
914 } 938 }
915 if (_impl == null) { 939 if (_impl == null) {
916 throw new core.MojoApiError("$this has no implementation set"); 940 throw new core.MojoApiError("$this has no implementation set");
917 } 941 }
918 switch (message.header.type) { 942 switch (message.header.type) {
919 case _sensorServiceMethodAddListenerName: 943 case _sensorServiceMethodAddListenerName:
920 var params = _SensorServiceAddListenerParams.deserialize( 944 var params = _SensorServiceAddListenerParams.deserialize(
921 message.payload); 945 message.payload);
922 _impl.addListener(params.type, params.listener); 946 _impl.addListener(params.type, params.listener);
923 break; 947 break;
924 default: 948 default:
925 throw new bindings.MojoCodecError("Unexpected message name"); 949 throw new bindings.MojoCodecError("Unexpected message name");
926 break; 950 break;
927 } 951 }
928 return null;
929 } 952 }
930 953
931 SensorService get impl => _impl; 954 SensorService get impl => _impl;
932 set impl(SensorService d) { 955 set impl(SensorService d) {
933 if (d == null) { 956 if (d == null) {
934 throw new core.MojoApiError("$this: Cannot set a null implementation"); 957 throw new core.MojoApiError("$this: Cannot set a null implementation");
935 } 958 }
936 if (isBound && (_impl == null)) { 959 if (isBound && (_impl == null)) {
937 beginHandlingEvents(); 960 beginHandlingEvents();
938 } 961 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 } 1002 }
980 1003
981 1004
982 void addListener(SensorType type, SensorListenerInterface listener) { 1005 void addListener(SensorType type, SensorListenerInterface listener) {
983 return impl.addListener(type, listener); 1006 return impl.addListener(type, listener);
984 } 1007 }
985 } 1008 }
986 1009
987 1010
988 1011
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698