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

Unified Diff: mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart

Issue 1998433002: Dart: Adds Interface and InterfaceRequest interfaces. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge 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 side-by-side diff with in-line comments
Download patch
Index: mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart
diff --git a/mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart b/mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart
index 228c92069845e6663f5bd63dccb05a980d3f108e..ff3ba5cef2a2e1d783a719e44046838712fde7bd 100644
--- a/mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart
+++ b/mojo/dart/packages/mojo_services/lib/sensors/sensors.mojom.dart
@@ -431,7 +431,7 @@ class _SensorServiceAddListenerParams extends bindings.Struct {
const bindings.StructDataHeader(24, 0)
];
SensorType type = null;
- Object listener = null;
+ SensorListenerInterface listener = null;
_SensorServiceAddListenerParams() : super(kVersions.last.size);
@@ -529,13 +529,51 @@ class _SensorListenerServiceDescription implements service_describer.ServiceDesc
abstract class SensorListener {
static const String serviceName = null;
+
+ static service_describer.ServiceDescription _cachedServiceDescription;
+ static service_describer.ServiceDescription get serviceDescription {
+ if (_cachedServiceDescription == null) {
+ _cachedServiceDescription = new _SensorListenerServiceDescription();
+ }
+ return _cachedServiceDescription;
+ }
+
+ static SensorListenerProxy connectToService(
+ bindings.ServiceConnector s, String url, [String serviceName]) {
+ SensorListenerProxy p = new SensorListenerProxy.unbound();
+ String name = serviceName ?? SensorListener.serviceName;
+ if ((name == null) || name.isEmpty) {
+ throw new core.MojoApiError(
+ "If an interface has no ServiceName, then one must be provided.");
+ }
+ s.connectToService(url, p, name);
+ return p;
+ }
void onAccuracyChanged(int accuracy);
void onSensorChanged(SensorData data);
}
+abstract class SensorListenerInterface
+ implements bindings.MojoInterface<SensorListener>,
+ SensorListener {
+ factory SensorListenerInterface([SensorListener impl]) =>
+ new SensorListenerStub.unbound(impl);
+ factory SensorListenerInterface.fromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint,
+ [SensorListener impl]) =>
+ new SensorListenerStub.fromEndpoint(endpoint, impl);
+}
+
+abstract class SensorListenerInterfaceRequest
+ implements bindings.MojoInterface<SensorListener>,
+ SensorListener {
+ factory SensorListenerInterfaceRequest() =>
+ new SensorListenerProxy.unbound();
+}
+
class _SensorListenerProxyControl
extends bindings.ProxyMessageHandler
- implements bindings.ProxyControl {
+ implements bindings.ProxyControl<SensorListener> {
_SensorListenerProxyControl.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
@@ -544,9 +582,6 @@ class _SensorListenerProxyControl
_SensorListenerProxyControl.unbound() : super.unbound();
- service_describer.ServiceDescription get serviceDescription =>
- new _SensorListenerServiceDescription();
-
String get serviceName => SensorListener.serviceName;
void handleResponse(bindings.ServiceMessage message) {
@@ -558,6 +593,11 @@ class _SensorListenerProxyControl
}
}
+ SensorListener get impl => null;
+ set impl(SensorListener _) {
+ throw new core.MojoApiError("The impl of a Proxy cannot be set.");
+ }
+
@override
String toString() {
var superString = super.toString();
@@ -566,8 +606,10 @@ class _SensorListenerProxyControl
}
class SensorListenerProxy
- extends bindings.Proxy
- implements SensorListener {
+ extends bindings.Proxy<SensorListener>
+ implements SensorListener,
+ SensorListenerInterface,
+ SensorListenerInterfaceRequest {
SensorListenerProxy.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint)
: super(new _SensorListenerProxyControl.fromEndpoint(endpoint));
@@ -584,13 +626,6 @@ class SensorListenerProxy
return new SensorListenerProxy.fromEndpoint(endpoint);
}
- factory SensorListenerProxy.connectToService(
- bindings.ServiceConnector s, String url, [String serviceName]) {
- SensorListenerProxy p = new SensorListenerProxy.unbound();
- s.connectToService(url, p, serviceName);
- return p;
- }
-
void onAccuracyChanged(int accuracy) {
if (!ctrl.isBound) {
@@ -633,6 +668,8 @@ class _SensorListenerStubControl
_SensorListenerStubControl.unbound([this._impl]) : super.unbound();
+ String get serviceName => SensorListener.serviceName;
+
dynamic handleMessage(bindings.ServiceMessage message) {
@@ -688,19 +725,16 @@ class _SensorListenerStubControl
}
int get version => 0;
-
- static service_describer.ServiceDescription _cachedServiceDescription;
- static service_describer.ServiceDescription get serviceDescription {
- if (_cachedServiceDescription == null) {
- _cachedServiceDescription = new _SensorListenerServiceDescription();
- }
- return _cachedServiceDescription;
- }
}
class SensorListenerStub
extends bindings.Stub<SensorListener>
- implements SensorListener {
+ implements SensorListener,
+ SensorListenerInterface,
+ SensorListenerInterfaceRequest {
+ SensorListenerStub.unbound([SensorListener impl])
+ : super(new _SensorListenerStubControl.unbound(impl));
+
SensorListenerStub.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint, [SensorListener impl])
: super(new _SensorListenerStubControl.fromEndpoint(endpoint, impl));
@@ -709,18 +743,12 @@ class SensorListenerStub
core.MojoHandle handle, [SensorListener impl])
: super(new _SensorListenerStubControl.fromHandle(handle, impl));
- SensorListenerStub.unbound([SensorListener impl])
- : super(new _SensorListenerStubControl.unbound(impl));
-
static SensorListenerStub newFromEndpoint(
core.MojoMessagePipeEndpoint endpoint) {
assert(endpoint.setDescription("For SensorListenerStub"));
return new SensorListenerStub.fromEndpoint(endpoint);
}
- static service_describer.ServiceDescription get serviceDescription =>
- _SensorListenerStubControl.serviceDescription;
-
void onAccuracyChanged(int accuracy) {
return impl.onAccuracyChanged(accuracy);
@@ -745,12 +773,50 @@ class _SensorServiceServiceDescription implements service_describer.ServiceDescr
abstract class SensorService {
static const String serviceName = "sensors::SensorService";
- void addListener(SensorType type, Object listener);
+
+ static service_describer.ServiceDescription _cachedServiceDescription;
+ static service_describer.ServiceDescription get serviceDescription {
+ if (_cachedServiceDescription == null) {
+ _cachedServiceDescription = new _SensorServiceServiceDescription();
+ }
+ return _cachedServiceDescription;
+ }
+
+ static SensorServiceProxy connectToService(
+ bindings.ServiceConnector s, String url, [String serviceName]) {
+ SensorServiceProxy p = new SensorServiceProxy.unbound();
+ String name = serviceName ?? SensorService.serviceName;
+ if ((name == null) || name.isEmpty) {
+ throw new core.MojoApiError(
+ "If an interface has no ServiceName, then one must be provided.");
+ }
+ s.connectToService(url, p, name);
+ return p;
+ }
+ void addListener(SensorType type, SensorListenerInterface listener);
+}
+
+abstract class SensorServiceInterface
+ implements bindings.MojoInterface<SensorService>,
+ SensorService {
+ factory SensorServiceInterface([SensorService impl]) =>
+ new SensorServiceStub.unbound(impl);
+ factory SensorServiceInterface.fromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint,
+ [SensorService impl]) =>
+ new SensorServiceStub.fromEndpoint(endpoint, impl);
+}
+
+abstract class SensorServiceInterfaceRequest
+ implements bindings.MojoInterface<SensorService>,
+ SensorService {
+ factory SensorServiceInterfaceRequest() =>
+ new SensorServiceProxy.unbound();
}
class _SensorServiceProxyControl
extends bindings.ProxyMessageHandler
- implements bindings.ProxyControl {
+ implements bindings.ProxyControl<SensorService> {
_SensorServiceProxyControl.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
@@ -759,9 +825,6 @@ class _SensorServiceProxyControl
_SensorServiceProxyControl.unbound() : super.unbound();
- service_describer.ServiceDescription get serviceDescription =>
- new _SensorServiceServiceDescription();
-
String get serviceName => SensorService.serviceName;
void handleResponse(bindings.ServiceMessage message) {
@@ -773,6 +836,11 @@ class _SensorServiceProxyControl
}
}
+ SensorService get impl => null;
+ set impl(SensorService _) {
+ throw new core.MojoApiError("The impl of a Proxy cannot be set.");
+ }
+
@override
String toString() {
var superString = super.toString();
@@ -781,8 +849,10 @@ class _SensorServiceProxyControl
}
class SensorServiceProxy
- extends bindings.Proxy
- implements SensorService {
+ extends bindings.Proxy<SensorService>
+ implements SensorService,
+ SensorServiceInterface,
+ SensorServiceInterfaceRequest {
SensorServiceProxy.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint)
: super(new _SensorServiceProxyControl.fromEndpoint(endpoint));
@@ -799,15 +869,8 @@ class SensorServiceProxy
return new SensorServiceProxy.fromEndpoint(endpoint);
}
- factory SensorServiceProxy.connectToService(
- bindings.ServiceConnector s, String url, [String serviceName]) {
- SensorServiceProxy p = new SensorServiceProxy.unbound();
- s.connectToService(url, p, serviceName);
- return p;
- }
-
- void addListener(SensorType type, Object listener) {
+ void addListener(SensorType type, SensorListenerInterface listener) {
if (!ctrl.isBound) {
ctrl.proxyError("The Proxy is closed.");
return;
@@ -839,6 +902,8 @@ class _SensorServiceStubControl
_SensorServiceStubControl.unbound([this._impl]) : super.unbound();
+ String get serviceName => SensorService.serviceName;
+
dynamic handleMessage(bindings.ServiceMessage message) {
@@ -889,19 +954,16 @@ class _SensorServiceStubControl
}
int get version => 0;
-
- static service_describer.ServiceDescription _cachedServiceDescription;
- static service_describer.ServiceDescription get serviceDescription {
- if (_cachedServiceDescription == null) {
- _cachedServiceDescription = new _SensorServiceServiceDescription();
- }
- return _cachedServiceDescription;
- }
}
class SensorServiceStub
extends bindings.Stub<SensorService>
- implements SensorService {
+ implements SensorService,
+ SensorServiceInterface,
+ SensorServiceInterfaceRequest {
+ SensorServiceStub.unbound([SensorService impl])
+ : super(new _SensorServiceStubControl.unbound(impl));
+
SensorServiceStub.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint, [SensorService impl])
: super(new _SensorServiceStubControl.fromEndpoint(endpoint, impl));
@@ -910,20 +972,14 @@ class SensorServiceStub
core.MojoHandle handle, [SensorService impl])
: super(new _SensorServiceStubControl.fromHandle(handle, impl));
- SensorServiceStub.unbound([SensorService impl])
- : super(new _SensorServiceStubControl.unbound(impl));
-
static SensorServiceStub newFromEndpoint(
core.MojoMessagePipeEndpoint endpoint) {
assert(endpoint.setDescription("For SensorServiceStub"));
return new SensorServiceStub.fromEndpoint(endpoint);
}
- static service_describer.ServiceDescription get serviceDescription =>
- _SensorServiceStubControl.serviceDescription;
-
- void addListener(SensorType type, Object listener) {
+ void addListener(SensorType type, SensorListenerInterface listener) {
return impl.addListener(type, listener);
}
}

Powered by Google App Engine
This is Rietveld 408576698