| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 if (_closed) return; | 485 if (_closed) return; |
| 486 if (end == null) throw new ArgumentError.notNull("end"); | 486 if (end == null) throw new ArgumentError.notNull("end"); |
| 487 RangeError.checkValidRange(start, end, data.length); | 487 RangeError.checkValidRange(start, end, data.length); |
| 488 try { | 488 try { |
| 489 _empty = false; | 489 _empty = false; |
| 490 _BufferAndStart bufferAndStart = | 490 _BufferAndStart bufferAndStart = |
| 491 _ensureFastAndSerializableByteData(data, start, end); | 491 _ensureFastAndSerializableByteData(data, start, end); |
| 492 _filter.process(bufferAndStart.buffer, | 492 _filter.process(bufferAndStart.buffer, |
| 493 bufferAndStart.start, | 493 bufferAndStart.start, |
| 494 end - (start - bufferAndStart.start)); | 494 end - (start - bufferAndStart.start)); |
| 495 List<int> out; | 495 var out; |
| 496 while ((out = _filter.processed(flush: false)) != null) { | 496 while ((out = _filter.processed(flush: false)) != null) { |
| 497 _sink.add(out); | 497 _sink.add(out); |
| 498 } | 498 } |
| 499 } catch (e) { | 499 } catch (e) { |
| 500 _closed = true; | 500 _closed = true; |
| 501 rethrow; | 501 rethrow; |
| 502 } | 502 } |
| 503 | 503 |
| 504 if (isLast) close(); | 504 if (isLast) close(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 void close() { | 507 void close() { |
| 508 if (_closed) return; | 508 if (_closed) return; |
| 509 // Be sure to send process an empty chunk of data. Without this, the empty | 509 // Be sure to send process an empty chunk of data. Without this, the empty |
| 510 // message would not have a GZip frame (if compressed with GZip). | 510 // message would not have a GZip frame (if compressed with GZip). |
| 511 if (_empty) _filter.process(const [], 0, 0); | 511 if (_empty) _filter.process(const [], 0, 0); |
| 512 try { | 512 try { |
| 513 List<int> out; | 513 var out; |
| 514 while ((out = _filter.processed(end: true)) != null) { | 514 while ((out = _filter.processed(end: true)) != null) { |
| 515 _sink.add(out); | 515 _sink.add(out); |
| 516 } | 516 } |
| 517 } catch (e) { | 517 } catch (e) { |
| 518 _closed = true; | 518 _closed = true; |
| 519 throw e; | 519 throw e; |
| 520 } | 520 } |
| 521 _closed = true; | 521 _closed = true; |
| 522 _sink.close(); | 522 _sink.close(); |
| 523 } | 523 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 578 } |
| 579 | 579 |
| 580 void _validateZLibStrategy(int strategy) { | 580 void _validateZLibStrategy(int strategy) { |
| 581 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED, | 581 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED, |
| 582 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE, | 582 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE, |
| 583 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT]; | 583 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT]; |
| 584 if (strategies.indexOf(strategy) == -1) { | 584 if (strategies.indexOf(strategy) == -1) { |
| 585 throw new ArgumentError("Unsupported 'strategy'"); | 585 throw new ArgumentError("Unsupported 'strategy'"); |
| 586 } | 586 } |
| 587 } | 587 } |
| OLD | NEW |