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

Unified Diff: sdk/lib/io/data_transformer.dart

Issue 130513003: [ZLIB] Add support for windowBits, memLevel, raw (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | tests/standalone/io/zlib_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/data_transformer.dart
diff --git a/sdk/lib/io/data_transformer.dart b/sdk/lib/io/data_transformer.dart
index 79df03cc140dfac3b857a07f297157d3dd0f219d..3d7704712b86fbda59a9cb9f00f48f51a8ced04c 100644
--- a/sdk/lib/io/data_transformer.dart
+++ b/sdk/lib/io/data_transformer.dart
@@ -22,23 +22,35 @@ class ZLibCodec extends Codec<List<int>, List<int>> {
final int level;
/**
+ * The windowBits parameter is the base two logarithm of the window size (the
+ * size of the history buffer). It should be in the range 8..15. Larger values
+ * of this parameter result in better compression at the expense of memory
+ * usage. The default value is 15
+ */
+ final int windowBits;
+
+ final bool raw;
+
+ /**
* Get a [Converter] for encoding to `ZLib` compressed data.
*/
Converter<List<int>, List<int>> get encoder =>
- new ZLibEncoder(gzip: false, level: level);
+ new ZLibEncoder(gzip: false, level: level, windowBits: windowBits,
+ raw: raw);
/**
* Get a [Converter] for decoding `ZLib` compressed data.
*/
- Converter<List<int>, List<int>> get decoder => const ZLibDecoder();
+ Converter<List<int>, List<int>> get decoder => new ZLibDecoder(
+ windowBits: windowBits, raw: raw);
/**
- * The compression-[level] can be set in the range of `1..10`, with `6` being
+ * The compression-[level] can be set in the range of `-1..9`, with `6` being
* the default compression level. Levels above 6 will have higher compression
* rates at the cost of more CPU and memory usage. Levels below 6 will use
* less CPU and memory, but at the cost of lower compression rates.
*/
- const ZLibCodec({this.level: 6});
+ const ZLibCodec({this.level: 6, this.windowBits: 15, this.raw: false});
vicb 2014/01/09 09:48:27 Adding some checks here would imply removing the '
}
@@ -62,23 +74,36 @@ class GZipCodec extends Codec<List<int>, List<int>> {
final int level;
/**
+ * The windowBits parameter is the base two logarithm of the window size (the
+ * size of the history buffer). It should be in the range 8..15. Larger values
+ * of this parameter result in better compression at the expense of memory
+ * usage. The default value is 15
+ */
+ final int windowBits;
+
+ final bool raw;
+
+ /**
* Get a [Converter] for encoding to `GZip` compressed data.
*/
Converter<List<int>, List<int>> get encoder =>
- new ZLibEncoder(gzip: true, level: level);
+ new ZLibEncoder(gzip: true, level: level, windowBits: windowBits,
+ raw: raw);
/**
* Get a [Converter] for decoding `GZip` compressed data.
*/
- Converter<List<int>, List<int>> get decoder => const ZLibDecoder();
+ Converter<List<int>, List<int>> get decoder => new ZLibDecoder(
+ windowBits: windowBits, raw: raw);
/**
- * The compression-[level] can be set in the range of `1..10`, with `6` being
- * the default compression level. Levels above 6 will have higher compression
- * rates at the cost of more CPU and memory usage. Levels below 6 will use
- * less CPU and memory, but at the cost of lower compression rates.
+ * The compression-[level] can be set in the range of `-1..9`, with `6` being
+ * the default compression level. Levels above `6` will have higher
+ * compression rates at the cost of more CPU and memory usage. Levels below
+ * `6` will use less CPU and memory, but at the cost of lower compression
+ * rates.
*/
- const GZipCodec({this.level: 6});
+ const GZipCodec({this.level: 6, this.windowBits: 15, this.raw: false});
}
@@ -98,11 +123,21 @@ class ZLibEncoder extends Converter<List<int>, List<int>> {
final int level;
/**
+ * The windowBits parameter is the base two logarithm of the window size (the
+ * size of the history buffer). It should be in the range 8..15. Larger values
+ * of this parameter result in better compression at the expense of memory
+ * usage. The default value is 15
+ */
+ final int windowBits;
+
+ final bool raw;
+
+ /**
* Create a new [ZLibEncoder] converter. If the [gzip] flag is set, the
* encoder will wrap the encoded ZLib data in GZip frames.
*/
- const ZLibEncoder({this.gzip: false, this.level: 6});
-
+ const ZLibEncoder({this.gzip: false, this.level: 6, this.windowBits: 15,
+ this.raw: false});
/**
* Convert a list of bytes using the options given to the [ZLibEncoder]
@@ -127,7 +162,7 @@ class ZLibEncoder extends Converter<List<int>, List<int>> {
if (sink is! ByteConversionSink) {
sink = new ByteConversionSink.from(sink);
}
- return new _ZLibEncoderSink(sink, gzip, level);
+ return new _ZLibEncoderSink(sink, gzip, level, windowBits, raw);
}
}
@@ -137,11 +172,20 @@ class ZLibEncoder extends Converter<List<int>, List<int>> {
* decompress data.
*/
class ZLibDecoder extends Converter<List<int>, List<int>> {
+ /**
+ * The windowBits parameter is the base two logarithm of the window size (the
+ * size of the history buffer). It should be in the range 8..15. Larger values
+ * of this parameter result in better compression at the expense of memory
+ * usage. The default value is 15
+ */
+ final int windowBits;
+
+ final bool raw;
/**
- * Create a new [ZLibEncoder] converter.
+ * Create a new [ZLibDecoder] converter.
*/
- const ZLibDecoder();
+ const ZLibDecoder({this.windowBits: 15, this.raw: false});
/**
* Convert a list of bytes using the options given to the [ZLibDecoder]
@@ -165,7 +209,7 @@ class ZLibDecoder extends Converter<List<int>, List<int>> {
if (sink is! ByteConversionSink) {
sink = new ByteConversionSink.from(sink);
}
- return new _ZLibDecoderSink(sink);
+ return new _ZLibDecoderSink(sink, windowBits, raw);
}
}
@@ -191,14 +235,15 @@ class _BufferSink extends ByteConversionSink {
class _ZLibEncoderSink extends _FilterSink {
- _ZLibEncoderSink(ByteConversionSink sink, bool gzip, int level)
- : super(sink, _Filter.newZLibDeflateFilter(gzip, level));
+ _ZLibEncoderSink(ByteConversionSink sink, bool gzip, int level,
+ int windowBits, bool raw)
+ : super(sink, _Filter.newZLibDeflateFilter(gzip, level, windowBits, raw));
}
class _ZLibDecoderSink extends _FilterSink {
- _ZLibDecoderSink(ByteConversionSink sink)
- : super(sink, _Filter.newZLibInflateFilter());
+ _ZLibDecoderSink(ByteConversionSink sink, int windowBits, bool raw)
+ : super(sink, _Filter.newZLibInflateFilter(windowBits, raw));
}
@@ -208,7 +253,7 @@ class _FilterSink extends ByteConversionSink {
bool _closed = false;
bool _empty = true;
- _FilterSink(ByteConversionSink this._sink, _Filter this._filter);
+ _FilterSink(this._sink, this._filter);
void add(List<int> data) {
addSlice(data, 0, data.length, false);
@@ -286,6 +331,7 @@ abstract class _Filter {
*/
void end();
- external static _Filter newZLibDeflateFilter(bool gzip, int level);
- external static _Filter newZLibInflateFilter();
+ external static _Filter newZLibDeflateFilter(bool gzip, int level,
+ int windowBits, bool raw);
+ external static _Filter newZLibInflateFilter(int windowBits, bool raw);
}
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | tests/standalone/io/zlib_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698