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

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

Issue 2320006: Revert r47599 because it breaks PDF viewing on windows.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« 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 }
164 } 152 }
165 153
166 void MultipartResponseDelegate::OnCompletedRequest() { 154 void MultipartResponseDelegate::OnCompletedRequest() {
167 // If we have any pending data and we're not in a header, go ahead and send 155 // If we have any pending data and we're not in a header, go ahead and send
168 // it to WebCore. 156 // it to WebCore.
169 if (!processing_headers_ && !data_.empty()) { 157 if (!processing_headers_ && !data_.empty()) {
170 client_->didReceiveData(loader_, 158 client_->didReceiveData(loader_,
171 data_.data(), 159 data_.data(),
172 static_cast<int>(data_.length())); 160 static_cast<int>(data_.length()));
173 } 161 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 byte_range_upper_bound_characters); 339 byte_range_upper_bound_characters);
352 340
353 if (!StringToInt(byte_range_lower_bound, content_range_lower_bound)) 341 if (!StringToInt(byte_range_lower_bound, content_range_lower_bound))
354 return false; 342 return false;
355 if (!StringToInt(byte_range_upper_bound, content_range_upper_bound)) 343 if (!StringToInt(byte_range_upper_bound, content_range_upper_bound))
356 return false; 344 return false;
357 return true; 345 return true;
358 } 346 }
359 347
360 } // namespace webkit_glue 348 } // 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