| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.convert; | 5 part of dart.convert; |
| 6 | 6 |
| 7 typedef void _ChunkedConversionCallback<T>(T accumulated); | 7 typedef void _ChunkedConversionCallback<T>(T accumulated); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * A converter that supports chunked conversions. | 10 * A converter that supports chunked conversions. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 * [handleData] is added into this sink. | 123 * [handleData] is added into this sink. |
| 124 */ | 124 */ |
| 125 ChunkedConversionSink<S> _chunkedSink; | 125 ChunkedConversionSink<S> _chunkedSink; |
| 126 | 126 |
| 127 _ConverterStreamEventSink( | 127 _ConverterStreamEventSink( |
| 128 Converter/*=ChunkedConverter<dynamic, dynamic, S, T>*/ converter, | 128 Converter/*=ChunkedConverter<dynamic, dynamic, S, T>*/ converter, |
| 129 EventSink<T> sink) | 129 EventSink<T> sink) |
| 130 : this._eventSink = sink, | 130 : this._eventSink = sink, |
| 131 _chunkedSink = converter.startChunkedConversion(sink); | 131 _chunkedSink = converter.startChunkedConversion(sink); |
| 132 | 132 |
| 133 void add(S o) => _chunkedSink.add(o); | 133 void add(S o) { _chunkedSink.add(o); } |
| 134 void addError(Object error, [StackTrace stackTrace]) { | 134 void addError(Object error, [StackTrace stackTrace]) { |
| 135 _eventSink.addError(error, stackTrace); | 135 _eventSink.addError(error, stackTrace); |
| 136 } | 136 } |
| 137 void close() => _chunkedSink.close(); | 137 void close() { _chunkedSink.close(); } |
| 138 } | 138 } |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Fuses two chunked converters. | 141 * Fuses two chunked converters. |
| 142 */ | 142 */ |
| 143 class _FusedChunkedConverter<S, M, T, S2, M2, T2> extends | 143 class _FusedChunkedConverter<S, M, T, S2, M2, T2> extends |
| 144 ChunkedConverter<S, T, S2, T2> { | 144 ChunkedConverter<S, T, S2, T2> { |
| 145 final ChunkedConverter<S, M, S2, M2> _first; | 145 final ChunkedConverter<S, M, S2, M2> _first; |
| 146 final ChunkedConverter<M, T, M2, T2> _second; | 146 final ChunkedConverter<M, T, M2, T2> _second; |
| 147 | 147 |
| 148 _FusedChunkedConverter(this._first, this._second); | 148 _FusedChunkedConverter(this._first, this._second); |
| 149 | 149 |
| 150 T convert(S input) => _second.convert(_first.convert(input)); | 150 T convert(S input) => _second.convert(_first.convert(input)); |
| 151 | 151 |
| 152 ChunkedConversionSink<S2> startChunkedConversion(Sink<T2> sink) { | 152 ChunkedConversionSink<S2> startChunkedConversion(Sink<T2> sink) { |
| 153 return _first.startChunkedConversion(_second.startChunkedConversion(sink)); | 153 return _first.startChunkedConversion(_second.startChunkedConversion(sink)); |
| 154 } | 154 } |
| 155 } | 155 } |
| OLD | NEW |