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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/mojo/cookie_store.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 cookie_store_mojom; 4 library cookie_store_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 _CookieStoreGetParams extends bindings.Struct { 12 class _CookieStoreGetParams extends bindings.Struct {
13 static const List<bindings.StructDataHeader> kVersions = const [ 13 static const List<bindings.StructDataHeader> kVersions = const [
14 const bindings.StructDataHeader(16, 0) 14 const bindings.StructDataHeader(16, 0)
15 ]; 15 ];
16 String url = null; 16 String url = null;
17 17
18 _CookieStoreGetParams() : super(kVersions.last.size); 18 _CookieStoreGetParams() : super(kVersions.last.size);
19 19
20 _CookieStoreGetParams.init(
21 String this.url
22 ) : super(kVersions.last.size);
23
20 static _CookieStoreGetParams deserialize(bindings.Message message) { 24 static _CookieStoreGetParams deserialize(bindings.Message message) {
21 var decoder = new bindings.Decoder(message); 25 var decoder = new bindings.Decoder(message);
22 var result = decode(decoder); 26 var result = decode(decoder);
23 if (decoder.excessHandles != null) { 27 if (decoder.excessHandles != null) {
24 decoder.excessHandles.forEach((h) => h.close()); 28 decoder.excessHandles.forEach((h) => h.close());
25 } 29 }
26 return result; 30 return result;
27 } 31 }
28 32
29 static _CookieStoreGetParams decode(bindings.Decoder decoder0) { 33 static _CookieStoreGetParams decode(bindings.Decoder decoder0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 86
83 87
84 class CookieStoreGetResponseParams extends bindings.Struct { 88 class CookieStoreGetResponseParams extends bindings.Struct {
85 static const List<bindings.StructDataHeader> kVersions = const [ 89 static const List<bindings.StructDataHeader> kVersions = const [
86 const bindings.StructDataHeader(16, 0) 90 const bindings.StructDataHeader(16, 0)
87 ]; 91 ];
88 String cookies = null; 92 String cookies = null;
89 93
90 CookieStoreGetResponseParams() : super(kVersions.last.size); 94 CookieStoreGetResponseParams() : super(kVersions.last.size);
91 95
96 CookieStoreGetResponseParams.init(
97 String this.cookies
98 ) : super(kVersions.last.size);
99
92 static CookieStoreGetResponseParams deserialize(bindings.Message message) { 100 static CookieStoreGetResponseParams deserialize(bindings.Message message) {
93 var decoder = new bindings.Decoder(message); 101 var decoder = new bindings.Decoder(message);
94 var result = decode(decoder); 102 var result = decode(decoder);
95 if (decoder.excessHandles != null) { 103 if (decoder.excessHandles != null) {
96 decoder.excessHandles.forEach((h) => h.close()); 104 decoder.excessHandles.forEach((h) => h.close());
97 } 105 }
98 return result; 106 return result;
99 } 107 }
100 108
101 static CookieStoreGetResponseParams decode(bindings.Decoder decoder0) { 109 static CookieStoreGetResponseParams decode(bindings.Decoder decoder0) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 163
156 class _CookieStoreSetParams extends bindings.Struct { 164 class _CookieStoreSetParams extends bindings.Struct {
157 static const List<bindings.StructDataHeader> kVersions = const [ 165 static const List<bindings.StructDataHeader> kVersions = const [
158 const bindings.StructDataHeader(24, 0) 166 const bindings.StructDataHeader(24, 0)
159 ]; 167 ];
160 String url = null; 168 String url = null;
161 String cookie = null; 169 String cookie = null;
162 170
163 _CookieStoreSetParams() : super(kVersions.last.size); 171 _CookieStoreSetParams() : super(kVersions.last.size);
164 172
173 _CookieStoreSetParams.init(
174 String this.url,
175 String this.cookie
176 ) : super(kVersions.last.size);
177
165 static _CookieStoreSetParams deserialize(bindings.Message message) { 178 static _CookieStoreSetParams deserialize(bindings.Message message) {
166 var decoder = new bindings.Decoder(message); 179 var decoder = new bindings.Decoder(message);
167 var result = decode(decoder); 180 var result = decode(decoder);
168 if (decoder.excessHandles != null) { 181 if (decoder.excessHandles != null) {
169 decoder.excessHandles.forEach((h) => h.close()); 182 decoder.excessHandles.forEach((h) => h.close());
170 } 183 }
171 return result; 184 return result;
172 } 185 }
173 186
174 static _CookieStoreSetParams decode(bindings.Decoder decoder0) { 187 static _CookieStoreSetParams decode(bindings.Decoder decoder0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 253
241 254
242 class CookieStoreSetResponseParams extends bindings.Struct { 255 class CookieStoreSetResponseParams extends bindings.Struct {
243 static const List<bindings.StructDataHeader> kVersions = const [ 256 static const List<bindings.StructDataHeader> kVersions = const [
244 const bindings.StructDataHeader(16, 0) 257 const bindings.StructDataHeader(16, 0)
245 ]; 258 ];
246 bool success = false; 259 bool success = false;
247 260
248 CookieStoreSetResponseParams() : super(kVersions.last.size); 261 CookieStoreSetResponseParams() : super(kVersions.last.size);
249 262
263 CookieStoreSetResponseParams.init(
264 bool this.success
265 ) : super(kVersions.last.size);
266
250 static CookieStoreSetResponseParams deserialize(bindings.Message message) { 267 static CookieStoreSetResponseParams deserialize(bindings.Message message) {
251 var decoder = new bindings.Decoder(message); 268 var decoder = new bindings.Decoder(message);
252 var result = decode(decoder); 269 var result = decode(decoder);
253 if (decoder.excessHandles != null) { 270 if (decoder.excessHandles != null) {
254 decoder.excessHandles.forEach((h) => h.close()); 271 decoder.excessHandles.forEach((h) => h.close());
255 } 272 }
256 return result; 273 return result;
257 } 274 }
258 275
259 static CookieStoreSetResponseParams decode(bindings.Decoder decoder0) { 276 static CookieStoreSetResponseParams decode(bindings.Decoder decoder0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 Map map = new Map(); 324 Map map = new Map();
308 map["success"] = success; 325 map["success"] = success;
309 return map; 326 return map;
310 } 327 }
311 } 328 }
312 329
313 const int _cookieStoreMethodGetName = 0; 330 const int _cookieStoreMethodGetName = 0;
314 const int _cookieStoreMethodSetName = 1; 331 const int _cookieStoreMethodSetName = 1;
315 332
316 class _CookieStoreServiceDescription implements service_describer.ServiceDescrip tion { 333 class _CookieStoreServiceDescription implements service_describer.ServiceDescrip tion {
317 dynamic getTopLevelInterface([Function responseFactory]) => 334 void getTopLevelInterface(Function responder) {
318 responseFactory(null); 335 responder(null);
336 }
319 337
320 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 338 void getTypeDefinition(String typeKey, Function responder) {
321 responseFactory(null); 339 responder(null);
340 }
322 341
323 dynamic getAllTypeDefinitions([Function responseFactory]) => 342 void getAllTypeDefinitions(Function responder) {
324 responseFactory(null); 343 responder(null);
344 }
325 } 345 }
326 346
327 abstract class CookieStore { 347 abstract class CookieStore {
328 static const String serviceName = null; 348 static const String serviceName = null;
329 349
330 static service_describer.ServiceDescription _cachedServiceDescription; 350 static service_describer.ServiceDescription _cachedServiceDescription;
331 static service_describer.ServiceDescription get serviceDescription { 351 static service_describer.ServiceDescription get serviceDescription {
332 if (_cachedServiceDescription == null) { 352 if (_cachedServiceDescription == null) {
333 _cachedServiceDescription = new _CookieStoreServiceDescription(); 353 _cachedServiceDescription = new _CookieStoreServiceDescription();
334 } 354 }
335 return _cachedServiceDescription; 355 return _cachedServiceDescription;
336 } 356 }
337 357
338 static CookieStoreProxy connectToService( 358 static CookieStoreProxy connectToService(
339 bindings.ServiceConnector s, String url, [String serviceName]) { 359 bindings.ServiceConnector s, String url, [String serviceName]) {
340 CookieStoreProxy p = new CookieStoreProxy.unbound(); 360 CookieStoreProxy p = new CookieStoreProxy.unbound();
341 String name = serviceName ?? CookieStore.serviceName; 361 String name = serviceName ?? CookieStore.serviceName;
342 if ((name == null) || name.isEmpty) { 362 if ((name == null) || name.isEmpty) {
343 throw new core.MojoApiError( 363 throw new core.MojoApiError(
344 "If an interface has no ServiceName, then one must be provided."); 364 "If an interface has no ServiceName, then one must be provided.");
345 } 365 }
346 s.connectToService(url, p, name); 366 s.connectToService(url, p, name);
347 return p; 367 return p;
348 } 368 }
349 dynamic get(String url,[Function responseFactory = null]); 369 void get(String url,void callback(String cookies));
350 dynamic set(String url,String cookie,[Function responseFactory = null]); 370 void set(String url,String cookie,void callback(bool success));
351 } 371 }
352 372
353 abstract class CookieStoreInterface 373 abstract class CookieStoreInterface
354 implements bindings.MojoInterface<CookieStore>, 374 implements bindings.MojoInterface<CookieStore>,
355 CookieStore { 375 CookieStore {
356 factory CookieStoreInterface([CookieStore impl]) => 376 factory CookieStoreInterface([CookieStore impl]) =>
357 new CookieStoreStub.unbound(impl); 377 new CookieStoreStub.unbound(impl);
358 378
359 factory CookieStoreInterface.fromEndpoint( 379 factory CookieStoreInterface.fromEndpoint(
360 core.MojoMessagePipeEndpoint endpoint, 380 core.MojoMessagePipeEndpoint endpoint,
(...skipping 29 matching lines...) Expand all
390 410
391 void handleResponse(bindings.ServiceMessage message) { 411 void handleResponse(bindings.ServiceMessage message) {
392 switch (message.header.type) { 412 switch (message.header.type) {
393 case _cookieStoreMethodGetName: 413 case _cookieStoreMethodGetName:
394 var r = CookieStoreGetResponseParams.deserialize( 414 var r = CookieStoreGetResponseParams.deserialize(
395 message.payload); 415 message.payload);
396 if (!message.header.hasRequestId) { 416 if (!message.header.hasRequestId) {
397 proxyError("Expected a message with a valid request Id."); 417 proxyError("Expected a message with a valid request Id.");
398 return; 418 return;
399 } 419 }
400 Completer c = completerMap[message.header.requestId]; 420 Function callback = callbackMap[message.header.requestId];
401 if (c == null) { 421 if (callback == null) {
402 proxyError( 422 proxyError(
403 "Message had unknown request Id: ${message.header.requestId}"); 423 "Message had unknown request Id: ${message.header.requestId}");
404 return; 424 return;
405 } 425 }
406 completerMap.remove(message.header.requestId); 426 callbackMap.remove(message.header.requestId);
407 if (c.isCompleted) { 427 callback(r.cookies );
408 proxyError("Response completer already completed");
409 return;
410 }
411 c.complete(r);
412 break; 428 break;
413 case _cookieStoreMethodSetName: 429 case _cookieStoreMethodSetName:
414 var r = CookieStoreSetResponseParams.deserialize( 430 var r = CookieStoreSetResponseParams.deserialize(
415 message.payload); 431 message.payload);
416 if (!message.header.hasRequestId) { 432 if (!message.header.hasRequestId) {
417 proxyError("Expected a message with a valid request Id."); 433 proxyError("Expected a message with a valid request Id.");
418 return; 434 return;
419 } 435 }
420 Completer c = completerMap[message.header.requestId]; 436 Function callback = callbackMap[message.header.requestId];
421 if (c == null) { 437 if (callback == null) {
422 proxyError( 438 proxyError(
423 "Message had unknown request Id: ${message.header.requestId}"); 439 "Message had unknown request Id: ${message.header.requestId}");
424 return; 440 return;
425 } 441 }
426 completerMap.remove(message.header.requestId); 442 callbackMap.remove(message.header.requestId);
427 if (c.isCompleted) { 443 callback(r.success );
428 proxyError("Response completer already completed");
429 return;
430 }
431 c.complete(r);
432 break; 444 break;
433 default: 445 default:
434 proxyError("Unexpected message type: ${message.header.type}"); 446 proxyError("Unexpected message type: ${message.header.type}");
435 close(immediate: true); 447 close(immediate: true);
436 break; 448 break;
437 } 449 }
438 } 450 }
439 451
440 @override 452 @override
441 String toString() { 453 String toString() {
(...skipping 24 matching lines...) Expand all
466 return newMockedProxy; 478 return newMockedProxy;
467 } 479 }
468 480
469 static CookieStoreProxy newFromEndpoint( 481 static CookieStoreProxy newFromEndpoint(
470 core.MojoMessagePipeEndpoint endpoint) { 482 core.MojoMessagePipeEndpoint endpoint) {
471 assert(endpoint.setDescription("For CookieStoreProxy")); 483 assert(endpoint.setDescription("For CookieStoreProxy"));
472 return new CookieStoreProxy.fromEndpoint(endpoint); 484 return new CookieStoreProxy.fromEndpoint(endpoint);
473 } 485 }
474 486
475 487
476 dynamic get(String url,[Function responseFactory = null]) { 488 void get(String url,void callback(String cookies)) {
477 if (impl != null) { 489 if (impl != null) {
478 return new Future(() => impl.get(url,_CookieStoreStubControl._cookieStoreG etResponseParamsFactory)); 490 impl.get(url,callback);
491 return;
479 } 492 }
480 var params = new _CookieStoreGetParams(); 493 var params = new _CookieStoreGetParams();
481 params.url = url; 494 params.url = url;
482 return ctrl.sendMessageWithRequestId( 495 ctrl.sendMessageWithRequestId(
483 params, 496 params,
484 _cookieStoreMethodGetName, 497 _cookieStoreMethodGetName,
485 -1, 498 -1,
486 bindings.MessageHeader.kMessageExpectsResponse); 499 bindings.MessageHeader.kMessageExpectsResponse,
500 callback);
487 } 501 }
488 dynamic set(String url,String cookie,[Function responseFactory = null]) { 502 void set(String url,String cookie,void callback(bool success)) {
489 if (impl != null) { 503 if (impl != null) {
490 return new Future(() => impl.set(url,cookie,_CookieStoreStubControl._cooki eStoreSetResponseParamsFactory)); 504 impl.set(url,cookie,callback);
505 return;
491 } 506 }
492 var params = new _CookieStoreSetParams(); 507 var params = new _CookieStoreSetParams();
493 params.url = url; 508 params.url = url;
494 params.cookie = cookie; 509 params.cookie = cookie;
495 return ctrl.sendMessageWithRequestId( 510 ctrl.sendMessageWithRequestId(
496 params, 511 params,
497 _cookieStoreMethodSetName, 512 _cookieStoreMethodSetName,
498 -1, 513 -1,
499 bindings.MessageHeader.kMessageExpectsResponse); 514 bindings.MessageHeader.kMessageExpectsResponse,
515 callback);
500 } 516 }
501 } 517 }
502 518
503 class _CookieStoreStubControl 519 class _CookieStoreStubControl
504 extends bindings.StubMessageHandler 520 extends bindings.StubMessageHandler
505 implements bindings.StubControl<CookieStore> { 521 implements bindings.StubControl<CookieStore> {
506 CookieStore _impl; 522 CookieStore _impl;
507 523
508 _CookieStoreStubControl.fromEndpoint( 524 _CookieStoreStubControl.fromEndpoint(
509 core.MojoMessagePipeEndpoint endpoint, [CookieStore impl]) 525 core.MojoMessagePipeEndpoint endpoint, [CookieStore impl])
510 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 526 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
511 _impl = impl; 527 _impl = impl;
512 } 528 }
513 529
514 _CookieStoreStubControl.fromHandle( 530 _CookieStoreStubControl.fromHandle(
515 core.MojoHandle handle, [CookieStore impl]) 531 core.MojoHandle handle, [CookieStore impl])
516 : super.fromHandle(handle, autoBegin: impl != null) { 532 : super.fromHandle(handle, autoBegin: impl != null) {
517 _impl = impl; 533 _impl = impl;
518 } 534 }
519 535
520 _CookieStoreStubControl.unbound([this._impl]) : super.unbound(); 536 _CookieStoreStubControl.unbound([this._impl]) : super.unbound();
521 537
522 String get serviceName => CookieStore.serviceName; 538 String get serviceName => CookieStore.serviceName;
523 539
524 540
525 static CookieStoreGetResponseParams _cookieStoreGetResponseParamsFactory(Strin g cookies) { 541 Function _cookieStoreGetResponseParamsResponder(
526 var result = new CookieStoreGetResponseParams(); 542 int requestId) {
527 result.cookies = cookies; 543 return (String cookies) {
528 return result; 544 var result = new CookieStoreGetResponseParams();
545 result.cookies = cookies;
546 sendResponse(buildResponseWithId(
547 result,
548 _cookieStoreMethodGetName,
549 requestId,
550 bindings.MessageHeader.kMessageIsResponse));
551 };
529 } 552 }
530 static CookieStoreSetResponseParams _cookieStoreSetResponseParamsFactory(bool success) { 553 Function _cookieStoreSetResponseParamsResponder(
531 var result = new CookieStoreSetResponseParams(); 554 int requestId) {
532 result.success = success; 555 return (bool success) {
533 return result; 556 var result = new CookieStoreSetResponseParams();
557 result.success = success;
558 sendResponse(buildResponseWithId(
559 result,
560 _cookieStoreMethodSetName,
561 requestId,
562 bindings.MessageHeader.kMessageIsResponse));
563 };
534 } 564 }
535 565
536 dynamic handleMessage(bindings.ServiceMessage message) { 566 void handleMessage(bindings.ServiceMessage message) {
537 if (bindings.ControlMessageHandler.isControlMessage(message)) { 567 if (bindings.ControlMessageHandler.isControlMessage(message)) {
538 return bindings.ControlMessageHandler.handleMessage(this, 568 bindings.ControlMessageHandler.handleMessage(
539 0, 569 this, 0, message);
540 message); 570 return;
541 } 571 }
542 if (_impl == null) { 572 if (_impl == null) {
543 throw new core.MojoApiError("$this has no implementation set"); 573 throw new core.MojoApiError("$this has no implementation set");
544 } 574 }
545 switch (message.header.type) { 575 switch (message.header.type) {
546 case _cookieStoreMethodGetName: 576 case _cookieStoreMethodGetName:
547 var params = _CookieStoreGetParams.deserialize( 577 var params = _CookieStoreGetParams.deserialize(
548 message.payload); 578 message.payload);
549 var response = _impl.get(params.url,_cookieStoreGetResponseParamsFactory ); 579 _impl.get(params.url, _cookieStoreGetResponseParamsResponder(message.hea der.requestId));
550 if (response is Future) {
551 return response.then((response) {
552 if (response != null) {
553 return buildResponseWithId(
554 response,
555 _cookieStoreMethodGetName,
556 message.header.requestId,
557 bindings.MessageHeader.kMessageIsResponse);
558 }
559 });
560 } else if (response != null) {
561 return buildResponseWithId(
562 response,
563 _cookieStoreMethodGetName,
564 message.header.requestId,
565 bindings.MessageHeader.kMessageIsResponse);
566 }
567 break; 580 break;
568 case _cookieStoreMethodSetName: 581 case _cookieStoreMethodSetName:
569 var params = _CookieStoreSetParams.deserialize( 582 var params = _CookieStoreSetParams.deserialize(
570 message.payload); 583 message.payload);
571 var response = _impl.set(params.url,params.cookie,_cookieStoreSetRespons eParamsFactory); 584 _impl.set(params.url, params.cookie, _cookieStoreSetResponseParamsRespon der(message.header.requestId));
572 if (response is Future) {
573 return response.then((response) {
574 if (response != null) {
575 return buildResponseWithId(
576 response,
577 _cookieStoreMethodSetName,
578 message.header.requestId,
579 bindings.MessageHeader.kMessageIsResponse);
580 }
581 });
582 } else if (response != null) {
583 return buildResponseWithId(
584 response,
585 _cookieStoreMethodSetName,
586 message.header.requestId,
587 bindings.MessageHeader.kMessageIsResponse);
588 }
589 break; 585 break;
590 default: 586 default:
591 throw new bindings.MojoCodecError("Unexpected message name"); 587 throw new bindings.MojoCodecError("Unexpected message name");
592 break; 588 break;
593 } 589 }
594 return null;
595 } 590 }
596 591
597 CookieStore get impl => _impl; 592 CookieStore get impl => _impl;
598 set impl(CookieStore d) { 593 set impl(CookieStore d) {
599 if (d == null) { 594 if (d == null) {
600 throw new core.MojoApiError("$this: Cannot set a null implementation"); 595 throw new core.MojoApiError("$this: Cannot set a null implementation");
601 } 596 }
602 if (isBound && (_impl == null)) { 597 if (isBound && (_impl == null)) {
603 beginHandlingEvents(); 598 beginHandlingEvents();
604 } 599 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 core.MojoHandle handle, [CookieStore impl]) 633 core.MojoHandle handle, [CookieStore impl])
639 : super(new _CookieStoreStubControl.fromHandle(handle, impl)); 634 : super(new _CookieStoreStubControl.fromHandle(handle, impl));
640 635
641 static CookieStoreStub newFromEndpoint( 636 static CookieStoreStub newFromEndpoint(
642 core.MojoMessagePipeEndpoint endpoint) { 637 core.MojoMessagePipeEndpoint endpoint) {
643 assert(endpoint.setDescription("For CookieStoreStub")); 638 assert(endpoint.setDescription("For CookieStoreStub"));
644 return new CookieStoreStub.fromEndpoint(endpoint); 639 return new CookieStoreStub.fromEndpoint(endpoint);
645 } 640 }
646 641
647 642
648 dynamic get(String url,[Function responseFactory = null]) { 643 void get(String url,void callback(String cookies)) {
649 return impl.get(url,responseFactory); 644 return impl.get(url,callback);
650 } 645 }
651 dynamic set(String url,String cookie,[Function responseFactory = null]) { 646 void set(String url,String cookie,void callback(bool success)) {
652 return impl.set(url,cookie,responseFactory); 647 return impl.set(url,cookie,callback);
653 } 648 }
654 } 649 }
655 650
656 651
657 652
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698