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

Unified Diff: mojo/dart/packages/mojo/lib/mojo/service_provider.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/lib/mojo/service_provider.mojom.dart
diff --git a/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart b/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
index 9f859f7d206f87ff660be3fd738bcb6f4488be70..3956995ae8e12bf6373ee00443c624e132cc0215 100644
--- a/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
+++ b/mojo/dart/packages/mojo/lib/mojo/service_provider.mojom.dart
@@ -108,12 +108,50 @@ class _ServiceProviderServiceDescription implements service_describer.ServiceDes
abstract class ServiceProvider {
static const String serviceName = null;
+
+ static service_describer.ServiceDescription _cachedServiceDescription;
+ static service_describer.ServiceDescription get serviceDescription {
+ if (_cachedServiceDescription == null) {
+ _cachedServiceDescription = new _ServiceProviderServiceDescription();
+ }
+ return _cachedServiceDescription;
+ }
+
+ static ServiceProviderProxy connectToService(
+ bindings.ServiceConnector s, String url, [String serviceName]) {
+ ServiceProviderProxy p = new ServiceProviderProxy.unbound();
+ String name = serviceName ?? ServiceProvider.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 connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe);
}
+abstract class ServiceProviderInterface
+ implements bindings.MojoInterface<ServiceProvider>,
+ ServiceProvider {
+ factory ServiceProviderInterface([ServiceProvider impl]) =>
+ new ServiceProviderStub.unbound(impl);
+ factory ServiceProviderInterface.fromEndpoint(
+ core.MojoMessagePipeEndpoint endpoint,
+ [ServiceProvider impl]) =>
+ new ServiceProviderStub.fromEndpoint(endpoint, impl);
+}
+
+abstract class ServiceProviderInterfaceRequest
+ implements bindings.MojoInterface<ServiceProvider>,
+ ServiceProvider {
+ factory ServiceProviderInterfaceRequest() =>
+ new ServiceProviderProxy.unbound();
+}
+
class _ServiceProviderProxyControl
extends bindings.ProxyMessageHandler
- implements bindings.ProxyControl {
+ implements bindings.ProxyControl<ServiceProvider> {
_ServiceProviderProxyControl.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
@@ -122,9 +160,6 @@ class _ServiceProviderProxyControl
_ServiceProviderProxyControl.unbound() : super.unbound();
- service_describer.ServiceDescription get serviceDescription =>
- new _ServiceProviderServiceDescription();
-
String get serviceName => ServiceProvider.serviceName;
void handleResponse(bindings.ServiceMessage message) {
@@ -136,6 +171,11 @@ class _ServiceProviderProxyControl
}
}
+ ServiceProvider get impl => null;
+ set impl(ServiceProvider _) {
+ throw new core.MojoApiError("The impl of a Proxy cannot be set.");
+ }
+
@override
String toString() {
var superString = super.toString();
@@ -144,8 +184,10 @@ class _ServiceProviderProxyControl
}
class ServiceProviderProxy
- extends bindings.Proxy
- implements ServiceProvider {
+ extends bindings.Proxy<ServiceProvider>
+ implements ServiceProvider,
+ ServiceProviderInterface,
+ ServiceProviderInterfaceRequest {
ServiceProviderProxy.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint)
: super(new _ServiceProviderProxyControl.fromEndpoint(endpoint));
@@ -162,13 +204,6 @@ class ServiceProviderProxy
return new ServiceProviderProxy.fromEndpoint(endpoint);
}
- factory ServiceProviderProxy.connectToService(
- bindings.ServiceConnector s, String url, [String serviceName]) {
- ServiceProviderProxy p = new ServiceProviderProxy.unbound();
- s.connectToService(url, p, serviceName);
- return p;
- }
-
void connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe) {
if (!ctrl.isBound) {
@@ -202,6 +237,8 @@ class _ServiceProviderStubControl
_ServiceProviderStubControl.unbound([this._impl]) : super.unbound();
+ String get serviceName => ServiceProvider.serviceName;
+
dynamic handleMessage(bindings.ServiceMessage message) {
@@ -252,19 +289,16 @@ class _ServiceProviderStubControl
}
int get version => 0;
-
- static service_describer.ServiceDescription _cachedServiceDescription;
- static service_describer.ServiceDescription get serviceDescription {
- if (_cachedServiceDescription == null) {
- _cachedServiceDescription = new _ServiceProviderServiceDescription();
- }
- return _cachedServiceDescription;
- }
}
class ServiceProviderStub
extends bindings.Stub<ServiceProvider>
- implements ServiceProvider {
+ implements ServiceProvider,
+ ServiceProviderInterface,
+ ServiceProviderInterfaceRequest {
+ ServiceProviderStub.unbound([ServiceProvider impl])
+ : super(new _ServiceProviderStubControl.unbound(impl));
+
ServiceProviderStub.fromEndpoint(
core.MojoMessagePipeEndpoint endpoint, [ServiceProvider impl])
: super(new _ServiceProviderStubControl.fromEndpoint(endpoint, impl));
@@ -273,18 +307,12 @@ class ServiceProviderStub
core.MojoHandle handle, [ServiceProvider impl])
: super(new _ServiceProviderStubControl.fromHandle(handle, impl));
- ServiceProviderStub.unbound([ServiceProvider impl])
- : super(new _ServiceProviderStubControl.unbound(impl));
-
static ServiceProviderStub newFromEndpoint(
core.MojoMessagePipeEndpoint endpoint) {
assert(endpoint.setDescription("For ServiceProviderStub"));
return new ServiceProviderStub.fromEndpoint(endpoint);
}
- static service_describer.ServiceDescription get serviceDescription =>
- _ServiceProviderStubControl.serviceDescription;
-
void connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe) {
return impl.connectToService_(interfaceName, pipe);

Powered by Google App Engine
This is Rietveld 408576698