| 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 service_provider_mojom; | 5 library service_provider_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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 dynamic getAllTypeDefinitions([Function responseFactory]) => | 105 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 106 responseFactory(null); | 106 responseFactory(null); |
| 107 } | 107 } |
| 108 | 108 |
| 109 abstract class ServiceProvider { | 109 abstract class ServiceProvider { |
| 110 static const String serviceName = null; | 110 static const String serviceName = null; |
| 111 void connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe
); | 111 void connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe
); |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 class _ServiceProviderProxyControl |
| 115 class _ServiceProviderProxyControl extends bindings.ProxyMessageHandler | 115 extends bindings.ProxyMessageHandler |
| 116 implements bindings.ProxyControl { | 116 implements bindings.ProxyControl { |
| 117 _ServiceProviderProxyControl.fromEndpoint( | 117 _ServiceProviderProxyControl.fromEndpoint( |
| 118 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 118 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 119 | 119 |
| 120 _ServiceProviderProxyControl.fromHandle( | 120 _ServiceProviderProxyControl.fromHandle( |
| 121 core.MojoHandle handle) : super.fromHandle(handle); | 121 core.MojoHandle handle) : super.fromHandle(handle); |
| 122 | 122 |
| 123 _ServiceProviderProxyControl.unbound() : super.unbound(); | 123 _ServiceProviderProxyControl.unbound() : super.unbound(); |
| 124 | 124 |
| 125 service_describer.ServiceDescription get serviceDescription => | 125 service_describer.ServiceDescription get serviceDescription => |
| 126 new _ServiceProviderServiceDescription(); | 126 new _ServiceProviderServiceDescription(); |
| 127 | 127 |
| 128 String get serviceName => ServiceProvider.serviceName; | 128 String get serviceName => ServiceProvider.serviceName; |
| 129 | 129 |
| 130 @override | |
| 131 void handleResponse(bindings.ServiceMessage message) { | 130 void handleResponse(bindings.ServiceMessage message) { |
| 132 switch (message.header.type) { | 131 switch (message.header.type) { |
| 133 default: | 132 default: |
| 134 proxyError("Unexpected message type: ${message.header.type}"); | 133 proxyError("Unexpected message type: ${message.header.type}"); |
| 135 close(immediate: true); | 134 close(immediate: true); |
| 136 break; | 135 break; |
| 137 } | 136 } |
| 138 } | 137 } |
| 139 | 138 |
| 140 @override | 139 @override |
| 141 String toString() { | 140 String toString() { |
| 142 var superString = super.toString(); | 141 var superString = super.toString(); |
| 143 return "_ServiceProviderProxyControl($superString)"; | 142 return "_ServiceProviderProxyControl($superString)"; |
| 144 } | 143 } |
| 145 } | 144 } |
| 146 | 145 |
| 147 | 146 class ServiceProviderProxy |
| 148 class ServiceProviderProxy extends bindings.Proxy | 147 extends bindings.Proxy |
| 149 implements ServiceProvider { | 148 implements ServiceProvider { |
| 150 ServiceProviderProxy.fromEndpoint( | 149 ServiceProviderProxy.fromEndpoint( |
| 151 core.MojoMessagePipeEndpoint endpoint) | 150 core.MojoMessagePipeEndpoint endpoint) |
| 152 : super(new _ServiceProviderProxyControl.fromEndpoint(endpoint)); | 151 : super(new _ServiceProviderProxyControl.fromEndpoint(endpoint)); |
| 153 | 152 |
| 154 ServiceProviderProxy.fromHandle(core.MojoHandle handle) | 153 ServiceProviderProxy.fromHandle(core.MojoHandle handle) |
| 155 : super(new _ServiceProviderProxyControl.fromHandle(handle)); | 154 : super(new _ServiceProviderProxyControl.fromHandle(handle)); |
| 156 | 155 |
| 157 ServiceProviderProxy.unbound() | 156 ServiceProviderProxy.unbound() |
| 158 : super(new _ServiceProviderProxyControl.unbound()); | 157 : super(new _ServiceProviderProxyControl.unbound()); |
| 159 | 158 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 177 return; | 176 return; |
| 178 } | 177 } |
| 179 var params = new _ServiceProviderConnectToServiceParams(); | 178 var params = new _ServiceProviderConnectToServiceParams(); |
| 180 params.interfaceName = interfaceName; | 179 params.interfaceName = interfaceName; |
| 181 params.pipe = pipe; | 180 params.pipe = pipe; |
| 182 ctrl.sendMessage(params, | 181 ctrl.sendMessage(params, |
| 183 _serviceProviderMethodConnectToServiceName); | 182 _serviceProviderMethodConnectToServiceName); |
| 184 } | 183 } |
| 185 } | 184 } |
| 186 | 185 |
| 187 | 186 class _ServiceProviderStubControl |
| 188 class ServiceProviderStub extends bindings.Stub { | 187 extends bindings.StubMessageHandler |
| 188 implements bindings.StubControl<ServiceProvider> { |
| 189 ServiceProvider _impl; | 189 ServiceProvider _impl; |
| 190 | 190 |
| 191 ServiceProviderStub.fromEndpoint( | 191 _ServiceProviderStubControl.fromEndpoint( |
| 192 core.MojoMessagePipeEndpoint endpoint, [ServiceProvider impl]) | 192 core.MojoMessagePipeEndpoint endpoint, [ServiceProvider impl]) |
| 193 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 193 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 194 _impl = impl; | 194 _impl = impl; |
| 195 } | 195 } |
| 196 | 196 |
| 197 ServiceProviderStub.fromHandle( | 197 _ServiceProviderStubControl.fromHandle( |
| 198 core.MojoHandle handle, [ServiceProvider impl]) | 198 core.MojoHandle handle, [ServiceProvider impl]) |
| 199 : super.fromHandle(handle, autoBegin: impl != null) { | 199 : super.fromHandle(handle, autoBegin: impl != null) { |
| 200 _impl = impl; | 200 _impl = impl; |
| 201 } | 201 } |
| 202 | 202 |
| 203 ServiceProviderStub.unbound([this._impl]) : super.unbound(); | 203 _ServiceProviderStubControl.unbound([this._impl]) : super.unbound(); |
| 204 | |
| 205 static ServiceProviderStub newFromEndpoint( | |
| 206 core.MojoMessagePipeEndpoint endpoint) { | |
| 207 assert(endpoint.setDescription("For ServiceProviderStub")); | |
| 208 return new ServiceProviderStub.fromEndpoint(endpoint); | |
| 209 } | |
| 210 | 204 |
| 211 | 205 |
| 212 | 206 |
| 213 dynamic handleMessage(bindings.ServiceMessage message) { | 207 dynamic handleMessage(bindings.ServiceMessage message) { |
| 214 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 208 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 215 return bindings.ControlMessageHandler.handleMessage(this, | 209 return bindings.ControlMessageHandler.handleMessage(this, |
| 216 0, | 210 0, |
| 217 message); | 211 message); |
| 218 } | 212 } |
| 219 if (_impl == null) { | 213 if (_impl == null) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 244 } | 238 } |
| 245 | 239 |
| 246 @override | 240 @override |
| 247 void bind(core.MojoMessagePipeEndpoint endpoint) { | 241 void bind(core.MojoMessagePipeEndpoint endpoint) { |
| 248 super.bind(endpoint); | 242 super.bind(endpoint); |
| 249 if (!isOpen && (_impl != null)) { | 243 if (!isOpen && (_impl != null)) { |
| 250 beginHandlingEvents(); | 244 beginHandlingEvents(); |
| 251 } | 245 } |
| 252 } | 246 } |
| 253 | 247 |
| 248 @override |
| 254 String toString() { | 249 String toString() { |
| 255 var superString = super.toString(); | 250 var superString = super.toString(); |
| 256 return "ServiceProviderStub($superString)"; | 251 return "_ServiceProviderStubControl($superString)"; |
| 257 } | 252 } |
| 258 | 253 |
| 259 int get version => 0; | 254 int get version => 0; |
| 260 | 255 |
| 261 static service_describer.ServiceDescription _cachedServiceDescription; | 256 static service_describer.ServiceDescription _cachedServiceDescription; |
| 262 static service_describer.ServiceDescription get serviceDescription { | 257 static service_describer.ServiceDescription get serviceDescription { |
| 263 if (_cachedServiceDescription == null) { | 258 if (_cachedServiceDescription == null) { |
| 264 _cachedServiceDescription = new _ServiceProviderServiceDescription(); | 259 _cachedServiceDescription = new _ServiceProviderServiceDescription(); |
| 265 } | 260 } |
| 266 return _cachedServiceDescription; | 261 return _cachedServiceDescription; |
| 267 } | 262 } |
| 268 } | 263 } |
| 269 | 264 |
| 265 class ServiceProviderStub |
| 266 extends bindings.Stub<ServiceProvider> |
| 267 implements ServiceProvider { |
| 268 ServiceProviderStub.fromEndpoint( |
| 269 core.MojoMessagePipeEndpoint endpoint, [ServiceProvider impl]) |
| 270 : super(new _ServiceProviderStubControl.fromEndpoint(endpoint, impl)); |
| 271 |
| 272 ServiceProviderStub.fromHandle( |
| 273 core.MojoHandle handle, [ServiceProvider impl]) |
| 274 : super(new _ServiceProviderStubControl.fromHandle(handle, impl)); |
| 275 |
| 276 ServiceProviderStub.unbound([ServiceProvider impl]) |
| 277 : super(new _ServiceProviderStubControl.unbound(impl)); |
| 278 |
| 279 static ServiceProviderStub newFromEndpoint( |
| 280 core.MojoMessagePipeEndpoint endpoint) { |
| 281 assert(endpoint.setDescription("For ServiceProviderStub")); |
| 282 return new ServiceProviderStub.fromEndpoint(endpoint); |
| 283 } |
| 284 |
| 285 static service_describer.ServiceDescription get serviceDescription => |
| 286 _ServiceProviderStubControl.serviceDescription; |
| 287 |
| 288 |
| 289 void connectToService_(String interfaceName, core.MojoMessagePipeEndpoint pipe
) { |
| 290 return impl.connectToService_(interfaceName, pipe); |
| 291 } |
| 292 } |
| 293 |
| 270 | 294 |
| 271 | 295 |
| OLD | NEW |