| 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 device_info_mojom; | 5 library device_info_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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 dynamic getAllTypeDefinitions([Function responseFactory]) => | 242 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 243 responseFactory(null); | 243 responseFactory(null); |
| 244 } | 244 } |
| 245 | 245 |
| 246 abstract class DeviceInfo { | 246 abstract class DeviceInfo { |
| 247 static const String serviceName = "mojo::DeviceInfo"; | 247 static const String serviceName = "mojo::DeviceInfo"; |
| 248 dynamic getDeviceType([Function responseFactory = null]); | 248 dynamic getDeviceType([Function responseFactory = null]); |
| 249 } | 249 } |
| 250 | 250 |
| 251 | 251 |
| 252 class _DeviceInfoProxyImpl extends bindings.Proxy { | 252 class _DeviceInfoProxyControl extends bindings.ProxyMessageHandler |
| 253 _DeviceInfoProxyImpl.fromEndpoint( | 253 implements bindings.ProxyControl { |
| 254 _DeviceInfoProxyControl.fromEndpoint( |
| 254 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 255 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 255 | 256 |
| 256 _DeviceInfoProxyImpl.fromHandle(core.MojoHandle handle) : | 257 _DeviceInfoProxyControl.fromHandle( |
| 257 super.fromHandle(handle); | 258 core.MojoHandle handle) : super.fromHandle(handle); |
| 258 | 259 |
| 259 _DeviceInfoProxyImpl.unbound() : super.unbound(); | 260 _DeviceInfoProxyControl.unbound() : super.unbound(); |
| 260 | |
| 261 static _DeviceInfoProxyImpl newFromEndpoint( | |
| 262 core.MojoMessagePipeEndpoint endpoint) { | |
| 263 assert(endpoint.setDescription("For _DeviceInfoProxyImpl")); | |
| 264 return new _DeviceInfoProxyImpl.fromEndpoint(endpoint); | |
| 265 } | |
| 266 | 261 |
| 267 service_describer.ServiceDescription get serviceDescription => | 262 service_describer.ServiceDescription get serviceDescription => |
| 268 new _DeviceInfoServiceDescription(); | 263 new _DeviceInfoServiceDescription(); |
| 269 | 264 |
| 265 String get serviceName => DeviceInfo.serviceName; |
| 266 |
| 267 @override |
| 270 void handleResponse(bindings.ServiceMessage message) { | 268 void handleResponse(bindings.ServiceMessage message) { |
| 271 switch (message.header.type) { | 269 switch (message.header.type) { |
| 272 case _deviceInfoMethodGetDeviceTypeName: | 270 case _deviceInfoMethodGetDeviceTypeName: |
| 273 var r = DeviceInfoGetDeviceTypeResponseParams.deserialize( | 271 var r = DeviceInfoGetDeviceTypeResponseParams.deserialize( |
| 274 message.payload); | 272 message.payload); |
| 275 if (!message.header.hasRequestId) { | 273 if (!message.header.hasRequestId) { |
| 276 proxyError("Expected a message with a valid request Id."); | 274 proxyError("Expected a message with a valid request Id."); |
| 277 return; | 275 return; |
| 278 } | 276 } |
| 279 Completer c = completerMap[message.header.requestId]; | 277 Completer c = completerMap[message.header.requestId]; |
| 280 if (c == null) { | 278 if (c == null) { |
| 281 proxyError( | 279 proxyError( |
| 282 "Message had unknown request Id: ${message.header.requestId}"); | 280 "Message had unknown request Id: ${message.header.requestId}"); |
| 283 return; | 281 return; |
| 284 } | 282 } |
| 285 completerMap.remove(message.header.requestId); | 283 completerMap.remove(message.header.requestId); |
| 286 if (c.isCompleted) { | 284 if (c.isCompleted) { |
| 287 proxyError("Response completer already completed"); | 285 proxyError("Response completer already completed"); |
| 288 return; | 286 return; |
| 289 } | 287 } |
| 290 c.complete(r); | 288 c.complete(r); |
| 291 break; | 289 break; |
| 292 default: | 290 default: |
| 293 proxyError("Unexpected message type: ${message.header.type}"); | 291 proxyError("Unexpected message type: ${message.header.type}"); |
| 294 close(immediate: true); | 292 close(immediate: true); |
| 295 break; | 293 break; |
| 296 } | 294 } |
| 297 } | 295 } |
| 298 | 296 |
| 297 @override |
| 299 String toString() { | 298 String toString() { |
| 300 var superString = super.toString(); | 299 var superString = super.toString(); |
| 301 return "_DeviceInfoProxyImpl($superString)"; | 300 return "_DeviceInfoProxyControl($superString)"; |
| 302 } | 301 } |
| 303 } | 302 } |
| 304 | 303 |
| 305 | 304 |
| 306 class _DeviceInfoProxyCalls implements DeviceInfo { | 305 class DeviceInfoProxy extends bindings.Proxy |
| 307 _DeviceInfoProxyImpl _proxyImpl; | 306 implements DeviceInfo { |
| 307 DeviceInfoProxy.fromEndpoint( |
| 308 core.MojoMessagePipeEndpoint endpoint) |
| 309 : super(new _DeviceInfoProxyControl.fromEndpoint(endpoint)); |
| 308 | 310 |
| 309 _DeviceInfoProxyCalls(this._proxyImpl); | 311 DeviceInfoProxy.fromHandle(core.MojoHandle handle) |
| 310 dynamic getDeviceType([Function responseFactory = null]) { | 312 : super(new _DeviceInfoProxyControl.fromHandle(handle)); |
| 311 var params = new _DeviceInfoGetDeviceTypeParams(); | |
| 312 return _proxyImpl.sendMessageWithRequestId( | |
| 313 params, | |
| 314 _deviceInfoMethodGetDeviceTypeName, | |
| 315 -1, | |
| 316 bindings.MessageHeader.kMessageExpectsResponse); | |
| 317 } | |
| 318 } | |
| 319 | 313 |
| 314 DeviceInfoProxy.unbound() |
| 315 : super(new _DeviceInfoProxyControl.unbound()); |
| 320 | 316 |
| 321 class DeviceInfoProxy implements bindings.ProxyBase { | 317 static DeviceInfoProxy newFromEndpoint( |
| 322 final bindings.Proxy impl; | 318 core.MojoMessagePipeEndpoint endpoint) { |
| 323 DeviceInfo ptr; | 319 assert(endpoint.setDescription("For DeviceInfoProxy")); |
| 324 | 320 return new DeviceInfoProxy.fromEndpoint(endpoint); |
| 325 DeviceInfoProxy(_DeviceInfoProxyImpl proxyImpl) : | |
| 326 impl = proxyImpl, | |
| 327 ptr = new _DeviceInfoProxyCalls(proxyImpl); | |
| 328 | |
| 329 DeviceInfoProxy.fromEndpoint( | |
| 330 core.MojoMessagePipeEndpoint endpoint) : | |
| 331 impl = new _DeviceInfoProxyImpl.fromEndpoint(endpoint) { | |
| 332 ptr = new _DeviceInfoProxyCalls(impl); | |
| 333 } | |
| 334 | |
| 335 DeviceInfoProxy.fromHandle(core.MojoHandle handle) : | |
| 336 impl = new _DeviceInfoProxyImpl.fromHandle(handle) { | |
| 337 ptr = new _DeviceInfoProxyCalls(impl); | |
| 338 } | |
| 339 | |
| 340 DeviceInfoProxy.unbound() : | |
| 341 impl = new _DeviceInfoProxyImpl.unbound() { | |
| 342 ptr = new _DeviceInfoProxyCalls(impl); | |
| 343 } | 321 } |
| 344 | 322 |
| 345 factory DeviceInfoProxy.connectToService( | 323 factory DeviceInfoProxy.connectToService( |
| 346 bindings.ServiceConnector s, String url, [String serviceName]) { | 324 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 347 DeviceInfoProxy p = new DeviceInfoProxy.unbound(); | 325 DeviceInfoProxy p = new DeviceInfoProxy.unbound(); |
| 348 s.connectToService(url, p, serviceName); | 326 s.connectToService(url, p, serviceName); |
| 349 return p; | 327 return p; |
| 350 } | 328 } |
| 351 | 329 |
| 352 static DeviceInfoProxy newFromEndpoint( | |
| 353 core.MojoMessagePipeEndpoint endpoint) { | |
| 354 assert(endpoint.setDescription("For DeviceInfoProxy")); | |
| 355 return new DeviceInfoProxy.fromEndpoint(endpoint); | |
| 356 } | |
| 357 | 330 |
| 358 String get serviceName => DeviceInfo.serviceName; | 331 dynamic getDeviceType([Function responseFactory = null]) { |
| 359 | 332 var params = new _DeviceInfoGetDeviceTypeParams(); |
| 360 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 333 return ctrl.sendMessageWithRequestId( |
| 361 | 334 params, |
| 362 Future responseOrError(Future f) => impl.responseOrError(f); | 335 _deviceInfoMethodGetDeviceTypeName, |
| 363 | 336 -1, |
| 364 Future get errorFuture => impl.errorFuture; | 337 bindings.MessageHeader.kMessageExpectsResponse); |
| 365 | |
| 366 int get version => impl.version; | |
| 367 | |
| 368 Future<int> queryVersion() => impl.queryVersion(); | |
| 369 | |
| 370 void requireVersion(int requiredVersion) { | |
| 371 impl.requireVersion(requiredVersion); | |
| 372 } | |
| 373 | |
| 374 String toString() { | |
| 375 return "DeviceInfoProxy($impl)"; | |
| 376 } | 338 } |
| 377 } | 339 } |
| 378 | 340 |
| 379 | 341 |
| 380 class DeviceInfoStub extends bindings.Stub { | 342 class DeviceInfoStub extends bindings.Stub { |
| 381 DeviceInfo _impl; | 343 DeviceInfo _impl; |
| 382 | 344 |
| 383 DeviceInfoStub.fromEndpoint( | 345 DeviceInfoStub.fromEndpoint( |
| 384 core.MojoMessagePipeEndpoint endpoint, [DeviceInfo impl]) | 346 core.MojoMessagePipeEndpoint endpoint, [DeviceInfo impl]) |
| 385 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 347 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 static service_describer.ServiceDescription get serviceDescription { | 436 static service_describer.ServiceDescription get serviceDescription { |
| 475 if (_cachedServiceDescription == null) { | 437 if (_cachedServiceDescription == null) { |
| 476 _cachedServiceDescription = new _DeviceInfoServiceDescription(); | 438 _cachedServiceDescription = new _DeviceInfoServiceDescription(); |
| 477 } | 439 } |
| 478 return _cachedServiceDescription; | 440 return _cachedServiceDescription; |
| 479 } | 441 } |
| 480 } | 442 } |
| 481 | 443 |
| 482 | 444 |
| 483 | 445 |
| OLD | NEW |