| 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 url_loader_mojom; | 5 library url_loader_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 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; | 10 import 'package:mojo/mojo/network_error.mojom.dart' as network_error_mojom; |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 impl.requireVersion(requiredVersion); | 706 impl.requireVersion(requiredVersion); |
| 707 } | 707 } |
| 708 | 708 |
| 709 String toString() { | 709 String toString() { |
| 710 return "UrlLoaderProxy($impl)"; | 710 return "UrlLoaderProxy($impl)"; |
| 711 } | 711 } |
| 712 } | 712 } |
| 713 | 713 |
| 714 | 714 |
| 715 class UrlLoaderStub extends bindings.Stub { | 715 class UrlLoaderStub extends bindings.Stub { |
| 716 UrlLoader _impl = null; | 716 UrlLoader _impl; |
| 717 | 717 |
| 718 UrlLoaderStub.fromEndpoint( | 718 UrlLoaderStub.fromEndpoint( |
| 719 core.MojoMessagePipeEndpoint endpoint, [this._impl]) | 719 core.MojoMessagePipeEndpoint endpoint, [UrlLoader impl]) |
| 720 : super.fromEndpoint(endpoint); | 720 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| 721 _impl = impl; |
| 722 } |
| 721 | 723 |
| 722 UrlLoaderStub.fromHandle(core.MojoHandle handle, [this._impl]) | 724 UrlLoaderStub.fromHandle( |
| 723 : super.fromHandle(handle); | 725 core.MojoHandle handle, [UrlLoader impl]) |
| 726 : super.fromHandle(handle, autoBegin: impl != null) { |
| 727 _impl = impl; |
| 728 } |
| 724 | 729 |
| 725 UrlLoaderStub.unbound() : super.unbound(); | 730 UrlLoaderStub.unbound() : super.unbound(); |
| 726 | 731 |
| 727 static UrlLoaderStub newFromEndpoint( | 732 static UrlLoaderStub newFromEndpoint( |
| 728 core.MojoMessagePipeEndpoint endpoint) { | 733 core.MojoMessagePipeEndpoint endpoint) { |
| 729 assert(endpoint.setDescription("For UrlLoaderStub")); | 734 assert(endpoint.setDescription("For UrlLoaderStub")); |
| 730 return new UrlLoaderStub.fromEndpoint(endpoint); | 735 return new UrlLoaderStub.fromEndpoint(endpoint); |
| 731 } | 736 } |
| 732 | 737 |
| 733 | 738 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 746 result.status = status; | 751 result.status = status; |
| 747 return result; | 752 return result; |
| 748 } | 753 } |
| 749 | 754 |
| 750 dynamic handleMessage(bindings.ServiceMessage message) { | 755 dynamic handleMessage(bindings.ServiceMessage message) { |
| 751 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 756 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 752 return bindings.ControlMessageHandler.handleMessage(this, | 757 return bindings.ControlMessageHandler.handleMessage(this, |
| 753 0, | 758 0, |
| 754 message); | 759 message); |
| 755 } | 760 } |
| 756 assert(_impl != null); | 761 if (_impl == null) { |
| 762 throw new core.MojoApiError("$this has no implementation set"); |
| 763 } |
| 757 switch (message.header.type) { | 764 switch (message.header.type) { |
| 758 case _urlLoaderMethodStartName: | 765 case _urlLoaderMethodStartName: |
| 759 var params = _UrlLoaderStartParams.deserialize( | 766 var params = _UrlLoaderStartParams.deserialize( |
| 760 message.payload); | 767 message.payload); |
| 761 var response = _impl.start(params.request,_urlLoaderStartResponseParamsF
actory); | 768 var response = _impl.start(params.request,_urlLoaderStartResponseParamsF
actory); |
| 762 if (response is Future) { | 769 if (response is Future) { |
| 763 return response.then((response) { | 770 return response.then((response) { |
| 764 if (response != null) { | 771 if (response != null) { |
| 765 return buildResponseWithId( | 772 return buildResponseWithId( |
| 766 response, | 773 response, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 break; | 826 break; |
| 820 default: | 827 default: |
| 821 throw new bindings.MojoCodecError("Unexpected message name"); | 828 throw new bindings.MojoCodecError("Unexpected message name"); |
| 822 break; | 829 break; |
| 823 } | 830 } |
| 824 return null; | 831 return null; |
| 825 } | 832 } |
| 826 | 833 |
| 827 UrlLoader get impl => _impl; | 834 UrlLoader get impl => _impl; |
| 828 set impl(UrlLoader d) { | 835 set impl(UrlLoader d) { |
| 829 assert(_impl == null); | 836 if (d == null) { |
| 837 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
| 838 } |
| 839 if (isBound && (_impl == null)) { |
| 840 beginHandlingEvents(); |
| 841 } |
| 830 _impl = d; | 842 _impl = d; |
| 831 } | 843 } |
| 832 | 844 |
| 845 @override |
| 846 void bind(core.MojoMessagePipeEndpoint endpoint) { |
| 847 super.bind(endpoint); |
| 848 if (!isOpen && (_impl != null)) { |
| 849 beginHandlingEvents(); |
| 850 } |
| 851 } |
| 852 |
| 833 String toString() { | 853 String toString() { |
| 834 var superString = super.toString(); | 854 var superString = super.toString(); |
| 835 return "UrlLoaderStub($superString)"; | 855 return "UrlLoaderStub($superString)"; |
| 836 } | 856 } |
| 837 | 857 |
| 838 int get version => 0; | 858 int get version => 0; |
| 839 | 859 |
| 840 static service_describer.ServiceDescription _cachedServiceDescription; | 860 static service_describer.ServiceDescription _cachedServiceDescription; |
| 841 static service_describer.ServiceDescription get serviceDescription { | 861 static service_describer.ServiceDescription get serviceDescription { |
| 842 if (_cachedServiceDescription == null) { | 862 if (_cachedServiceDescription == null) { |
| 843 _cachedServiceDescription = new _UrlLoaderServiceDescription(); | 863 _cachedServiceDescription = new _UrlLoaderServiceDescription(); |
| 844 } | 864 } |
| 845 return _cachedServiceDescription; | 865 return _cachedServiceDescription; |
| 846 } | 866 } |
| 847 } | 867 } |
| 848 | 868 |
| 849 | 869 |
| 850 | 870 |
| OLD | NEW |