| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 dynamic getAllTypeDefinitions([Function responseFactory]) => | 151 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 152 responseFactory(null); | 152 responseFactory(null); |
| 153 } | 153 } |
| 154 | 154 |
| 155 abstract class VSyncProvider { | 155 abstract class VSyncProvider { |
| 156 static const String serviceName = "vsync::VSyncProvider"; | 156 static const String serviceName = "vsync::VSyncProvider"; |
| 157 dynamic awaitVSync([Function responseFactory = null]); | 157 dynamic awaitVSync([Function responseFactory = null]); |
| 158 } | 158 } |
| 159 | 159 |
| 160 | 160 |
| 161 class _VSyncProviderProxyImpl extends bindings.Proxy { | 161 class _VSyncProviderProxyControl extends bindings.ProxyMessageHandler |
| 162 _VSyncProviderProxyImpl.fromEndpoint( | 162 implements bindings.ProxyControl { |
| 163 _VSyncProviderProxyControl.fromEndpoint( |
| 163 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 164 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 164 | 165 |
| 165 _VSyncProviderProxyImpl.fromHandle(core.MojoHandle handle) : | 166 _VSyncProviderProxyControl.fromHandle( |
| 166 super.fromHandle(handle); | 167 core.MojoHandle handle) : super.fromHandle(handle); |
| 167 | 168 |
| 168 _VSyncProviderProxyImpl.unbound() : super.unbound(); | 169 _VSyncProviderProxyControl.unbound() : super.unbound(); |
| 169 | |
| 170 static _VSyncProviderProxyImpl newFromEndpoint( | |
| 171 core.MojoMessagePipeEndpoint endpoint) { | |
| 172 assert(endpoint.setDescription("For _VSyncProviderProxyImpl")); | |
| 173 return new _VSyncProviderProxyImpl.fromEndpoint(endpoint); | |
| 174 } | |
| 175 | 170 |
| 176 service_describer.ServiceDescription get serviceDescription => | 171 service_describer.ServiceDescription get serviceDescription => |
| 177 new _VSyncProviderServiceDescription(); | 172 new _VSyncProviderServiceDescription(); |
| 178 | 173 |
| 174 String get serviceName => VSyncProvider.serviceName; |
| 175 |
| 176 @override |
| 179 void handleResponse(bindings.ServiceMessage message) { | 177 void handleResponse(bindings.ServiceMessage message) { |
| 180 switch (message.header.type) { | 178 switch (message.header.type) { |
| 181 case _vSyncProviderMethodAwaitVSyncName: | 179 case _vSyncProviderMethodAwaitVSyncName: |
| 182 var r = VSyncProviderAwaitVSyncResponseParams.deserialize( | 180 var r = VSyncProviderAwaitVSyncResponseParams.deserialize( |
| 183 message.payload); | 181 message.payload); |
| 184 if (!message.header.hasRequestId) { | 182 if (!message.header.hasRequestId) { |
| 185 proxyError("Expected a message with a valid request Id."); | 183 proxyError("Expected a message with a valid request Id."); |
| 186 return; | 184 return; |
| 187 } | 185 } |
| 188 Completer c = completerMap[message.header.requestId]; | 186 Completer c = completerMap[message.header.requestId]; |
| 189 if (c == null) { | 187 if (c == null) { |
| 190 proxyError( | 188 proxyError( |
| 191 "Message had unknown request Id: ${message.header.requestId}"); | 189 "Message had unknown request Id: ${message.header.requestId}"); |
| 192 return; | 190 return; |
| 193 } | 191 } |
| 194 completerMap.remove(message.header.requestId); | 192 completerMap.remove(message.header.requestId); |
| 195 if (c.isCompleted) { | 193 if (c.isCompleted) { |
| 196 proxyError("Response completer already completed"); | 194 proxyError("Response completer already completed"); |
| 197 return; | 195 return; |
| 198 } | 196 } |
| 199 c.complete(r); | 197 c.complete(r); |
| 200 break; | 198 break; |
| 201 default: | 199 default: |
| 202 proxyError("Unexpected message type: ${message.header.type}"); | 200 proxyError("Unexpected message type: ${message.header.type}"); |
| 203 close(immediate: true); | 201 close(immediate: true); |
| 204 break; | 202 break; |
| 205 } | 203 } |
| 206 } | 204 } |
| 207 | 205 |
| 206 @override |
| 208 String toString() { | 207 String toString() { |
| 209 var superString = super.toString(); | 208 var superString = super.toString(); |
| 210 return "_VSyncProviderProxyImpl($superString)"; | 209 return "_VSyncProviderProxyControl($superString)"; |
| 211 } | 210 } |
| 212 } | 211 } |
| 213 | 212 |
| 214 | 213 |
| 215 class _VSyncProviderProxyCalls implements VSyncProvider { | 214 class VSyncProviderProxy extends bindings.Proxy |
| 216 _VSyncProviderProxyImpl _proxyImpl; | 215 implements VSyncProvider { |
| 216 VSyncProviderProxy.fromEndpoint( |
| 217 core.MojoMessagePipeEndpoint endpoint) |
| 218 : super(new _VSyncProviderProxyControl.fromEndpoint(endpoint)); |
| 217 | 219 |
| 218 _VSyncProviderProxyCalls(this._proxyImpl); | 220 VSyncProviderProxy.fromHandle(core.MojoHandle handle) |
| 219 dynamic awaitVSync([Function responseFactory = null]) { | 221 : super(new _VSyncProviderProxyControl.fromHandle(handle)); |
| 220 var params = new _VSyncProviderAwaitVSyncParams(); | |
| 221 return _proxyImpl.sendMessageWithRequestId( | |
| 222 params, | |
| 223 _vSyncProviderMethodAwaitVSyncName, | |
| 224 -1, | |
| 225 bindings.MessageHeader.kMessageExpectsResponse); | |
| 226 } | |
| 227 } | |
| 228 | 222 |
| 223 VSyncProviderProxy.unbound() |
| 224 : super(new _VSyncProviderProxyControl.unbound()); |
| 229 | 225 |
| 230 class VSyncProviderProxy implements bindings.ProxyBase { | 226 static VSyncProviderProxy newFromEndpoint( |
| 231 final bindings.Proxy impl; | 227 core.MojoMessagePipeEndpoint endpoint) { |
| 232 VSyncProvider ptr; | 228 assert(endpoint.setDescription("For VSyncProviderProxy")); |
| 233 | 229 return new VSyncProviderProxy.fromEndpoint(endpoint); |
| 234 VSyncProviderProxy(_VSyncProviderProxyImpl proxyImpl) : | |
| 235 impl = proxyImpl, | |
| 236 ptr = new _VSyncProviderProxyCalls(proxyImpl); | |
| 237 | |
| 238 VSyncProviderProxy.fromEndpoint( | |
| 239 core.MojoMessagePipeEndpoint endpoint) : | |
| 240 impl = new _VSyncProviderProxyImpl.fromEndpoint(endpoint) { | |
| 241 ptr = new _VSyncProviderProxyCalls(impl); | |
| 242 } | |
| 243 | |
| 244 VSyncProviderProxy.fromHandle(core.MojoHandle handle) : | |
| 245 impl = new _VSyncProviderProxyImpl.fromHandle(handle) { | |
| 246 ptr = new _VSyncProviderProxyCalls(impl); | |
| 247 } | |
| 248 | |
| 249 VSyncProviderProxy.unbound() : | |
| 250 impl = new _VSyncProviderProxyImpl.unbound() { | |
| 251 ptr = new _VSyncProviderProxyCalls(impl); | |
| 252 } | 230 } |
| 253 | 231 |
| 254 factory VSyncProviderProxy.connectToService( | 232 factory VSyncProviderProxy.connectToService( |
| 255 bindings.ServiceConnector s, String url, [String serviceName]) { | 233 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 256 VSyncProviderProxy p = new VSyncProviderProxy.unbound(); | 234 VSyncProviderProxy p = new VSyncProviderProxy.unbound(); |
| 257 s.connectToService(url, p, serviceName); | 235 s.connectToService(url, p, serviceName); |
| 258 return p; | 236 return p; |
| 259 } | 237 } |
| 260 | 238 |
| 261 static VSyncProviderProxy newFromEndpoint( | |
| 262 core.MojoMessagePipeEndpoint endpoint) { | |
| 263 assert(endpoint.setDescription("For VSyncProviderProxy")); | |
| 264 return new VSyncProviderProxy.fromEndpoint(endpoint); | |
| 265 } | |
| 266 | 239 |
| 267 String get serviceName => VSyncProvider.serviceName; | 240 dynamic awaitVSync([Function responseFactory = null]) { |
| 268 | 241 var params = new _VSyncProviderAwaitVSyncParams(); |
| 269 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 242 return ctrl.sendMessageWithRequestId( |
| 270 | 243 params, |
| 271 Future responseOrError(Future f) => impl.responseOrError(f); | 244 _vSyncProviderMethodAwaitVSyncName, |
| 272 | 245 -1, |
| 273 Future get errorFuture => impl.errorFuture; | 246 bindings.MessageHeader.kMessageExpectsResponse); |
| 274 | |
| 275 int get version => impl.version; | |
| 276 | |
| 277 Future<int> queryVersion() => impl.queryVersion(); | |
| 278 | |
| 279 void requireVersion(int requiredVersion) { | |
| 280 impl.requireVersion(requiredVersion); | |
| 281 } | |
| 282 | |
| 283 String toString() { | |
| 284 return "VSyncProviderProxy($impl)"; | |
| 285 } | 247 } |
| 286 } | 248 } |
| 287 | 249 |
| 288 | 250 |
| 289 class VSyncProviderStub extends bindings.Stub { | 251 class VSyncProviderStub extends bindings.Stub { |
| 290 VSyncProvider _impl; | 252 VSyncProvider _impl; |
| 291 | 253 |
| 292 VSyncProviderStub.fromEndpoint( | 254 VSyncProviderStub.fromEndpoint( |
| 293 core.MojoMessagePipeEndpoint endpoint, [VSyncProvider impl]) | 255 core.MojoMessagePipeEndpoint endpoint, [VSyncProvider impl]) |
| 294 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 256 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 static service_describer.ServiceDescription get serviceDescription { | 345 static service_describer.ServiceDescription get serviceDescription { |
| 384 if (_cachedServiceDescription == null) { | 346 if (_cachedServiceDescription == null) { |
| 385 _cachedServiceDescription = new _VSyncProviderServiceDescription(); | 347 _cachedServiceDescription = new _VSyncProviderServiceDescription(); |
| 386 } | 348 } |
| 387 return _cachedServiceDescription; | 349 return _cachedServiceDescription; |
| 388 } | 350 } |
| 389 } | 351 } |
| 390 | 352 |
| 391 | 353 |
| 392 | 354 |
| OLD | NEW |