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 /** | 7 /** |
8 * The [ByteConversionSink] provides an interface for converters to | 8 * The [ByteConversionSink] provides an interface for converters to |
9 * efficiently transmit byte data. | 9 * efficiently transmit byte data. |
10 * | 10 * |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 * This class adapts a simple [Sink] to a [ByteConversionSink]. | 57 * This class adapts a simple [Sink] to a [ByteConversionSink]. |
58 * | 58 * |
59 * All additional methods of the [ByteConversionSink] (compared to the | 59 * All additional methods of the [ByteConversionSink] (compared to the |
60 * ChunkedConversionSink) are redirected to the `add` method. | 60 * ChunkedConversionSink) are redirected to the `add` method. |
61 */ | 61 */ |
62 class _ByteAdapterSink extends ByteConversionSinkBase { | 62 class _ByteAdapterSink extends ByteConversionSinkBase { |
63 final Sink<List<int>> _sink; | 63 final Sink<List<int>> _sink; |
64 | 64 |
65 _ByteAdapterSink(this._sink); | 65 _ByteAdapterSink(this._sink); |
66 | 66 |
67 void add(List<int> chunk) => _sink.add(chunk); | 67 void add(List<int> chunk) { _sink.add(chunk); } |
68 void close() => _sink.close(); | 68 void close() { _sink.close(); } |
69 } | 69 } |
70 | 70 |
71 /** | 71 /** |
72 * This class accumulates all chunks into one list of bytes | 72 * This class accumulates all chunks into one list of bytes |
73 * and invokes a callback when the sink is closed. | 73 * and invokes a callback when the sink is closed. |
74 * | 74 * |
75 * This class can be used to terminate a chunked conversion. | 75 * This class can be used to terminate a chunked conversion. |
76 */ | 76 */ |
77 class _ByteCallbackSink extends ByteConversionSinkBase { | 77 class _ByteCallbackSink extends ByteConversionSinkBase { |
78 static const _INITIAL_BUFFER_SIZE = 1024; | 78 static const _INITIAL_BUFFER_SIZE = 1024; |
(...skipping 28 matching lines...) Expand all Loading... |
107 v |= v >> 8; | 107 v |= v >> 8; |
108 v |= v >> 16; | 108 v |= v >> 16; |
109 v++; | 109 v++; |
110 return v; | 110 return v; |
111 } | 111 } |
112 | 112 |
113 void close() { | 113 void close() { |
114 _callback(_buffer.sublist(0, _bufferIndex)); | 114 _callback(_buffer.sublist(0, _bufferIndex)); |
115 } | 115 } |
116 } | 116 } |
OLD | NEW |