| 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 cookie_store_mojom; | 5 library cookie_store_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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 responseFactory(null); | 325 responseFactory(null); |
| 326 } | 326 } |
| 327 | 327 |
| 328 abstract class CookieStore { | 328 abstract class CookieStore { |
| 329 static const String serviceName = null; | 329 static const String serviceName = null; |
| 330 dynamic get(String url,[Function responseFactory = null]); | 330 dynamic get(String url,[Function responseFactory = null]); |
| 331 dynamic set(String url,String cookie,[Function responseFactory = null]); | 331 dynamic set(String url,String cookie,[Function responseFactory = null]); |
| 332 } | 332 } |
| 333 | 333 |
| 334 | 334 |
| 335 class _CookieStoreProxyImpl extends bindings.Proxy { | 335 class _CookieStoreProxyControl extends bindings.ProxyMessageHandler |
| 336 _CookieStoreProxyImpl.fromEndpoint( | 336 implements bindings.ProxyControl { |
| 337 _CookieStoreProxyControl.fromEndpoint( |
| 337 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 338 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 338 | 339 |
| 339 _CookieStoreProxyImpl.fromHandle(core.MojoHandle handle) : | 340 _CookieStoreProxyControl.fromHandle( |
| 340 super.fromHandle(handle); | 341 core.MojoHandle handle) : super.fromHandle(handle); |
| 341 | 342 |
| 342 _CookieStoreProxyImpl.unbound() : super.unbound(); | 343 _CookieStoreProxyControl.unbound() : super.unbound(); |
| 343 | |
| 344 static _CookieStoreProxyImpl newFromEndpoint( | |
| 345 core.MojoMessagePipeEndpoint endpoint) { | |
| 346 assert(endpoint.setDescription("For _CookieStoreProxyImpl")); | |
| 347 return new _CookieStoreProxyImpl.fromEndpoint(endpoint); | |
| 348 } | |
| 349 | 344 |
| 350 service_describer.ServiceDescription get serviceDescription => | 345 service_describer.ServiceDescription get serviceDescription => |
| 351 new _CookieStoreServiceDescription(); | 346 new _CookieStoreServiceDescription(); |
| 352 | 347 |
| 348 String get serviceName => CookieStore.serviceName; |
| 349 |
| 350 @override |
| 353 void handleResponse(bindings.ServiceMessage message) { | 351 void handleResponse(bindings.ServiceMessage message) { |
| 354 switch (message.header.type) { | 352 switch (message.header.type) { |
| 355 case _cookieStoreMethodGetName: | 353 case _cookieStoreMethodGetName: |
| 356 var r = CookieStoreGetResponseParams.deserialize( | 354 var r = CookieStoreGetResponseParams.deserialize( |
| 357 message.payload); | 355 message.payload); |
| 358 if (!message.header.hasRequestId) { | 356 if (!message.header.hasRequestId) { |
| 359 proxyError("Expected a message with a valid request Id."); | 357 proxyError("Expected a message with a valid request Id."); |
| 360 return; | 358 return; |
| 361 } | 359 } |
| 362 Completer c = completerMap[message.header.requestId]; | 360 Completer c = completerMap[message.header.requestId]; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 392 } | 390 } |
| 393 c.complete(r); | 391 c.complete(r); |
| 394 break; | 392 break; |
| 395 default: | 393 default: |
| 396 proxyError("Unexpected message type: ${message.header.type}"); | 394 proxyError("Unexpected message type: ${message.header.type}"); |
| 397 close(immediate: true); | 395 close(immediate: true); |
| 398 break; | 396 break; |
| 399 } | 397 } |
| 400 } | 398 } |
| 401 | 399 |
| 400 @override |
| 402 String toString() { | 401 String toString() { |
| 403 var superString = super.toString(); | 402 var superString = super.toString(); |
| 404 return "_CookieStoreProxyImpl($superString)"; | 403 return "_CookieStoreProxyControl($superString)"; |
| 405 } | 404 } |
| 406 } | 405 } |
| 407 | 406 |
| 408 | 407 |
| 409 class _CookieStoreProxyCalls implements CookieStore { | 408 class CookieStoreProxy extends bindings.Proxy |
| 410 _CookieStoreProxyImpl _proxyImpl; | 409 implements CookieStore { |
| 410 CookieStoreProxy.fromEndpoint( |
| 411 core.MojoMessagePipeEndpoint endpoint) |
| 412 : super(new _CookieStoreProxyControl.fromEndpoint(endpoint)); |
| 411 | 413 |
| 412 _CookieStoreProxyCalls(this._proxyImpl); | 414 CookieStoreProxy.fromHandle(core.MojoHandle handle) |
| 413 dynamic get(String url,[Function responseFactory = null]) { | 415 : super(new _CookieStoreProxyControl.fromHandle(handle)); |
| 414 var params = new _CookieStoreGetParams(); | |
| 415 params.url = url; | |
| 416 return _proxyImpl.sendMessageWithRequestId( | |
| 417 params, | |
| 418 _cookieStoreMethodGetName, | |
| 419 -1, | |
| 420 bindings.MessageHeader.kMessageExpectsResponse); | |
| 421 } | |
| 422 dynamic set(String url,String cookie,[Function responseFactory = null]) { | |
| 423 var params = new _CookieStoreSetParams(); | |
| 424 params.url = url; | |
| 425 params.cookie = cookie; | |
| 426 return _proxyImpl.sendMessageWithRequestId( | |
| 427 params, | |
| 428 _cookieStoreMethodSetName, | |
| 429 -1, | |
| 430 bindings.MessageHeader.kMessageExpectsResponse); | |
| 431 } | |
| 432 } | |
| 433 | 416 |
| 417 CookieStoreProxy.unbound() |
| 418 : super(new _CookieStoreProxyControl.unbound()); |
| 434 | 419 |
| 435 class CookieStoreProxy implements bindings.ProxyBase { | 420 static CookieStoreProxy newFromEndpoint( |
| 436 final bindings.Proxy impl; | 421 core.MojoMessagePipeEndpoint endpoint) { |
| 437 CookieStore ptr; | 422 assert(endpoint.setDescription("For CookieStoreProxy")); |
| 438 | 423 return new CookieStoreProxy.fromEndpoint(endpoint); |
| 439 CookieStoreProxy(_CookieStoreProxyImpl proxyImpl) : | |
| 440 impl = proxyImpl, | |
| 441 ptr = new _CookieStoreProxyCalls(proxyImpl); | |
| 442 | |
| 443 CookieStoreProxy.fromEndpoint( | |
| 444 core.MojoMessagePipeEndpoint endpoint) : | |
| 445 impl = new _CookieStoreProxyImpl.fromEndpoint(endpoint) { | |
| 446 ptr = new _CookieStoreProxyCalls(impl); | |
| 447 } | |
| 448 | |
| 449 CookieStoreProxy.fromHandle(core.MojoHandle handle) : | |
| 450 impl = new _CookieStoreProxyImpl.fromHandle(handle) { | |
| 451 ptr = new _CookieStoreProxyCalls(impl); | |
| 452 } | |
| 453 | |
| 454 CookieStoreProxy.unbound() : | |
| 455 impl = new _CookieStoreProxyImpl.unbound() { | |
| 456 ptr = new _CookieStoreProxyCalls(impl); | |
| 457 } | 424 } |
| 458 | 425 |
| 459 factory CookieStoreProxy.connectToService( | 426 factory CookieStoreProxy.connectToService( |
| 460 bindings.ServiceConnector s, String url, [String serviceName]) { | 427 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 461 CookieStoreProxy p = new CookieStoreProxy.unbound(); | 428 CookieStoreProxy p = new CookieStoreProxy.unbound(); |
| 462 s.connectToService(url, p, serviceName); | 429 s.connectToService(url, p, serviceName); |
| 463 return p; | 430 return p; |
| 464 } | 431 } |
| 465 | 432 |
| 466 static CookieStoreProxy newFromEndpoint( | 433 |
| 467 core.MojoMessagePipeEndpoint endpoint) { | 434 dynamic get(String url,[Function responseFactory = null]) { |
| 468 assert(endpoint.setDescription("For CookieStoreProxy")); | 435 var params = new _CookieStoreGetParams(); |
| 469 return new CookieStoreProxy.fromEndpoint(endpoint); | 436 params.url = url; |
| 437 return ctrl.sendMessageWithRequestId( |
| 438 params, |
| 439 _cookieStoreMethodGetName, |
| 440 -1, |
| 441 bindings.MessageHeader.kMessageExpectsResponse); |
| 470 } | 442 } |
| 471 | 443 dynamic set(String url,String cookie,[Function responseFactory = null]) { |
| 472 String get serviceName => CookieStore.serviceName; | 444 var params = new _CookieStoreSetParams(); |
| 473 | 445 params.url = url; |
| 474 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 446 params.cookie = cookie; |
| 475 | 447 return ctrl.sendMessageWithRequestId( |
| 476 Future responseOrError(Future f) => impl.responseOrError(f); | 448 params, |
| 477 | 449 _cookieStoreMethodSetName, |
| 478 Future get errorFuture => impl.errorFuture; | 450 -1, |
| 479 | 451 bindings.MessageHeader.kMessageExpectsResponse); |
| 480 int get version => impl.version; | |
| 481 | |
| 482 Future<int> queryVersion() => impl.queryVersion(); | |
| 483 | |
| 484 void requireVersion(int requiredVersion) { | |
| 485 impl.requireVersion(requiredVersion); | |
| 486 } | |
| 487 | |
| 488 String toString() { | |
| 489 return "CookieStoreProxy($impl)"; | |
| 490 } | 452 } |
| 491 } | 453 } |
| 492 | 454 |
| 493 | 455 |
| 494 class CookieStoreStub extends bindings.Stub { | 456 class CookieStoreStub extends bindings.Stub { |
| 495 CookieStore _impl; | 457 CookieStore _impl; |
| 496 | 458 |
| 497 CookieStoreStub.fromEndpoint( | 459 CookieStoreStub.fromEndpoint( |
| 498 core.MojoMessagePipeEndpoint endpoint, [CookieStore impl]) | 460 core.MojoMessagePipeEndpoint endpoint, [CookieStore impl]) |
| 499 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 461 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 static service_describer.ServiceDescription get serviceDescription { | 579 static service_describer.ServiceDescription get serviceDescription { |
| 618 if (_cachedServiceDescription == null) { | 580 if (_cachedServiceDescription == null) { |
| 619 _cachedServiceDescription = new _CookieStoreServiceDescription(); | 581 _cachedServiceDescription = new _CookieStoreServiceDescription(); |
| 620 } | 582 } |
| 621 return _cachedServiceDescription; | 583 return _cachedServiceDescription; |
| 622 } | 584 } |
| 623 } | 585 } |
| 624 | 586 |
| 625 | 587 |
| 626 | 588 |
| OLD | NEW |