Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: mojo/dart/packages/mojo_services/lib/vsync/vsync.mojom.dart

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // WARNING: DO NOT EDIT. This file was generated by a program. 1 // WARNING: DO NOT EDIT. This file was generated by a program.
2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py. 2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py.
3 3
4 library vsync_mojom; 4 library vsync_mojom;
5 import 'dart:async'; 5 import 'dart:async';
6 import 'package:mojo/bindings.dart' as bindings; 6 import 'package:mojo/bindings.dart' as bindings;
7 import 'package:mojo/core.dart' as core; 7 import 'package:mojo/core.dart' as core;
8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer; 8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
9 9
10 10
11 11
12 class _VSyncProviderAwaitVSyncParams extends bindings.Struct { 12 class _VSyncProviderAwaitVSyncParams extends bindings.Struct {
13 static const List<bindings.StructDataHeader> kVersions = const [ 13 static const List<bindings.StructDataHeader> kVersions = const [
14 const bindings.StructDataHeader(8, 0) 14 const bindings.StructDataHeader(8, 0)
15 ]; 15 ];
16 16
17 _VSyncProviderAwaitVSyncParams() : super(kVersions.last.size); 17 _VSyncProviderAwaitVSyncParams() : super(kVersions.last.size);
18 18
19 _VSyncProviderAwaitVSyncParams.init(
20 ) : super(kVersions.last.size);
21
19 static _VSyncProviderAwaitVSyncParams deserialize(bindings.Message message) { 22 static _VSyncProviderAwaitVSyncParams deserialize(bindings.Message message) {
20 var decoder = new bindings.Decoder(message); 23 var decoder = new bindings.Decoder(message);
21 var result = decode(decoder); 24 var result = decode(decoder);
22 if (decoder.excessHandles != null) { 25 if (decoder.excessHandles != null) {
23 decoder.excessHandles.forEach((h) => h.close()); 26 decoder.excessHandles.forEach((h) => h.close());
24 } 27 }
25 return result; 28 return result;
26 } 29 }
27 30
28 static _VSyncProviderAwaitVSyncParams decode(bindings.Decoder decoder0) { 31 static _VSyncProviderAwaitVSyncParams decode(bindings.Decoder decoder0) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 71
69 72
70 class VSyncProviderAwaitVSyncResponseParams extends bindings.Struct { 73 class VSyncProviderAwaitVSyncResponseParams extends bindings.Struct {
71 static const List<bindings.StructDataHeader> kVersions = const [ 74 static const List<bindings.StructDataHeader> kVersions = const [
72 const bindings.StructDataHeader(16, 0) 75 const bindings.StructDataHeader(16, 0)
73 ]; 76 ];
74 int timeStamp = 0; 77 int timeStamp = 0;
75 78
76 VSyncProviderAwaitVSyncResponseParams() : super(kVersions.last.size); 79 VSyncProviderAwaitVSyncResponseParams() : super(kVersions.last.size);
77 80
81 VSyncProviderAwaitVSyncResponseParams.init(
82 int this.timeStamp
83 ) : super(kVersions.last.size);
84
78 static VSyncProviderAwaitVSyncResponseParams deserialize(bindings.Message mess age) { 85 static VSyncProviderAwaitVSyncResponseParams deserialize(bindings.Message mess age) {
79 var decoder = new bindings.Decoder(message); 86 var decoder = new bindings.Decoder(message);
80 var result = decode(decoder); 87 var result = decode(decoder);
81 if (decoder.excessHandles != null) { 88 if (decoder.excessHandles != null) {
82 decoder.excessHandles.forEach((h) => h.close()); 89 decoder.excessHandles.forEach((h) => h.close());
83 } 90 }
84 return result; 91 return result;
85 } 92 }
86 93
87 static VSyncProviderAwaitVSyncResponseParams decode(bindings.Decoder decoder0) { 94 static VSyncProviderAwaitVSyncResponseParams decode(bindings.Decoder decoder0) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 Map toJson() { 141 Map toJson() {
135 Map map = new Map(); 142 Map map = new Map();
136 map["timeStamp"] = timeStamp; 143 map["timeStamp"] = timeStamp;
137 return map; 144 return map;
138 } 145 }
139 } 146 }
140 147
141 const int _vSyncProviderMethodAwaitVSyncName = 0; 148 const int _vSyncProviderMethodAwaitVSyncName = 0;
142 149
143 class _VSyncProviderServiceDescription implements service_describer.ServiceDescr iption { 150 class _VSyncProviderServiceDescription implements service_describer.ServiceDescr iption {
144 dynamic getTopLevelInterface([Function responseFactory]) => 151 void getTopLevelInterface(Function responder) {
145 responseFactory(null); 152 responder(null);
153 }
146 154
147 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 155 void getTypeDefinition(String typeKey, Function responder) {
148 responseFactory(null); 156 responder(null);
157 }
149 158
150 dynamic getAllTypeDefinitions([Function responseFactory]) => 159 void getAllTypeDefinitions(Function responder) {
151 responseFactory(null); 160 responder(null);
161 }
152 } 162 }
153 163
154 abstract class VSyncProvider { 164 abstract class VSyncProvider {
155 static const String serviceName = "vsync::VSyncProvider"; 165 static const String serviceName = "vsync::VSyncProvider";
156 166
157 static service_describer.ServiceDescription _cachedServiceDescription; 167 static service_describer.ServiceDescription _cachedServiceDescription;
158 static service_describer.ServiceDescription get serviceDescription { 168 static service_describer.ServiceDescription get serviceDescription {
159 if (_cachedServiceDescription == null) { 169 if (_cachedServiceDescription == null) {
160 _cachedServiceDescription = new _VSyncProviderServiceDescription(); 170 _cachedServiceDescription = new _VSyncProviderServiceDescription();
161 } 171 }
162 return _cachedServiceDescription; 172 return _cachedServiceDescription;
163 } 173 }
164 174
165 static VSyncProviderProxy connectToService( 175 static VSyncProviderProxy connectToService(
166 bindings.ServiceConnector s, String url, [String serviceName]) { 176 bindings.ServiceConnector s, String url, [String serviceName]) {
167 VSyncProviderProxy p = new VSyncProviderProxy.unbound(); 177 VSyncProviderProxy p = new VSyncProviderProxy.unbound();
168 String name = serviceName ?? VSyncProvider.serviceName; 178 String name = serviceName ?? VSyncProvider.serviceName;
169 if ((name == null) || name.isEmpty) { 179 if ((name == null) || name.isEmpty) {
170 throw new core.MojoApiError( 180 throw new core.MojoApiError(
171 "If an interface has no ServiceName, then one must be provided."); 181 "If an interface has no ServiceName, then one must be provided.");
172 } 182 }
173 s.connectToService(url, p, name); 183 s.connectToService(url, p, name);
174 return p; 184 return p;
175 } 185 }
176 dynamic awaitVSync([Function responseFactory = null]); 186 void awaitVSync(void callback(int timeStamp));
177 } 187 }
178 188
179 abstract class VSyncProviderInterface 189 abstract class VSyncProviderInterface
180 implements bindings.MojoInterface<VSyncProvider>, 190 implements bindings.MojoInterface<VSyncProvider>,
181 VSyncProvider { 191 VSyncProvider {
182 factory VSyncProviderInterface([VSyncProvider impl]) => 192 factory VSyncProviderInterface([VSyncProvider impl]) =>
183 new VSyncProviderStub.unbound(impl); 193 new VSyncProviderStub.unbound(impl);
184 194
185 factory VSyncProviderInterface.fromEndpoint( 195 factory VSyncProviderInterface.fromEndpoint(
186 core.MojoMessagePipeEndpoint endpoint, 196 core.MojoMessagePipeEndpoint endpoint,
(...skipping 29 matching lines...) Expand all
216 226
217 void handleResponse(bindings.ServiceMessage message) { 227 void handleResponse(bindings.ServiceMessage message) {
218 switch (message.header.type) { 228 switch (message.header.type) {
219 case _vSyncProviderMethodAwaitVSyncName: 229 case _vSyncProviderMethodAwaitVSyncName:
220 var r = VSyncProviderAwaitVSyncResponseParams.deserialize( 230 var r = VSyncProviderAwaitVSyncResponseParams.deserialize(
221 message.payload); 231 message.payload);
222 if (!message.header.hasRequestId) { 232 if (!message.header.hasRequestId) {
223 proxyError("Expected a message with a valid request Id."); 233 proxyError("Expected a message with a valid request Id.");
224 return; 234 return;
225 } 235 }
226 Completer c = completerMap[message.header.requestId]; 236 Function callback = callbackMap[message.header.requestId];
227 if (c == null) { 237 if (callback == null) {
228 proxyError( 238 proxyError(
229 "Message had unknown request Id: ${message.header.requestId}"); 239 "Message had unknown request Id: ${message.header.requestId}");
230 return; 240 return;
231 } 241 }
232 completerMap.remove(message.header.requestId); 242 callbackMap.remove(message.header.requestId);
233 if (c.isCompleted) { 243 callback(r.timeStamp );
234 proxyError("Response completer already completed");
235 return;
236 }
237 c.complete(r);
238 break; 244 break;
239 default: 245 default:
240 proxyError("Unexpected message type: ${message.header.type}"); 246 proxyError("Unexpected message type: ${message.header.type}");
241 close(immediate: true); 247 close(immediate: true);
242 break; 248 break;
243 } 249 }
244 } 250 }
245 251
246 @override 252 @override
247 String toString() { 253 String toString() {
(...skipping 24 matching lines...) Expand all
272 return newMockedProxy; 278 return newMockedProxy;
273 } 279 }
274 280
275 static VSyncProviderProxy newFromEndpoint( 281 static VSyncProviderProxy newFromEndpoint(
276 core.MojoMessagePipeEndpoint endpoint) { 282 core.MojoMessagePipeEndpoint endpoint) {
277 assert(endpoint.setDescription("For VSyncProviderProxy")); 283 assert(endpoint.setDescription("For VSyncProviderProxy"));
278 return new VSyncProviderProxy.fromEndpoint(endpoint); 284 return new VSyncProviderProxy.fromEndpoint(endpoint);
279 } 285 }
280 286
281 287
282 dynamic awaitVSync([Function responseFactory = null]) { 288 void awaitVSync(void callback(int timeStamp)) {
283 if (impl != null) { 289 if (impl != null) {
284 return new Future(() => impl.awaitVSync(_VSyncProviderStubControl._vSyncPr oviderAwaitVSyncResponseParamsFactory)); 290 impl.awaitVSync(callback);
291 return;
285 } 292 }
286 var params = new _VSyncProviderAwaitVSyncParams(); 293 var params = new _VSyncProviderAwaitVSyncParams();
287 return ctrl.sendMessageWithRequestId( 294 ctrl.sendMessageWithRequestId(
288 params, 295 params,
289 _vSyncProviderMethodAwaitVSyncName, 296 _vSyncProviderMethodAwaitVSyncName,
290 -1, 297 -1,
291 bindings.MessageHeader.kMessageExpectsResponse); 298 bindings.MessageHeader.kMessageExpectsResponse,
299 callback);
292 } 300 }
293 } 301 }
294 302
295 class _VSyncProviderStubControl 303 class _VSyncProviderStubControl
296 extends bindings.StubMessageHandler 304 extends bindings.StubMessageHandler
297 implements bindings.StubControl<VSyncProvider> { 305 implements bindings.StubControl<VSyncProvider> {
298 VSyncProvider _impl; 306 VSyncProvider _impl;
299 307
300 _VSyncProviderStubControl.fromEndpoint( 308 _VSyncProviderStubControl.fromEndpoint(
301 core.MojoMessagePipeEndpoint endpoint, [VSyncProvider impl]) 309 core.MojoMessagePipeEndpoint endpoint, [VSyncProvider impl])
302 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 310 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
303 _impl = impl; 311 _impl = impl;
304 } 312 }
305 313
306 _VSyncProviderStubControl.fromHandle( 314 _VSyncProviderStubControl.fromHandle(
307 core.MojoHandle handle, [VSyncProvider impl]) 315 core.MojoHandle handle, [VSyncProvider impl])
308 : super.fromHandle(handle, autoBegin: impl != null) { 316 : super.fromHandle(handle, autoBegin: impl != null) {
309 _impl = impl; 317 _impl = impl;
310 } 318 }
311 319
312 _VSyncProviderStubControl.unbound([this._impl]) : super.unbound(); 320 _VSyncProviderStubControl.unbound([this._impl]) : super.unbound();
313 321
314 String get serviceName => VSyncProvider.serviceName; 322 String get serviceName => VSyncProvider.serviceName;
315 323
316 324
317 static VSyncProviderAwaitVSyncResponseParams _vSyncProviderAwaitVSyncResponseP aramsFactory(int timeStamp) { 325 Function _vSyncProviderAwaitVSyncResponseParamsResponder(
318 var result = new VSyncProviderAwaitVSyncResponseParams(); 326 int requestId) {
319 result.timeStamp = timeStamp; 327 return (int timeStamp) {
320 return result; 328 var result = new VSyncProviderAwaitVSyncResponseParams();
329 result.timeStamp = timeStamp;
330 sendResponse(buildResponseWithId(
331 result,
332 _vSyncProviderMethodAwaitVSyncName,
333 requestId,
334 bindings.MessageHeader.kMessageIsResponse));
335 };
321 } 336 }
322 337
323 dynamic handleMessage(bindings.ServiceMessage message) { 338 void handleMessage(bindings.ServiceMessage message) {
324 if (bindings.ControlMessageHandler.isControlMessage(message)) { 339 if (bindings.ControlMessageHandler.isControlMessage(message)) {
325 return bindings.ControlMessageHandler.handleMessage(this, 340 bindings.ControlMessageHandler.handleMessage(
326 0, 341 this, 0, message);
327 message); 342 return;
328 } 343 }
329 if (_impl == null) { 344 if (_impl == null) {
330 throw new core.MojoApiError("$this has no implementation set"); 345 throw new core.MojoApiError("$this has no implementation set");
331 } 346 }
332 switch (message.header.type) { 347 switch (message.header.type) {
333 case _vSyncProviderMethodAwaitVSyncName: 348 case _vSyncProviderMethodAwaitVSyncName:
334 var response = _impl.awaitVSync(_vSyncProviderAwaitVSyncResponseParamsFa ctory); 349 _impl.awaitVSync(_vSyncProviderAwaitVSyncResponseParamsResponder(message .header.requestId));
335 if (response is Future) {
336 return response.then((response) {
337 if (response != null) {
338 return buildResponseWithId(
339 response,
340 _vSyncProviderMethodAwaitVSyncName,
341 message.header.requestId,
342 bindings.MessageHeader.kMessageIsResponse);
343 }
344 });
345 } else if (response != null) {
346 return buildResponseWithId(
347 response,
348 _vSyncProviderMethodAwaitVSyncName,
349 message.header.requestId,
350 bindings.MessageHeader.kMessageIsResponse);
351 }
352 break; 350 break;
353 default: 351 default:
354 throw new bindings.MojoCodecError("Unexpected message name"); 352 throw new bindings.MojoCodecError("Unexpected message name");
355 break; 353 break;
356 } 354 }
357 return null;
358 } 355 }
359 356
360 VSyncProvider get impl => _impl; 357 VSyncProvider get impl => _impl;
361 set impl(VSyncProvider d) { 358 set impl(VSyncProvider d) {
362 if (d == null) { 359 if (d == null) {
363 throw new core.MojoApiError("$this: Cannot set a null implementation"); 360 throw new core.MojoApiError("$this: Cannot set a null implementation");
364 } 361 }
365 if (isBound && (_impl == null)) { 362 if (isBound && (_impl == null)) {
366 beginHandlingEvents(); 363 beginHandlingEvents();
367 } 364 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 core.MojoHandle handle, [VSyncProvider impl]) 398 core.MojoHandle handle, [VSyncProvider impl])
402 : super(new _VSyncProviderStubControl.fromHandle(handle, impl)); 399 : super(new _VSyncProviderStubControl.fromHandle(handle, impl));
403 400
404 static VSyncProviderStub newFromEndpoint( 401 static VSyncProviderStub newFromEndpoint(
405 core.MojoMessagePipeEndpoint endpoint) { 402 core.MojoMessagePipeEndpoint endpoint) {
406 assert(endpoint.setDescription("For VSyncProviderStub")); 403 assert(endpoint.setDescription("For VSyncProviderStub"));
407 return new VSyncProviderStub.fromEndpoint(endpoint); 404 return new VSyncProviderStub.fromEndpoint(endpoint);
408 } 405 }
409 406
410 407
411 dynamic awaitVSync([Function responseFactory = null]) { 408 void awaitVSync(void callback(int timeStamp)) {
412 return impl.awaitVSync(responseFactory); 409 return impl.awaitVSync(callback);
413 } 410 }
414 } 411 }
415 412
416 413
417 414
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698