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

Side by Side Diff: webkit/glue/multipart_response_delegate.cc

Issue 2787002: Take 2 at working around a multipart crash (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: style 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 unified diff | Download patch
« no previous file with comments | « no previous file | webkit/glue/multipart_response_delegate_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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "webkit/glue/multipart_response_delegate.h" 5 #include "webkit/glue/multipart_response_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/net_util.h" 9 #include "net/base/net_util.h"
10 #include "net/http/http_util.h" 10 #include "net/http/http_util.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // We can now throw out data up through the boundary 142 // We can now throw out data up through the boundary
143 int offset = PushOverLine(data_, boundary_end_pos); 143 int offset = PushOverLine(data_, boundary_end_pos);
144 data_ = data_.substr(boundary_end_pos + offset); 144 data_ = data_.substr(boundary_end_pos + offset);
145 145
146 // Ok, back to parsing headers 146 // Ok, back to parsing headers
147 if (!ParseHeaders()) { 147 if (!ParseHeaders()) {
148 processing_headers_ = true; 148 processing_headers_ = true;
149 break; 149 break;
150 } 150 }
151 } 151 }
152
153 // At this point, we should send over any data we have, but keep enough data
154 // buffered to handle a boundary that may have been truncated.
155 if (!processing_headers_ && data_.length() > boundary_.length()) {
156 // If the last character is a new line character, go ahead and just send
157 // everything we have buffered. This matches an optimization in Gecko.
158 int send_length = data_.length() - boundary_.length();
159 if (data_[data_.length() - 1] == '\n')
160 send_length = data_.length();
161 client_->didReceiveData(loader_, data_.data(), send_length);
162 data_ = data_.substr(send_length);
163 }
152 } 164 }
153 165
154 void MultipartResponseDelegate::OnCompletedRequest() { 166 void MultipartResponseDelegate::OnCompletedRequest() {
155 // If we have any pending data and we're not in a header, go ahead and send 167 // If we have any pending data and we're not in a header, go ahead and send
156 // it to WebCore. 168 // it to WebCore.
157 if (!processing_headers_ && !data_.empty()) { 169 if (!processing_headers_ && !data_.empty()) {
158 client_->didReceiveData(loader_, 170 client_->didReceiveData(loader_,
159 data_.data(), 171 data_.data(),
160 static_cast<int>(data_.length())); 172 static_cast<int>(data_.length()));
161 } 173 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 byte_range_upper_bound_characters); 351 byte_range_upper_bound_characters);
340 352
341 if (!StringToInt(byte_range_lower_bound, content_range_lower_bound)) 353 if (!StringToInt(byte_range_lower_bound, content_range_lower_bound))
342 return false; 354 return false;
343 if (!StringToInt(byte_range_upper_bound, content_range_upper_bound)) 355 if (!StringToInt(byte_range_upper_bound, content_range_upper_bound))
344 return false; 356 return false;
345 return true; 357 return true;
346 } 358 }
347 359
348 } // namespace webkit_glue 360 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/multipart_response_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698