| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/filter/filter_source_stream.h" | 5 #include "net/filter/filter_source_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 if (result <= OK) | 120 if (result <= OK) |
| 121 upstream_end_reached_ = true; | 121 upstream_end_reached_ = true; |
| 122 return result; | 122 return result; |
| 123 } | 123 } |
| 124 | 124 |
| 125 int FilterSourceStream::DoFilterData() { | 125 int FilterSourceStream::DoFilterData() { |
| 126 DCHECK(output_buffer_); | 126 DCHECK(output_buffer_); |
| 127 DCHECK(drainable_input_buffer_); | 127 DCHECK(drainable_input_buffer_); |
| 128 | 128 |
| 129 int bytes_output = FilterData(output_buffer_.get(), output_buffer_size_, | 129 int bytes_output = |
| 130 drainable_input_buffer_.get()); | 130 FilterData(output_buffer_.get(), output_buffer_size_, |
| 131 drainable_input_buffer_.get(), upstream_end_reached_); |
| 131 if (bytes_output == ERR_CONTENT_DECODING_FAILED) { | 132 if (bytes_output == ERR_CONTENT_DECODING_FAILED) { |
| 132 UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed.FilterType", type(), | 133 UMA_HISTOGRAM_ENUMERATION("Net.ContentDecodingFailed.FilterType", type(), |
| 133 TYPE_MAX); | 134 TYPE_MAX); |
| 134 } | 135 } |
| 135 // FilterData() is not allowed to return ERR_IO_PENDING. | 136 // FilterData() is not allowed to return ERR_IO_PENDING. |
| 136 DCHECK_NE(ERR_IO_PENDING, bytes_output); | 137 DCHECK_NE(ERR_IO_PENDING, bytes_output); |
| 137 | 138 |
| 138 // Received data or encountered an error. | 139 // Received data or encountered an error. |
| 139 if (bytes_output != 0) | 140 if (bytes_output != 0) |
| 140 return bytes_output; | 141 return bytes_output; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 157 output_buffer_size_ = 0; | 158 output_buffer_size_ = 0; |
| 158 | 159 |
| 159 base::ResetAndReturn(&callback_).Run(rv); | 160 base::ResetAndReturn(&callback_).Run(rv); |
| 160 } | 161 } |
| 161 | 162 |
| 162 bool FilterSourceStream::NeedMoreData() const { | 163 bool FilterSourceStream::NeedMoreData() const { |
| 163 return !upstream_end_reached_; | 164 return !upstream_end_reached_; |
| 164 } | 165 } |
| 165 | 166 |
| 166 } // namespace net | 167 } // namespace net |
| OLD | NEW |