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

Unified Diff: net/filter/gzip_source_stream.cc

Issue 2480203002: ui: Cleanup class/struct forward declarations (Closed)
Patch Set: Sync CL to position 430550 Created 4 years, 1 month 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 | « net/filter/gzip_source_stream.h ('k') | net/filter/gzip_source_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/gzip_source_stream.cc
diff --git a/net/filter/gzip_source_stream.cc b/net/filter/gzip_source_stream.cc
index 7a0ac0cefb5464a8b6be2f260395adf860c14a6c..de1a2de33cb8081688db800c2dcfa7364de558af 100644
--- a/net/filter/gzip_source_stream.cc
+++ b/net/filter/gzip_source_stream.cc
@@ -4,6 +4,9 @@
#include "net/filter/gzip_source_stream.h"
+#include <algorithm>
+#include <utility>
+
#include "base/bind.h"
#include "base/bit_cast.h"
#include "base/logging.h"
@@ -84,7 +87,7 @@ int GzipSourceStream::FilterData(IOBuffer* output_buffer,
int input_data_size = input_buffer_size;
int bytes_out = 0;
bool state_compressed_entered = false;
- while (input_data_size > 0) {
+ while (input_data_size > 0 && bytes_out < output_buffer_size) {
InputState state = input_state_;
switch (state) {
case STATE_START: {
@@ -159,16 +162,12 @@ int GzipSourceStream::FilterData(IOBuffer* output_buffer,
bytes_out = output_buffer_size - zlib_stream_.get()->avail_out;
input_data_size -= bytes_used;
input_data += bytes_used;
- if (ret == Z_STREAM_END) {
+ if (ret == Z_STREAM_END)
input_state_ = STATE_GZIP_FOOTER;
- break;
- }
- // Return early here since zlib has written as much data to
- // |output_buffer| as it could. There might still be some unconsumed
- // data in |input_buffer| if there is no space in |output_buffer|.
- DCHECK_EQ(Z_OK, ret);
- *consumed_bytes = input_buffer_size - input_data_size;
- return bytes_out;
+ // zlib has written as much data to |output_buffer| as it could.
+ // There might still be some unconsumed data in |input_buffer| if there
+ // is no space in |output_buffer|.
+ break;
}
case STATE_GZIP_FOOTER: {
size_t to_read = std::min(gzip_footer_bytes_left_,
« no previous file with comments | « net/filter/gzip_source_stream.h ('k') | net/filter/gzip_source_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698