| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library crypto.base64.decoder_sink; | |
| 6 | |
| 7 import 'dart:convert'; | 5 import 'dart:convert'; |
| 8 | 6 |
| 9 import 'decoder.dart'; | 7 import 'decoder.dart'; |
| 10 | 8 |
| 11 /// A [ChunkedConversionSink] for decoding chunks of Base64 strings to data. | 9 /// A [ChunkedConversionSink] for decoding chunks of Base64 strings to data. |
| 12 class Base64DecoderSink extends ChunkedConversionSink<String> { | 10 class Base64DecoderSink extends ChunkedConversionSink<String> { |
| 13 /// The encoder used to decode each chunk. | 11 /// The encoder used to decode each chunk. |
| 14 final Base64Decoder _decoder = new Base64Decoder(); | 12 final Base64Decoder _decoder = new Base64Decoder(); |
| 15 | 13 |
| 16 /// The underlying sink to which to emit the decoded strings. | 14 /// The underlying sink to which to emit the decoded strings. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 42 if (decodableLength > 0) { | 40 if (decodableLength > 0) { |
| 43 _outSink.add(_decoder.convert(chunk.substring(0, decodableLength))); | 41 _outSink.add(_decoder.convert(chunk.substring(0, decodableLength))); |
| 44 } | 42 } |
| 45 } | 43 } |
| 46 | 44 |
| 47 void close() { | 45 void close() { |
| 48 if (_unconverted.isNotEmpty) _outSink.add(_decoder.convert(_unconverted)); | 46 if (_unconverted.isNotEmpty) _outSink.add(_decoder.convert(_unconverted)); |
| 49 _outSink.close(); | 47 _outSink.close(); |
| 50 } | 48 } |
| 51 } | 49 } |
| OLD | NEW |