| 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 sensors_mojom; | 5 library sensors_mojom; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:mojo/bindings.dart' as bindings; | 9 import 'package:mojo/bindings.dart' as bindings; |
| 10 import 'package:mojo/core.dart' as core; | 10 import 'package:mojo/core.dart' as core; |
| 11 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; |
| 12 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
| 11 | 13 |
| 12 class SensorType extends bindings.MojoEnum { | 14 class SensorType extends bindings.MojoEnum { |
| 13 static const SensorType accelerometer = const SensorType._(0); | 15 static const SensorType accelerometer = const SensorType._(0); |
| 14 static const SensorType ambientTemperature = const SensorType._(1); | 16 static const SensorType ambientTemperature = const SensorType._(1); |
| 15 static const SensorType gameRotationVector = const SensorType._(2); | 17 static const SensorType gameRotationVector = const SensorType._(2); |
| 16 static const SensorType geomagneticRotationVector = const SensorType._(3); | 18 static const SensorType geomagneticRotationVector = const SensorType._(3); |
| 17 static const SensorType gravity = const SensorType._(4); | 19 static const SensorType gravity = const SensorType._(4); |
| 18 static const SensorType gyroscope = const SensorType._(5); | 20 static const SensorType gyroscope = const SensorType._(5); |
| 19 static const SensorType gyroscopeUncalibrated = const SensorType._(6); | 21 static const SensorType gyroscopeUncalibrated = const SensorType._(6); |
| 20 static const SensorType heartRate = const SensorType._(7); | 22 static const SensorType heartRate = const SensorType._(7); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 case relativeHumidity: | 167 case relativeHumidity: |
| 166 return 'SensorType.relativeHumidity'; | 168 return 'SensorType.relativeHumidity'; |
| 167 case rotationVector: | 169 case rotationVector: |
| 168 return 'SensorType.rotationVector'; | 170 return 'SensorType.rotationVector'; |
| 169 case significantMotion: | 171 case significantMotion: |
| 170 return 'SensorType.significantMotion'; | 172 return 'SensorType.significantMotion'; |
| 171 case stepCounter: | 173 case stepCounter: |
| 172 return 'SensorType.stepCounter'; | 174 return 'SensorType.stepCounter'; |
| 173 case stepDetector: | 175 case stepDetector: |
| 174 return 'SensorType.stepDetector'; | 176 return 'SensorType.stepDetector'; |
| 177 default: |
| 178 return null; |
| 175 } | 179 } |
| 176 } | 180 } |
| 177 | 181 |
| 178 int toJson() => mojoEnumValue; | 182 int toJson() => mojoEnumValue; |
| 179 } | 183 } |
| 180 | 184 |
| 181 | 185 |
| 182 | 186 |
| 187 |
| 188 |
| 183 class SensorData extends bindings.Struct { | 189 class SensorData extends bindings.Struct { |
| 184 static const List<bindings.StructDataHeader> kVersions = const [ | 190 static const List<bindings.StructDataHeader> kVersions = const [ |
| 185 const bindings.StructDataHeader(32, 0) | 191 const bindings.StructDataHeader(32, 0) |
| 186 ]; | 192 ]; |
| 187 int accuracy = 0; | 193 int accuracy = 0; |
| 188 int timeStamp = 0; | 194 int timeStamp = 0; |
| 189 List<double> values = null; | 195 List<double> values = null; |
| 190 | 196 |
| 191 SensorData() : super(kVersions.last.size); | 197 SensorData() : super(kVersions.last.size); |
| 192 | 198 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 Map toJson() { | 264 Map toJson() { |
| 259 Map map = new Map(); | 265 Map map = new Map(); |
| 260 map["accuracy"] = accuracy; | 266 map["accuracy"] = accuracy; |
| 261 map["timeStamp"] = timeStamp; | 267 map["timeStamp"] = timeStamp; |
| 262 map["values"] = values; | 268 map["values"] = values; |
| 263 return map; | 269 return map; |
| 264 } | 270 } |
| 265 } | 271 } |
| 266 | 272 |
| 267 | 273 |
| 274 |
| 275 |
| 268 class _SensorListenerOnAccuracyChangedParams extends bindings.Struct { | 276 class _SensorListenerOnAccuracyChangedParams extends bindings.Struct { |
| 269 static const List<bindings.StructDataHeader> kVersions = const [ | 277 static const List<bindings.StructDataHeader> kVersions = const [ |
| 270 const bindings.StructDataHeader(16, 0) | 278 const bindings.StructDataHeader(16, 0) |
| 271 ]; | 279 ]; |
| 272 int accuracy = 0; | 280 int accuracy = 0; |
| 273 | 281 |
| 274 _SensorListenerOnAccuracyChangedParams() : super(kVersions.last.size); | 282 _SensorListenerOnAccuracyChangedParams() : super(kVersions.last.size); |
| 275 | 283 |
| 276 static _SensorListenerOnAccuracyChangedParams deserialize(bindings.Message mes
sage) { | 284 static _SensorListenerOnAccuracyChangedParams deserialize(bindings.Message mes
sage) { |
| 277 var decoder = new bindings.Decoder(message); | 285 var decoder = new bindings.Decoder(message); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 333 } |
| 326 | 334 |
| 327 Map toJson() { | 335 Map toJson() { |
| 328 Map map = new Map(); | 336 Map map = new Map(); |
| 329 map["accuracy"] = accuracy; | 337 map["accuracy"] = accuracy; |
| 330 return map; | 338 return map; |
| 331 } | 339 } |
| 332 } | 340 } |
| 333 | 341 |
| 334 | 342 |
| 343 |
| 344 |
| 335 class _SensorListenerOnSensorChangedParams extends bindings.Struct { | 345 class _SensorListenerOnSensorChangedParams extends bindings.Struct { |
| 336 static const List<bindings.StructDataHeader> kVersions = const [ | 346 static const List<bindings.StructDataHeader> kVersions = const [ |
| 337 const bindings.StructDataHeader(16, 0) | 347 const bindings.StructDataHeader(16, 0) |
| 338 ]; | 348 ]; |
| 339 SensorData data = null; | 349 SensorData data = null; |
| 340 | 350 |
| 341 _SensorListenerOnSensorChangedParams() : super(kVersions.last.size); | 351 _SensorListenerOnSensorChangedParams() : super(kVersions.last.size); |
| 342 | 352 |
| 343 static _SensorListenerOnSensorChangedParams deserialize(bindings.Message messa
ge) { | 353 static _SensorListenerOnSensorChangedParams deserialize(bindings.Message messa
ge) { |
| 344 var decoder = new bindings.Decoder(message); | 354 var decoder = new bindings.Decoder(message); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } | 403 } |
| 394 | 404 |
| 395 Map toJson() { | 405 Map toJson() { |
| 396 Map map = new Map(); | 406 Map map = new Map(); |
| 397 map["data"] = data; | 407 map["data"] = data; |
| 398 return map; | 408 return map; |
| 399 } | 409 } |
| 400 } | 410 } |
| 401 | 411 |
| 402 | 412 |
| 413 |
| 414 |
| 403 class _SensorServiceAddListenerParams extends bindings.Struct { | 415 class _SensorServiceAddListenerParams extends bindings.Struct { |
| 404 static const List<bindings.StructDataHeader> kVersions = const [ | 416 static const List<bindings.StructDataHeader> kVersions = const [ |
| 405 const bindings.StructDataHeader(24, 0) | 417 const bindings.StructDataHeader(24, 0) |
| 406 ]; | 418 ]; |
| 407 SensorType type = null; | 419 SensorType type = null; |
| 408 Object listener = null; | 420 Object listener = null; |
| 409 | 421 |
| 410 _SensorServiceAddListenerParams() : super(kVersions.last.size); | 422 _SensorServiceAddListenerParams() : super(kVersions.last.size); |
| 411 | 423 |
| 412 static _SensorServiceAddListenerParams deserialize(bindings.Message message) { | 424 static _SensorServiceAddListenerParams deserialize(bindings.Message message) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 "type: $type" ", " | 482 "type: $type" ", " |
| 471 "listener: $listener" ")"; | 483 "listener: $listener" ")"; |
| 472 } | 484 } |
| 473 | 485 |
| 474 Map toJson() { | 486 Map toJson() { |
| 475 throw new bindings.MojoCodecError( | 487 throw new bindings.MojoCodecError( |
| 476 'Object containing handles cannot be encoded to JSON.'); | 488 'Object containing handles cannot be encoded to JSON.'); |
| 477 } | 489 } |
| 478 } | 490 } |
| 479 | 491 |
| 492 |
| 493 |
| 494 |
| 480 const int _SensorListener_onAccuracyChangedName = 0; | 495 const int _SensorListener_onAccuracyChangedName = 0; |
| 481 const int _SensorListener_onSensorChangedName = 1; | 496 const int _SensorListener_onSensorChangedName = 1; |
| 482 | 497 |
| 498 |
| 499 |
| 500 class _SensorListenerServiceDescription implements service_describer.ServiceDesc
ription { |
| 501 dynamic getTopLevelInterface([Function responseFactory]) => null; |
| 502 |
| 503 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => null; |
| 504 |
| 505 dynamic getAllTypeDefinitions([Function responseFactory]) => null; |
| 506 } |
| 507 |
| 483 abstract class SensorListener { | 508 abstract class SensorListener { |
| 484 static const String serviceName = null; | 509 static const String serviceName = null; |
| 485 void onAccuracyChanged(int accuracy); | 510 void onAccuracyChanged(int accuracy); |
| 486 void onSensorChanged(SensorData data); | 511 void onSensorChanged(SensorData data); |
| 487 } | 512 } |
| 488 | 513 |
| 489 | 514 |
| 490 class _SensorListenerProxyImpl extends bindings.Proxy { | 515 class _SensorListenerProxyImpl extends bindings.Proxy { |
| 491 _SensorListenerProxyImpl.fromEndpoint( | 516 _SensorListenerProxyImpl.fromEndpoint( |
| 492 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 517 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 493 | 518 |
| 494 _SensorListenerProxyImpl.fromHandle(core.MojoHandle handle) : | 519 _SensorListenerProxyImpl.fromHandle(core.MojoHandle handle) : |
| 495 super.fromHandle(handle); | 520 super.fromHandle(handle); |
| 496 | 521 |
| 497 _SensorListenerProxyImpl.unbound() : super.unbound(); | 522 _SensorListenerProxyImpl.unbound() : super.unbound(); |
| 498 | 523 |
| 499 static _SensorListenerProxyImpl newFromEndpoint( | 524 static _SensorListenerProxyImpl newFromEndpoint( |
| 500 core.MojoMessagePipeEndpoint endpoint) { | 525 core.MojoMessagePipeEndpoint endpoint) { |
| 501 assert(endpoint.setDescription("For _SensorListenerProxyImpl")); | 526 assert(endpoint.setDescription("For _SensorListenerProxyImpl")); |
| 502 return new _SensorListenerProxyImpl.fromEndpoint(endpoint); | 527 return new _SensorListenerProxyImpl.fromEndpoint(endpoint); |
| 503 } | 528 } |
| 504 | 529 |
| 530 service_describer.ServiceDescription get serviceDescription => |
| 531 new _SensorListenerServiceDescription(); |
| 532 |
| 505 void handleResponse(bindings.ServiceMessage message) { | 533 void handleResponse(bindings.ServiceMessage message) { |
| 506 switch (message.header.type) { | 534 switch (message.header.type) { |
| 507 default: | 535 default: |
| 508 proxyError("Unexpected message type: ${message.header.type}"); | 536 proxyError("Unexpected message type: ${message.header.type}"); |
| 509 close(immediate: true); | 537 close(immediate: true); |
| 510 break; | 538 break; |
| 511 } | 539 } |
| 512 } | 540 } |
| 513 | 541 |
| 514 String toString() { | 542 String toString() { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 assert(_impl == null); | 680 assert(_impl == null); |
| 653 _impl = d; | 681 _impl = d; |
| 654 } | 682 } |
| 655 | 683 |
| 656 String toString() { | 684 String toString() { |
| 657 var superString = super.toString(); | 685 var superString = super.toString(); |
| 658 return "SensorListenerStub($superString)"; | 686 return "SensorListenerStub($superString)"; |
| 659 } | 687 } |
| 660 | 688 |
| 661 int get version => 0; | 689 int get version => 0; |
| 690 |
| 691 service_describer.ServiceDescription get serviceDescription => |
| 692 new _SensorListenerServiceDescription(); |
| 662 } | 693 } |
| 663 | 694 |
| 664 const int _SensorService_addListenerName = 0; | 695 const int _SensorService_addListenerName = 0; |
| 665 | 696 |
| 697 |
| 698 |
| 699 class _SensorServiceServiceDescription implements service_describer.ServiceDescr
iption { |
| 700 dynamic getTopLevelInterface([Function responseFactory]) => null; |
| 701 |
| 702 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => null; |
| 703 |
| 704 dynamic getAllTypeDefinitions([Function responseFactory]) => null; |
| 705 } |
| 706 |
| 666 abstract class SensorService { | 707 abstract class SensorService { |
| 667 static const String serviceName = "sensors::SensorService"; | 708 static const String serviceName = "sensors::SensorService"; |
| 668 void addListener(SensorType type, Object listener); | 709 void addListener(SensorType type, Object listener); |
| 669 } | 710 } |
| 670 | 711 |
| 671 | 712 |
| 672 class _SensorServiceProxyImpl extends bindings.Proxy { | 713 class _SensorServiceProxyImpl extends bindings.Proxy { |
| 673 _SensorServiceProxyImpl.fromEndpoint( | 714 _SensorServiceProxyImpl.fromEndpoint( |
| 674 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 715 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 675 | 716 |
| 676 _SensorServiceProxyImpl.fromHandle(core.MojoHandle handle) : | 717 _SensorServiceProxyImpl.fromHandle(core.MojoHandle handle) : |
| 677 super.fromHandle(handle); | 718 super.fromHandle(handle); |
| 678 | 719 |
| 679 _SensorServiceProxyImpl.unbound() : super.unbound(); | 720 _SensorServiceProxyImpl.unbound() : super.unbound(); |
| 680 | 721 |
| 681 static _SensorServiceProxyImpl newFromEndpoint( | 722 static _SensorServiceProxyImpl newFromEndpoint( |
| 682 core.MojoMessagePipeEndpoint endpoint) { | 723 core.MojoMessagePipeEndpoint endpoint) { |
| 683 assert(endpoint.setDescription("For _SensorServiceProxyImpl")); | 724 assert(endpoint.setDescription("For _SensorServiceProxyImpl")); |
| 684 return new _SensorServiceProxyImpl.fromEndpoint(endpoint); | 725 return new _SensorServiceProxyImpl.fromEndpoint(endpoint); |
| 685 } | 726 } |
| 686 | 727 |
| 728 service_describer.ServiceDescription get serviceDescription => |
| 729 new _SensorServiceServiceDescription(); |
| 730 |
| 687 void handleResponse(bindings.ServiceMessage message) { | 731 void handleResponse(bindings.ServiceMessage message) { |
| 688 switch (message.header.type) { | 732 switch (message.header.type) { |
| 689 default: | 733 default: |
| 690 proxyError("Unexpected message type: ${message.header.type}"); | 734 proxyError("Unexpected message type: ${message.header.type}"); |
| 691 close(immediate: true); | 735 close(immediate: true); |
| 692 break; | 736 break; |
| 693 } | 737 } |
| 694 } | 738 } |
| 695 | 739 |
| 696 String toString() { | 740 String toString() { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 assert(_impl == null); | 865 assert(_impl == null); |
| 822 _impl = d; | 866 _impl = d; |
| 823 } | 867 } |
| 824 | 868 |
| 825 String toString() { | 869 String toString() { |
| 826 var superString = super.toString(); | 870 var superString = super.toString(); |
| 827 return "SensorServiceStub($superString)"; | 871 return "SensorServiceStub($superString)"; |
| 828 } | 872 } |
| 829 | 873 |
| 830 int get version => 0; | 874 int get version => 0; |
| 875 |
| 876 service_describer.ServiceDescription get serviceDescription => |
| 877 new _SensorServiceServiceDescription(); |
| 831 } | 878 } |
| 832 | 879 |
| 833 | 880 |
| 881 |
| OLD | NEW |