| Index: sdk/lib/convert/converter.dart
|
| diff --git a/sdk/lib/convert/converter.dart b/sdk/lib/convert/converter.dart
|
| index 8e7a6f164f9a5b8aae3319d3b58ca15456a53f8d..faa509b944c3ec22e5e702c2b4e35d3eb9485f8e 100644
|
| --- a/sdk/lib/convert/converter.dart
|
| +++ b/sdk/lib/convert/converter.dart
|
| @@ -25,6 +25,39 @@ abstract class Converter<S, T> {
|
| Converter<S, dynamic> fuse(Converter<T, dynamic> other) {
|
| return new _FusedConverter<S, T, dynamic>(this, other);
|
| }
|
| +
|
| + /**
|
| + * Starts a chunked conversion.
|
| + *
|
| + * The returned [ChunkedConversionSink] supports the interface described by
|
| + * [inputInterface].
|
| + *
|
| + * If the given [sink] supports the methods described by
|
| + * [outputInterface] then the chunked conversion can take advantage of
|
| + * the additional methods and provide a more efficient conversion.
|
| + *
|
| + * If [sink] does not support the [outputInterface] it is adapted. If
|
| + * necessary, the adapter buffers all chunks and invokes
|
| + * `addNonChunked` on [sink].
|
| + */
|
| + ChunkedConversionSink startChunkedConversion(ChunkedConversionSink sink) {
|
| + throw new UnsupportedError(
|
| + "This converter does not support chunked conversions: $this");
|
| + }
|
| +
|
| + /**
|
| + * Defines the accepted input interface for chunked conversions.
|
| + *
|
| + * Is `null` if `this` does not support chunked conversions.
|
| + */
|
| + ChunkedConversionInterface get inputInterface => null;
|
| +
|
| + /**
|
| + * Defines the accepted output interface for chunked conversions.
|
| + *
|
| + * Is `null` if `this` does not support chunked conversions.
|
| + */
|
| + ChunkedConversionInterface get outputInterface => null;
|
| }
|
|
|
| /**
|
| @@ -39,4 +72,19 @@ class _FusedConverter<S, M, T> extends Converter<S, T> {
|
| _FusedConverter(this._first, this._second);
|
|
|
| T convert(S input) => _second.convert(_first.convert(input));
|
| +
|
| + ChunkedConversionSink startChunkedConversion(ChunkedConversionSink sink) {
|
| + return _first.startChunkedConversion(_second.startChunkedConversion(sink));
|
| + }
|
| +
|
| + ChunkedConversionInterface get inputInterface {
|
| + // Don't advertise a chunked conversion if the _second converter doesn't
|
| + // support it.
|
| + if (_second.inputInterface != null) return _first.inputInterface;
|
| + }
|
| + ChunkedConversionInterface get outputInterface {
|
| + // Don't advertise a chunked conversion if the _first converter doesn't
|
| + // support it.
|
| + if (_first.outputInterface != null) return _second.outputInterface;
|
| + }
|
| }
|
|
|