| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 450 } |
| 451 | 451 |
| 452 void close() {} | 452 void close() {} |
| 453 } | 453 } |
| 454 | 454 |
| 455 | 455 |
| 456 class _ZLibEncoderSink extends _FilterSink { | 456 class _ZLibEncoderSink extends _FilterSink { |
| 457 _ZLibEncoderSink(ByteConversionSink sink, bool gzip, int level, | 457 _ZLibEncoderSink(ByteConversionSink sink, bool gzip, int level, |
| 458 int windowBits, int memLevel, int strategy, | 458 int windowBits, int memLevel, int strategy, |
| 459 List<int> dictionary, bool raw) | 459 List<int> dictionary, bool raw) |
| 460 : super(sink, _Filter.newZLibDeflateFilter(gzip, level, windowBits, | 460 : super(sink, _Filter._newZLibDeflateFilter(gzip, level, windowBits, |
| 461 memLevel, strategy, | 461 memLevel, strategy, |
| 462 dictionary, raw)); | 462 dictionary, raw)); |
| 463 } | 463 } |
| 464 | 464 |
| 465 class _ZLibDecoderSink extends _FilterSink { | 465 class _ZLibDecoderSink extends _FilterSink { |
| 466 _ZLibDecoderSink(ByteConversionSink sink, int windowBits, | 466 _ZLibDecoderSink(ByteConversionSink sink, int windowBits, |
| 467 List<int> dictionary, bool raw) | 467 List<int> dictionary, bool raw) |
| 468 : super(sink, _Filter.newZLibInflateFilter(windowBits, dictionary, raw)); | 468 : super(sink, _Filter._newZLibInflateFilter(windowBits, dictionary, raw)); |
| 469 } | 469 } |
| 470 | 470 |
| 471 | 471 |
| 472 class _FilterSink extends ByteConversionSink { | 472 class _FilterSink extends ByteConversionSink { |
| 473 final _Filter _filter; | 473 final _Filter _filter; |
| 474 final ByteConversionSink _sink; | 474 final ByteConversionSink _sink; |
| 475 bool _closed = false; | 475 bool _closed = false; |
| 476 bool _empty = true; | 476 bool _empty = true; |
| 477 | 477 |
| 478 _FilterSink(this._sink, this._filter); | 478 _FilterSink(this._sink, this._filter); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 */ | 545 */ |
| 546 List<int> processed({bool flush: true, bool end: false}); | 546 List<int> processed({bool flush: true, bool end: false}); |
| 547 | 547 |
| 548 /** | 548 /** |
| 549 * Mark the filter as closed. Always call this method for any filter created | 549 * Mark the filter as closed. Always call this method for any filter created |
| 550 * to avoid leaking resources. [end] can be called at any time, but any | 550 * to avoid leaking resources. [end] can be called at any time, but any |
| 551 * successive calls to [process] or [processed] will fail. | 551 * successive calls to [process] or [processed] will fail. |
| 552 */ | 552 */ |
| 553 void end(); | 553 void end(); |
| 554 | 554 |
| 555 external static _Filter newZLibDeflateFilter(bool gzip, int level, | 555 external static _Filter _newZLibDeflateFilter(bool gzip, int level, |
| 556 int windowBits, int memLevel, | 556 int windowBits, int memLevel, |
| 557 int strategy, | 557 int strategy, |
| 558 List<int> dictionary, bool raw); | 558 List<int> dictionary, bool raw); |
| 559 | 559 |
| 560 external static _Filter newZLibInflateFilter(int windowBits, | 560 external static _Filter _newZLibInflateFilter(int windowBits, |
| 561 List<int> dictionary, bool raw); | 561 List<int> dictionary, bool raw); |
| 562 } | 562 } |
| 563 | 563 |
| 564 void _validateZLibWindowBits(int windowBits) { | 564 void _validateZLibWindowBits(int windowBits) { |
| 565 if (ZLibOption.MIN_WINDOW_BITS > windowBits || | 565 if (ZLibOption.MIN_WINDOW_BITS > windowBits || |
| 566 ZLibOption.MAX_WINDOW_BITS < windowBits) { | 566 ZLibOption.MAX_WINDOW_BITS < windowBits) { |
| 567 throw new RangeError.range(windowBits, ZLibOption.MIN_WINDOW_BITS, | 567 throw new RangeError.range(windowBits, ZLibOption.MIN_WINDOW_BITS, |
| 568 ZLibOption.MAX_WINDOW_BITS); | 568 ZLibOption.MAX_WINDOW_BITS); |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 | 571 |
| (...skipping 14 matching lines...) Expand all 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 |