| 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 icu_data_mojom; | 5 library icu_data_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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 dynamic getAllTypeDefinitions([Function responseFactory]) => | 164 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 165 responseFactory(null); | 165 responseFactory(null); |
| 166 } | 166 } |
| 167 | 167 |
| 168 abstract class IcuData { | 168 abstract class IcuData { |
| 169 static const String serviceName = "icu_data::ICUData"; | 169 static const String serviceName = "icu_data::ICUData"; |
| 170 dynamic map(String sha1hash,[Function responseFactory = null]); | 170 dynamic map(String sha1hash,[Function responseFactory = null]); |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 class _IcuDataProxyImpl extends bindings.Proxy { | 174 class _IcuDataProxyControl extends bindings.ProxyMessageHandler |
| 175 _IcuDataProxyImpl.fromEndpoint( | 175 implements bindings.ProxyControl { |
| 176 _IcuDataProxyControl.fromEndpoint( |
| 176 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 177 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 177 | 178 |
| 178 _IcuDataProxyImpl.fromHandle(core.MojoHandle handle) : | 179 _IcuDataProxyControl.fromHandle( |
| 179 super.fromHandle(handle); | 180 core.MojoHandle handle) : super.fromHandle(handle); |
| 180 | 181 |
| 181 _IcuDataProxyImpl.unbound() : super.unbound(); | 182 _IcuDataProxyControl.unbound() : super.unbound(); |
| 182 | |
| 183 static _IcuDataProxyImpl newFromEndpoint( | |
| 184 core.MojoMessagePipeEndpoint endpoint) { | |
| 185 assert(endpoint.setDescription("For _IcuDataProxyImpl")); | |
| 186 return new _IcuDataProxyImpl.fromEndpoint(endpoint); | |
| 187 } | |
| 188 | 183 |
| 189 service_describer.ServiceDescription get serviceDescription => | 184 service_describer.ServiceDescription get serviceDescription => |
| 190 new _IcuDataServiceDescription(); | 185 new _IcuDataServiceDescription(); |
| 191 | 186 |
| 187 String get serviceName => IcuData.serviceName; |
| 188 |
| 189 @override |
| 192 void handleResponse(bindings.ServiceMessage message) { | 190 void handleResponse(bindings.ServiceMessage message) { |
| 193 switch (message.header.type) { | 191 switch (message.header.type) { |
| 194 case _icuDataMethodMapName: | 192 case _icuDataMethodMapName: |
| 195 var r = IcuDataMapResponseParams.deserialize( | 193 var r = IcuDataMapResponseParams.deserialize( |
| 196 message.payload); | 194 message.payload); |
| 197 if (!message.header.hasRequestId) { | 195 if (!message.header.hasRequestId) { |
| 198 proxyError("Expected a message with a valid request Id."); | 196 proxyError("Expected a message with a valid request Id."); |
| 199 return; | 197 return; |
| 200 } | 198 } |
| 201 Completer c = completerMap[message.header.requestId]; | 199 Completer c = completerMap[message.header.requestId]; |
| 202 if (c == null) { | 200 if (c == null) { |
| 203 proxyError( | 201 proxyError( |
| 204 "Message had unknown request Id: ${message.header.requestId}"); | 202 "Message had unknown request Id: ${message.header.requestId}"); |
| 205 return; | 203 return; |
| 206 } | 204 } |
| 207 completerMap.remove(message.header.requestId); | 205 completerMap.remove(message.header.requestId); |
| 208 if (c.isCompleted) { | 206 if (c.isCompleted) { |
| 209 proxyError("Response completer already completed"); | 207 proxyError("Response completer already completed"); |
| 210 return; | 208 return; |
| 211 } | 209 } |
| 212 c.complete(r); | 210 c.complete(r); |
| 213 break; | 211 break; |
| 214 default: | 212 default: |
| 215 proxyError("Unexpected message type: ${message.header.type}"); | 213 proxyError("Unexpected message type: ${message.header.type}"); |
| 216 close(immediate: true); | 214 close(immediate: true); |
| 217 break; | 215 break; |
| 218 } | 216 } |
| 219 } | 217 } |
| 220 | 218 |
| 219 @override |
| 221 String toString() { | 220 String toString() { |
| 222 var superString = super.toString(); | 221 var superString = super.toString(); |
| 223 return "_IcuDataProxyImpl($superString)"; | 222 return "_IcuDataProxyControl($superString)"; |
| 224 } | 223 } |
| 225 } | 224 } |
| 226 | 225 |
| 227 | 226 |
| 228 class _IcuDataProxyCalls implements IcuData { | 227 class IcuDataProxy extends bindings.Proxy |
| 229 _IcuDataProxyImpl _proxyImpl; | 228 implements IcuData { |
| 229 IcuDataProxy.fromEndpoint( |
| 230 core.MojoMessagePipeEndpoint endpoint) |
| 231 : super(new _IcuDataProxyControl.fromEndpoint(endpoint)); |
| 230 | 232 |
| 231 _IcuDataProxyCalls(this._proxyImpl); | 233 IcuDataProxy.fromHandle(core.MojoHandle handle) |
| 232 dynamic map(String sha1hash,[Function responseFactory = null]) { | 234 : super(new _IcuDataProxyControl.fromHandle(handle)); |
| 233 var params = new _IcuDataMapParams(); | |
| 234 params.sha1hash = sha1hash; | |
| 235 return _proxyImpl.sendMessageWithRequestId( | |
| 236 params, | |
| 237 _icuDataMethodMapName, | |
| 238 -1, | |
| 239 bindings.MessageHeader.kMessageExpectsResponse); | |
| 240 } | |
| 241 } | |
| 242 | 235 |
| 236 IcuDataProxy.unbound() |
| 237 : super(new _IcuDataProxyControl.unbound()); |
| 243 | 238 |
| 244 class IcuDataProxy implements bindings.ProxyBase { | 239 static IcuDataProxy newFromEndpoint( |
| 245 final bindings.Proxy impl; | 240 core.MojoMessagePipeEndpoint endpoint) { |
| 246 IcuData ptr; | 241 assert(endpoint.setDescription("For IcuDataProxy")); |
| 247 | 242 return new IcuDataProxy.fromEndpoint(endpoint); |
| 248 IcuDataProxy(_IcuDataProxyImpl proxyImpl) : | |
| 249 impl = proxyImpl, | |
| 250 ptr = new _IcuDataProxyCalls(proxyImpl); | |
| 251 | |
| 252 IcuDataProxy.fromEndpoint( | |
| 253 core.MojoMessagePipeEndpoint endpoint) : | |
| 254 impl = new _IcuDataProxyImpl.fromEndpoint(endpoint) { | |
| 255 ptr = new _IcuDataProxyCalls(impl); | |
| 256 } | |
| 257 | |
| 258 IcuDataProxy.fromHandle(core.MojoHandle handle) : | |
| 259 impl = new _IcuDataProxyImpl.fromHandle(handle) { | |
| 260 ptr = new _IcuDataProxyCalls(impl); | |
| 261 } | |
| 262 | |
| 263 IcuDataProxy.unbound() : | |
| 264 impl = new _IcuDataProxyImpl.unbound() { | |
| 265 ptr = new _IcuDataProxyCalls(impl); | |
| 266 } | 243 } |
| 267 | 244 |
| 268 factory IcuDataProxy.connectToService( | 245 factory IcuDataProxy.connectToService( |
| 269 bindings.ServiceConnector s, String url, [String serviceName]) { | 246 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 270 IcuDataProxy p = new IcuDataProxy.unbound(); | 247 IcuDataProxy p = new IcuDataProxy.unbound(); |
| 271 s.connectToService(url, p, serviceName); | 248 s.connectToService(url, p, serviceName); |
| 272 return p; | 249 return p; |
| 273 } | 250 } |
| 274 | 251 |
| 275 static IcuDataProxy newFromEndpoint( | |
| 276 core.MojoMessagePipeEndpoint endpoint) { | |
| 277 assert(endpoint.setDescription("For IcuDataProxy")); | |
| 278 return new IcuDataProxy.fromEndpoint(endpoint); | |
| 279 } | |
| 280 | 252 |
| 281 String get serviceName => IcuData.serviceName; | 253 dynamic map(String sha1hash,[Function responseFactory = null]) { |
| 282 | 254 var params = new _IcuDataMapParams(); |
| 283 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 255 params.sha1hash = sha1hash; |
| 284 | 256 return ctrl.sendMessageWithRequestId( |
| 285 Future responseOrError(Future f) => impl.responseOrError(f); | 257 params, |
| 286 | 258 _icuDataMethodMapName, |
| 287 Future get errorFuture => impl.errorFuture; | 259 -1, |
| 288 | 260 bindings.MessageHeader.kMessageExpectsResponse); |
| 289 int get version => impl.version; | |
| 290 | |
| 291 Future<int> queryVersion() => impl.queryVersion(); | |
| 292 | |
| 293 void requireVersion(int requiredVersion) { | |
| 294 impl.requireVersion(requiredVersion); | |
| 295 } | |
| 296 | |
| 297 String toString() { | |
| 298 return "IcuDataProxy($impl)"; | |
| 299 } | 261 } |
| 300 } | 262 } |
| 301 | 263 |
| 302 | 264 |
| 303 class IcuDataStub extends bindings.Stub { | 265 class IcuDataStub extends bindings.Stub { |
| 304 IcuData _impl; | 266 IcuData _impl; |
| 305 | 267 |
| 306 IcuDataStub.fromEndpoint( | 268 IcuDataStub.fromEndpoint( |
| 307 core.MojoMessagePipeEndpoint endpoint, [IcuData impl]) | 269 core.MojoMessagePipeEndpoint endpoint, [IcuData impl]) |
| 308 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 270 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 static service_describer.ServiceDescription get serviceDescription { | 361 static service_describer.ServiceDescription get serviceDescription { |
| 400 if (_cachedServiceDescription == null) { | 362 if (_cachedServiceDescription == null) { |
| 401 _cachedServiceDescription = new _IcuDataServiceDescription(); | 363 _cachedServiceDescription = new _IcuDataServiceDescription(); |
| 402 } | 364 } |
| 403 return _cachedServiceDescription; | 365 return _cachedServiceDescription; |
| 404 } | 366 } |
| 405 } | 367 } |
| 406 | 368 |
| 407 | 369 |
| 408 | 370 |
| OLD | NEW |