Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: sdk/lib/io/data_transformer.dart

Issue 1393013002: Ensure ZILB encoder handles all typed data lists correctly (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Addressed review comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/filter.cc ('k') | tests/standalone/io/zlib_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 bool _empty = true; 476 bool _empty = true;
477 477
478 _FilterSink(this._sink, this._filter); 478 _FilterSink(this._sink, this._filter);
479 479
480 void add(List<int> data) { 480 void add(List<int> data) {
481 addSlice(data, 0, data.length, false); 481 addSlice(data, 0, data.length, false);
482 } 482 }
483 483
484 void addSlice(List<int> data, int start, int end, bool isLast) { 484 void addSlice(List<int> data, int start, int end, bool isLast) {
485 if (_closed) return; 485 if (_closed) return;
486 if (start < 0 || start > data.length) { 486 if (end == null) throw ArgumentError.notNull("end");
487 throw new ArgumentError("Invalid start position"); 487 RangeError.checkValidRange(start, end, data.length);
488 }
489 if (end < 0 || end > data.length || end < start) {
490 throw new ArgumentError("Invalid end position");
491 }
492 try { 488 try {
493 _empty = false; 489 _empty = false;
494 _filter.process(data, start, end); 490 _BufferAndStart bufferAndStart =
491 _ensureFastAndSerializableByteData(data, start, end);
492 _filter.process(bufferAndStart.buffer,
493 bufferAndStart.start,
494 end - (start - bufferAndStart.start));
495 var 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 throw e; 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);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « runtime/bin/filter.cc ('k') | tests/standalone/io/zlib_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698