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

Unified Diff: remoting/base/compressor_zlib.cc

Issue 2815043: zlib decompression for chromoting (Closed)
Patch Set: git try Created 10 years, 6 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 | « remoting/base/compressor_zlib.h ('k') | remoting/base/compressor_zlib_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/compressor_zlib.cc
diff --git a/remoting/base/compressor_zlib.cc b/remoting/base/compressor_zlib.cc
index e08d2f90ab99219c6d0c251d1eb838aef8b9ddf4..ae5b388718fa6e7eb09abca9984382a8af3f73b5 100644
--- a/remoting/base/compressor_zlib.cc
+++ b/remoting/base/compressor_zlib.cc
@@ -35,39 +35,28 @@ CompressorZlib::~CompressorZlib() {
deflateEnd(stream_.get());
}
-void CompressorZlib::Write(const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- int* consumed, int* written) {
+bool CompressorZlib::Process(const uint8* input_data, int input_size,
+ uint8* output_data, int output_size,
+ int* consumed, int* written) {
+ DCHECK_GT(output_size, 0);
+
// Setup I/O parameters.
stream_->avail_in = input_size;
stream_->next_in = (Bytef*)input_data;
stream_->avail_out = output_size;
stream_->next_out = (Bytef*)output_data;
- int ret = deflate(stream_.get(), Z_NO_FLUSH);
+ int ret = deflate(stream_.get(), input_size ? Z_NO_FLUSH : Z_FINISH);
if (ret == Z_STREAM_ERROR) {
NOTREACHED() << "zlib compression failed";
}
*consumed = input_size - stream_->avail_in;
*written = output_size - stream_->avail_out;
-}
-
-bool CompressorZlib::Flush(uint8* output_data, int output_size,
- int* written) {
- // Setup I/O parameters.
- stream_->avail_in = 0;
- stream_->next_in = NULL;
- stream_->avail_out = output_size;
- stream_->next_out = (Bytef*)output_data;
- int ret = deflate(stream_.get(), Z_FINISH);
- if (ret == Z_STREAM_ERROR) {
- NOTREACHED() << "zlib compression failed";
- }
-
- *written = output_size - stream_->avail_out;
- return ret == Z_OK;
+ // Return true when we get Z_BUF_ERROR, this way we can feed more data
+ // to zlib.
+ return ret == Z_OK || ret == Z_BUF_ERROR;
}
} // namespace remoting
« no previous file with comments | « remoting/base/compressor_zlib.h ('k') | remoting/base/compressor_zlib_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698