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.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * Exposes ZLib options for input parameters. | 8 * Exposes ZLib options for input parameters. |
9 * | 9 * |
10 * See http://www.zlib.net/manual.html for more documentation. | 10 * See http://www.zlib.net/manual.html for more documentation. |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 ByteConversionSink startChunkedConversion(Sink<List<int>> sink) { | 427 ByteConversionSink startChunkedConversion(Sink<List<int>> sink) { |
428 if (sink is! ByteConversionSink) { | 428 if (sink is! ByteConversionSink) { |
429 sink = new ByteConversionSink.from(sink); | 429 sink = new ByteConversionSink.from(sink); |
430 } | 430 } |
431 return new _ZLibDecoderSink(sink, windowBits, dictionary, raw); | 431 return new _ZLibDecoderSink(sink, windowBits, dictionary, raw); |
432 } | 432 } |
433 } | 433 } |
434 | 434 |
435 | 435 |
436 class _BufferSink extends ByteConversionSink { | 436 class _BufferSink extends ByteConversionSink { |
437 final BytesBuilder builder = new BytesBuilder(); | 437 final BytesBuilder builder = new BytesBuilder(copy: false); |
438 | 438 |
439 void add(List<int> chunk) { | 439 void add(List<int> chunk) { |
440 builder.add(chunk); | 440 builder.add(chunk); |
441 } | 441 } |
442 | 442 |
443 void addSlice(List<int> chunk, int start, int end, bool isLast) { | 443 void addSlice(List<int> chunk, int start, int end, bool isLast) { |
444 if (chunk is Uint8List) { | 444 if (chunk is Uint8List) { |
445 Uint8List list = chunk; | 445 Uint8List list = chunk; |
446 builder.add(new Uint8List.view(list.buffer, start, end - start)); | 446 builder.add(new Uint8List.view(list.buffer, start, end - start)); |
447 } else { | 447 } else { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 586 } |
587 | 587 |
588 void _validateZLibStrategy(int strategy) { | 588 void _validateZLibStrategy(int strategy) { |
589 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED, | 589 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED, |
590 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE, | 590 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE, |
591 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT]; | 591 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT]; |
592 if (strategies.indexOf(strategy) == -1) { | 592 if (strategies.indexOf(strategy) == -1) { |
593 throw new ArgumentError("Unsupported 'strategy'"); | 593 throw new ArgumentError("Unsupported 'strategy'"); |
594 } | 594 } |
595 } | 595 } |
OLD | NEW |