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

Side by Side Diff: net/filter/sdch_source_stream.cc

Issue 2446443002: Fix net::SdchSourceStream Passthrough bug (Closed)
Patch Set: mistake made during splitting off change 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/filter/sdch_source_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/sdch_source_stream.h" 5 #include "net/filter/sdch_source_stream.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 case STATE_OUTPUT_REPLACE: { 136 case STATE_OUTPUT_REPLACE: {
137 int flushed = FlushBufferedOutput(output_buffer->data() + bytes_out, 137 int flushed = FlushBufferedOutput(output_buffer->data() + bytes_out,
138 output_buffer_size - bytes_out, 138 output_buffer_size - bytes_out,
139 buffered_output_); 139 buffered_output_);
140 buffered_output_.erase(0, flushed); 140 buffered_output_.erase(0, flushed);
141 bytes_out += flushed; 141 bytes_out += flushed;
142 break; 142 break;
143 } 143 }
144 case STATE_PASS_THROUGH: { 144 case STATE_PASS_THROUGH: {
145 if (buffered_output_.empty()) 145 if (!buffered_output_.empty()) {
146 break; 146 int flushed = FlushBufferedOutput(output_buffer->data() + bytes_out,
147 int flushed = FlushBufferedOutput(output_buffer->data() + bytes_out, 147 output_buffer_size - bytes_out,
148 output_buffer_size - bytes_out, 148 buffered_output_);
149 buffered_output_); 149 buffered_output_.erase(0, flushed);
150 buffered_output_.erase(0, flushed); 150 bytes_out += flushed;
151 bytes_out += flushed; 151 }
152 if (!buffered_output_.empty()) 152 if (!buffered_output_.empty())
153 break; 153 break;
154 size_t to_copy = 154 size_t to_copy =
155 std::min(output_buffer_size - bytes_out, input_data_size); 155 std::min(output_buffer_size - bytes_out, input_data_size);
156 memcpy(output_buffer->data() + bytes_out, input_data, to_copy); 156 memcpy(output_buffer->data() + bytes_out, input_data, to_copy);
157 bytes_out += to_copy;
157 input_data += to_copy; 158 input_data += to_copy;
158 input_data_size -= to_copy; 159 input_data_size -= to_copy;
159 break; 160 break;
160 } 161 }
161 } 162 }
162 } 163 }
163 *consumed_bytes = input_buffer_size - input_data_size; 164 *consumed_bytes = input_buffer_size - input_data_size;
164 return bytes_out; 165 return bytes_out;
165 } 166 }
166 167
(...skipping 16 matching lines...) Expand all
183 input_state_ = STATE_PASS_THROUGH; 184 input_state_ = STATE_PASS_THROUGH;
184 break; 185 break;
185 case Delegate::REPLACE_OUTPUT: 186 case Delegate::REPLACE_OUTPUT:
186 input_state_ = STATE_OUTPUT_REPLACE; 187 input_state_ = STATE_OUTPUT_REPLACE;
187 break; 188 break;
188 } 189 }
189 return true; 190 return true;
190 } 191 }
191 192
192 } // namespace net 193 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/filter/sdch_source_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698