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

Unified Diff: net/filter/filter_source_stream.cc

Issue 2338043002: Change DrainableIOBuffer to IBuffer and int* in FilterData() arguments (Closed)
Patch Set: rebased to r418859 and add DCHECKs Created 4 years, 3 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 | « net/filter/filter_source_stream.h ('k') | net/filter/filter_source_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/filter_source_stream.cc
diff --git a/net/filter/filter_source_stream.cc b/net/filter/filter_source_stream.cc
index 39cf9c1a978c0335843b13ada9a03e8f4214cb00..43bd67d424c72dc3824ca9e74ea6a8c27309c22d 100644
--- a/net/filter/filter_source_stream.cc
+++ b/net/filter/filter_source_stream.cc
@@ -126,9 +126,15 @@ int FilterSourceStream::DoFilterData() {
DCHECK(output_buffer_);
DCHECK(drainable_input_buffer_);
- int bytes_output =
- FilterData(output_buffer_.get(), output_buffer_size_,
- drainable_input_buffer_.get(), upstream_end_reached_);
+ int consumed_bytes = 0;
+ int bytes_output = FilterData(output_buffer_.get(), output_buffer_size_,
+ drainable_input_buffer_.get(),
+ drainable_input_buffer_->BytesRemaining(),
+ &consumed_bytes, upstream_end_reached_);
+ DCHECK_LE(consumed_bytes, drainable_input_buffer_->BytesRemaining());
+ DCHECK(bytes_output != 0 ||
+ consumed_bytes == drainable_input_buffer_->BytesRemaining());
+
if (bytes_output == ERR_CONTENT_DECODING_FAILED) {
UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed.FilterType", type(),
TYPE_MAX);
@@ -136,6 +142,9 @@ int FilterSourceStream::DoFilterData() {
// FilterData() is not allowed to return ERR_IO_PENDING.
DCHECK_NE(ERR_IO_PENDING, bytes_output);
+ if (consumed_bytes > 0)
+ drainable_input_buffer_->DidConsume(consumed_bytes);
+
// Received data or encountered an error.
if (bytes_output != 0)
return bytes_output;
« no previous file with comments | « net/filter/filter_source_stream.h ('k') | net/filter/filter_source_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698