| 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 vsync_mojom; | 5 library vsync_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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 impl.requireVersion(requiredVersion); | 280 impl.requireVersion(requiredVersion); |
| 281 } | 281 } |
| 282 | 282 |
| 283 String toString() { | 283 String toString() { |
| 284 return "VSyncProviderProxy($impl)"; | 284 return "VSyncProviderProxy($impl)"; |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 class VSyncProviderStub extends bindings.Stub { | 289 class VSyncProviderStub extends bindings.Stub { |
| 290 VSyncProvider _impl = null; | 290 VSyncProvider _impl; |
| 291 | 291 |
| 292 VSyncProviderStub.fromEndpoint( | 292 VSyncProviderStub.fromEndpoint( |
| 293 core.MojoMessagePipeEndpoint endpoint, [this._impl]) | 293 core.MojoMessagePipeEndpoint endpoint, [VSyncProvider impl]) |
| 294 : super.fromEndpoint(endpoint); | 294 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 295 _impl = impl; |
| 296 } |
| 295 | 297 |
| 296 VSyncProviderStub.fromHandle(core.MojoHandle handle, [this._impl]) | 298 VSyncProviderStub.fromHandle( |
| 297 : super.fromHandle(handle); | 299 core.MojoHandle handle, [VSyncProvider impl]) |
| 300 : super.fromHandle(handle, autoBegin: impl != null) { |
| 301 _impl = impl; |
| 302 } |
| 298 | 303 |
| 299 VSyncProviderStub.unbound() : super.unbound(); | 304 VSyncProviderStub.unbound() : super.unbound(); |
| 300 | 305 |
| 301 static VSyncProviderStub newFromEndpoint( | 306 static VSyncProviderStub newFromEndpoint( |
| 302 core.MojoMessagePipeEndpoint endpoint) { | 307 core.MojoMessagePipeEndpoint endpoint) { |
| 303 assert(endpoint.setDescription("For VSyncProviderStub")); | 308 assert(endpoint.setDescription("For VSyncProviderStub")); |
| 304 return new VSyncProviderStub.fromEndpoint(endpoint); | 309 return new VSyncProviderStub.fromEndpoint(endpoint); |
| 305 } | 310 } |
| 306 | 311 |
| 307 | 312 |
| 308 VSyncProviderAwaitVSyncResponseParams _vSyncProviderAwaitVSyncResponseParamsFa
ctory(int timeStamp) { | 313 VSyncProviderAwaitVSyncResponseParams _vSyncProviderAwaitVSyncResponseParamsFa
ctory(int timeStamp) { |
| 309 var result = new VSyncProviderAwaitVSyncResponseParams(); | 314 var result = new VSyncProviderAwaitVSyncResponseParams(); |
| 310 result.timeStamp = timeStamp; | 315 result.timeStamp = timeStamp; |
| 311 return result; | 316 return result; |
| 312 } | 317 } |
| 313 | 318 |
| 314 dynamic handleMessage(bindings.ServiceMessage message) { | 319 dynamic handleMessage(bindings.ServiceMessage message) { |
| 315 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 320 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 316 return bindings.ControlMessageHandler.handleMessage(this, | 321 return bindings.ControlMessageHandler.handleMessage(this, |
| 317 0, | 322 0, |
| 318 message); | 323 message); |
| 319 } | 324 } |
| 320 assert(_impl != null); | 325 if (_impl == null) { |
| 326 throw new core.MojoApiError("$this has no implementation set"); |
| 327 } |
| 321 switch (message.header.type) { | 328 switch (message.header.type) { |
| 322 case _vSyncProviderMethodAwaitVSyncName: | 329 case _vSyncProviderMethodAwaitVSyncName: |
| 323 var response = _impl.awaitVSync(_vSyncProviderAwaitVSyncResponseParamsFa
ctory); | 330 var response = _impl.awaitVSync(_vSyncProviderAwaitVSyncResponseParamsFa
ctory); |
| 324 if (response is Future) { | 331 if (response is Future) { |
| 325 return response.then((response) { | 332 return response.then((response) { |
| 326 if (response != null) { | 333 if (response != null) { |
| 327 return buildResponseWithId( | 334 return buildResponseWithId( |
| 328 response, | 335 response, |
| 329 _vSyncProviderMethodAwaitVSyncName, | 336 _vSyncProviderMethodAwaitVSyncName, |
| 330 message.header.requestId, | 337 message.header.requestId, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 341 break; | 348 break; |
| 342 default: | 349 default: |
| 343 throw new bindings.MojoCodecError("Unexpected message name"); | 350 throw new bindings.MojoCodecError("Unexpected message name"); |
| 344 break; | 351 break; |
| 345 } | 352 } |
| 346 return null; | 353 return null; |
| 347 } | 354 } |
| 348 | 355 |
| 349 VSyncProvider get impl => _impl; | 356 VSyncProvider get impl => _impl; |
| 350 set impl(VSyncProvider d) { | 357 set impl(VSyncProvider d) { |
| 351 assert(_impl == null); | 358 if (d == null) { |
| 359 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
| 360 } |
| 361 if (isBound && (_impl == null)) { |
| 362 beginHandlingEvents(); |
| 363 } |
| 352 _impl = d; | 364 _impl = d; |
| 353 } | 365 } |
| 354 | 366 |
| 367 @override |
| 368 void bind(core.MojoMessagePipeEndpoint endpoint) { |
| 369 super.bind(endpoint); |
| 370 if (!isOpen && (_impl != null)) { |
| 371 beginHandlingEvents(); |
| 372 } |
| 373 } |
| 374 |
| 355 String toString() { | 375 String toString() { |
| 356 var superString = super.toString(); | 376 var superString = super.toString(); |
| 357 return "VSyncProviderStub($superString)"; | 377 return "VSyncProviderStub($superString)"; |
| 358 } | 378 } |
| 359 | 379 |
| 360 int get version => 0; | 380 int get version => 0; |
| 361 | 381 |
| 362 static service_describer.ServiceDescription _cachedServiceDescription; | 382 static service_describer.ServiceDescription _cachedServiceDescription; |
| 363 static service_describer.ServiceDescription get serviceDescription { | 383 static service_describer.ServiceDescription get serviceDescription { |
| 364 if (_cachedServiceDescription == null) { | 384 if (_cachedServiceDescription == null) { |
| 365 _cachedServiceDescription = new _VSyncProviderServiceDescription(); | 385 _cachedServiceDescription = new _VSyncProviderServiceDescription(); |
| 366 } | 386 } |
| 367 return _cachedServiceDescription; | 387 return _cachedServiceDescription; |
| 368 } | 388 } |
| 369 } | 389 } |
| 370 | 390 |
| 371 | 391 |
| 372 | 392 |
| OLD | NEW |