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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 148 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
149 responseFactory(null); | 149 responseFactory(null); |
150 | 150 |
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 |
| 158 static service_describer.ServiceDescription _cachedServiceDescription; |
| 159 static service_describer.ServiceDescription get serviceDescription { |
| 160 if (_cachedServiceDescription == null) { |
| 161 _cachedServiceDescription = new _VSyncProviderServiceDescription(); |
| 162 } |
| 163 return _cachedServiceDescription; |
| 164 } |
| 165 |
| 166 static VSyncProviderProxy connectToService( |
| 167 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 168 VSyncProviderProxy p = new VSyncProviderProxy.unbound(); |
| 169 String name = serviceName ?? VSyncProvider.serviceName; |
| 170 if ((name == null) || name.isEmpty) { |
| 171 throw new core.MojoApiError( |
| 172 "If an interface has no ServiceName, then one must be provided."); |
| 173 } |
| 174 s.connectToService(url, p, name); |
| 175 return p; |
| 176 } |
157 dynamic awaitVSync([Function responseFactory = null]); | 177 dynamic awaitVSync([Function responseFactory = null]); |
158 } | 178 } |
159 | 179 |
| 180 abstract class VSyncProviderInterface |
| 181 implements bindings.MojoInterface<VSyncProvider>, |
| 182 VSyncProvider { |
| 183 factory VSyncProviderInterface([VSyncProvider impl]) => |
| 184 new VSyncProviderStub.unbound(impl); |
| 185 factory VSyncProviderInterface.fromEndpoint( |
| 186 core.MojoMessagePipeEndpoint endpoint, |
| 187 [VSyncProvider impl]) => |
| 188 new VSyncProviderStub.fromEndpoint(endpoint, impl); |
| 189 } |
| 190 |
| 191 abstract class VSyncProviderInterfaceRequest |
| 192 implements bindings.MojoInterface<VSyncProvider>, |
| 193 VSyncProvider { |
| 194 factory VSyncProviderInterfaceRequest() => |
| 195 new VSyncProviderProxy.unbound(); |
| 196 } |
| 197 |
160 class _VSyncProviderProxyControl | 198 class _VSyncProviderProxyControl |
161 extends bindings.ProxyMessageHandler | 199 extends bindings.ProxyMessageHandler |
162 implements bindings.ProxyControl { | 200 implements bindings.ProxyControl<VSyncProvider> { |
163 _VSyncProviderProxyControl.fromEndpoint( | 201 _VSyncProviderProxyControl.fromEndpoint( |
164 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 202 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
165 | 203 |
166 _VSyncProviderProxyControl.fromHandle( | 204 _VSyncProviderProxyControl.fromHandle( |
167 core.MojoHandle handle) : super.fromHandle(handle); | 205 core.MojoHandle handle) : super.fromHandle(handle); |
168 | 206 |
169 _VSyncProviderProxyControl.unbound() : super.unbound(); | 207 _VSyncProviderProxyControl.unbound() : super.unbound(); |
170 | 208 |
171 service_describer.ServiceDescription get serviceDescription => | |
172 new _VSyncProviderServiceDescription(); | |
173 | |
174 String get serviceName => VSyncProvider.serviceName; | 209 String get serviceName => VSyncProvider.serviceName; |
175 | 210 |
176 void handleResponse(bindings.ServiceMessage message) { | 211 void handleResponse(bindings.ServiceMessage message) { |
177 switch (message.header.type) { | 212 switch (message.header.type) { |
178 case _vSyncProviderMethodAwaitVSyncName: | 213 case _vSyncProviderMethodAwaitVSyncName: |
179 var r = VSyncProviderAwaitVSyncResponseParams.deserialize( | 214 var r = VSyncProviderAwaitVSyncResponseParams.deserialize( |
180 message.payload); | 215 message.payload); |
181 if (!message.header.hasRequestId) { | 216 if (!message.header.hasRequestId) { |
182 proxyError("Expected a message with a valid request Id."); | 217 proxyError("Expected a message with a valid request Id."); |
183 return; | 218 return; |
(...skipping 11 matching lines...) Expand all Loading... |
195 } | 230 } |
196 c.complete(r); | 231 c.complete(r); |
197 break; | 232 break; |
198 default: | 233 default: |
199 proxyError("Unexpected message type: ${message.header.type}"); | 234 proxyError("Unexpected message type: ${message.header.type}"); |
200 close(immediate: true); | 235 close(immediate: true); |
201 break; | 236 break; |
202 } | 237 } |
203 } | 238 } |
204 | 239 |
| 240 VSyncProvider get impl => null; |
| 241 set impl(VSyncProvider _) { |
| 242 throw new core.MojoApiError("The impl of a Proxy cannot be set."); |
| 243 } |
| 244 |
205 @override | 245 @override |
206 String toString() { | 246 String toString() { |
207 var superString = super.toString(); | 247 var superString = super.toString(); |
208 return "_VSyncProviderProxyControl($superString)"; | 248 return "_VSyncProviderProxyControl($superString)"; |
209 } | 249 } |
210 } | 250 } |
211 | 251 |
212 class VSyncProviderProxy | 252 class VSyncProviderProxy |
213 extends bindings.Proxy | 253 extends bindings.Proxy<VSyncProvider> |
214 implements VSyncProvider { | 254 implements VSyncProvider, |
| 255 VSyncProviderInterface, |
| 256 VSyncProviderInterfaceRequest { |
215 VSyncProviderProxy.fromEndpoint( | 257 VSyncProviderProxy.fromEndpoint( |
216 core.MojoMessagePipeEndpoint endpoint) | 258 core.MojoMessagePipeEndpoint endpoint) |
217 : super(new _VSyncProviderProxyControl.fromEndpoint(endpoint)); | 259 : super(new _VSyncProviderProxyControl.fromEndpoint(endpoint)); |
218 | 260 |
219 VSyncProviderProxy.fromHandle(core.MojoHandle handle) | 261 VSyncProviderProxy.fromHandle(core.MojoHandle handle) |
220 : super(new _VSyncProviderProxyControl.fromHandle(handle)); | 262 : super(new _VSyncProviderProxyControl.fromHandle(handle)); |
221 | 263 |
222 VSyncProviderProxy.unbound() | 264 VSyncProviderProxy.unbound() |
223 : super(new _VSyncProviderProxyControl.unbound()); | 265 : super(new _VSyncProviderProxyControl.unbound()); |
224 | 266 |
225 static VSyncProviderProxy newFromEndpoint( | 267 static VSyncProviderProxy newFromEndpoint( |
226 core.MojoMessagePipeEndpoint endpoint) { | 268 core.MojoMessagePipeEndpoint endpoint) { |
227 assert(endpoint.setDescription("For VSyncProviderProxy")); | 269 assert(endpoint.setDescription("For VSyncProviderProxy")); |
228 return new VSyncProviderProxy.fromEndpoint(endpoint); | 270 return new VSyncProviderProxy.fromEndpoint(endpoint); |
229 } | 271 } |
230 | 272 |
231 factory VSyncProviderProxy.connectToService( | |
232 bindings.ServiceConnector s, String url, [String serviceName]) { | |
233 VSyncProviderProxy p = new VSyncProviderProxy.unbound(); | |
234 s.connectToService(url, p, serviceName); | |
235 return p; | |
236 } | |
237 | |
238 | 273 |
239 dynamic awaitVSync([Function responseFactory = null]) { | 274 dynamic awaitVSync([Function responseFactory = null]) { |
240 var params = new _VSyncProviderAwaitVSyncParams(); | 275 var params = new _VSyncProviderAwaitVSyncParams(); |
241 return ctrl.sendMessageWithRequestId( | 276 return ctrl.sendMessageWithRequestId( |
242 params, | 277 params, |
243 _vSyncProviderMethodAwaitVSyncName, | 278 _vSyncProviderMethodAwaitVSyncName, |
244 -1, | 279 -1, |
245 bindings.MessageHeader.kMessageExpectsResponse); | 280 bindings.MessageHeader.kMessageExpectsResponse); |
246 } | 281 } |
247 } | 282 } |
(...skipping 10 matching lines...) Expand all Loading... |
258 } | 293 } |
259 | 294 |
260 _VSyncProviderStubControl.fromHandle( | 295 _VSyncProviderStubControl.fromHandle( |
261 core.MojoHandle handle, [VSyncProvider impl]) | 296 core.MojoHandle handle, [VSyncProvider impl]) |
262 : super.fromHandle(handle, autoBegin: impl != null) { | 297 : super.fromHandle(handle, autoBegin: impl != null) { |
263 _impl = impl; | 298 _impl = impl; |
264 } | 299 } |
265 | 300 |
266 _VSyncProviderStubControl.unbound([this._impl]) : super.unbound(); | 301 _VSyncProviderStubControl.unbound([this._impl]) : super.unbound(); |
267 | 302 |
| 303 String get serviceName => VSyncProvider.serviceName; |
| 304 |
268 | 305 |
269 VSyncProviderAwaitVSyncResponseParams _vSyncProviderAwaitVSyncResponseParamsFa
ctory(int timeStamp) { | 306 VSyncProviderAwaitVSyncResponseParams _vSyncProviderAwaitVSyncResponseParamsFa
ctory(int timeStamp) { |
270 var result = new VSyncProviderAwaitVSyncResponseParams(); | 307 var result = new VSyncProviderAwaitVSyncResponseParams(); |
271 result.timeStamp = timeStamp; | 308 result.timeStamp = timeStamp; |
272 return result; | 309 return result; |
273 } | 310 } |
274 | 311 |
275 dynamic handleMessage(bindings.ServiceMessage message) { | 312 dynamic handleMessage(bindings.ServiceMessage message) { |
276 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 313 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
277 return bindings.ControlMessageHandler.handleMessage(this, | 314 return bindings.ControlMessageHandler.handleMessage(this, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 365 } |
329 } | 366 } |
330 | 367 |
331 @override | 368 @override |
332 String toString() { | 369 String toString() { |
333 var superString = super.toString(); | 370 var superString = super.toString(); |
334 return "_VSyncProviderStubControl($superString)"; | 371 return "_VSyncProviderStubControl($superString)"; |
335 } | 372 } |
336 | 373 |
337 int get version => 0; | 374 int get version => 0; |
338 | |
339 static service_describer.ServiceDescription _cachedServiceDescription; | |
340 static service_describer.ServiceDescription get serviceDescription { | |
341 if (_cachedServiceDescription == null) { | |
342 _cachedServiceDescription = new _VSyncProviderServiceDescription(); | |
343 } | |
344 return _cachedServiceDescription; | |
345 } | |
346 } | 375 } |
347 | 376 |
348 class VSyncProviderStub | 377 class VSyncProviderStub |
349 extends bindings.Stub<VSyncProvider> | 378 extends bindings.Stub<VSyncProvider> |
350 implements VSyncProvider { | 379 implements VSyncProvider, |
| 380 VSyncProviderInterface, |
| 381 VSyncProviderInterfaceRequest { |
| 382 VSyncProviderStub.unbound([VSyncProvider impl]) |
| 383 : super(new _VSyncProviderStubControl.unbound(impl)); |
| 384 |
351 VSyncProviderStub.fromEndpoint( | 385 VSyncProviderStub.fromEndpoint( |
352 core.MojoMessagePipeEndpoint endpoint, [VSyncProvider impl]) | 386 core.MojoMessagePipeEndpoint endpoint, [VSyncProvider impl]) |
353 : super(new _VSyncProviderStubControl.fromEndpoint(endpoint, impl)); | 387 : super(new _VSyncProviderStubControl.fromEndpoint(endpoint, impl)); |
354 | 388 |
355 VSyncProviderStub.fromHandle( | 389 VSyncProviderStub.fromHandle( |
356 core.MojoHandle handle, [VSyncProvider impl]) | 390 core.MojoHandle handle, [VSyncProvider impl]) |
357 : super(new _VSyncProviderStubControl.fromHandle(handle, impl)); | 391 : super(new _VSyncProviderStubControl.fromHandle(handle, impl)); |
358 | 392 |
359 VSyncProviderStub.unbound([VSyncProvider impl]) | |
360 : super(new _VSyncProviderStubControl.unbound(impl)); | |
361 | |
362 static VSyncProviderStub newFromEndpoint( | 393 static VSyncProviderStub newFromEndpoint( |
363 core.MojoMessagePipeEndpoint endpoint) { | 394 core.MojoMessagePipeEndpoint endpoint) { |
364 assert(endpoint.setDescription("For VSyncProviderStub")); | 395 assert(endpoint.setDescription("For VSyncProviderStub")); |
365 return new VSyncProviderStub.fromEndpoint(endpoint); | 396 return new VSyncProviderStub.fromEndpoint(endpoint); |
366 } | 397 } |
367 | 398 |
368 static service_describer.ServiceDescription get serviceDescription => | |
369 _VSyncProviderStubControl.serviceDescription; | |
370 | |
371 | 399 |
372 dynamic awaitVSync([Function responseFactory = null]) { | 400 dynamic awaitVSync([Function responseFactory = null]) { |
373 return impl.awaitVSync(responseFactory); | 401 return impl.awaitVSync(responseFactory); |
374 } | 402 } |
375 } | 403 } |
376 | 404 |
377 | 405 |
378 | 406 |
OLD | NEW |