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

Side by Side Diff: third_party/WebKit/Source/core/fetch/MultipartImageResourceParser.cpp

Issue 1756953002: Stop dispatching notifyFinished for each part in a multipart response (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup-2
Patch Set: Created 4 years, 9 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
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 "core/fetch/MultipartImageResourceParser.h" 5 #include "core/fetch/MultipartImageResourceParser.h"
6 6
7 #include "public/platform/Platform.h" 7 #include "public/platform/Platform.h"
8 #include "public/platform/WebURLResponse.h" 8 #include "public/platform/WebURLResponse.h"
9 #include "wtf/NotFound.h" 9 #include "wtf/NotFound.h"
10 #include "wtf/text/WTFString.h" 10 #include "wtf/text/WTFString.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // replacement headers. We only replace the same few headers that gecko 155 // replacement headers. We only replace the same few headers that gecko
156 // does. See netwerk/streamconv/converters/nsMultiMixedConv.cpp. 156 // does. See netwerk/streamconv/converters/nsMultiMixedConv.cpp.
157 WebURLResponse response(m_originalResponse.url()); 157 WebURLResponse response(m_originalResponse.url());
158 for (const auto& header : m_originalResponse.httpHeaderFields()) 158 for (const auto& header : m_originalResponse.httpHeaderFields())
159 response.addHTTPHeaderField(header.key, header.value); 159 response.addHTTPHeaderField(header.key, header.value);
160 160
161 size_t end = 0; 161 size_t end = 0;
162 if (!Platform::current()->parseMultipartHeadersFromBody(m_data.data(), m_dat a.size(), &response, &end)) 162 if (!Platform::current()->parseMultipartHeadersFromBody(m_data.data(), m_dat a.size(), &response, &end))
163 return false; 163 return false;
164 m_data.remove(0, end); 164 m_data.remove(0, end);
165
166 bool isFirstPart = m_isFirstPart;
167 m_isFirstPart = false;
168 // Send the response! 165 // Send the response!
169 m_client->onePartInMultipartReceived(response.toResourceResponse(), isFirstP art); 166 m_client->onePartInMultipartReceived(response.toResourceResponse());
170
171 return true; 167 return true;
172 } 168 }
173 169
174 // Boundaries are supposed to be preceeded with --, but it looks like gecko 170 // Boundaries are supposed to be preceeded with --, but it looks like gecko
175 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken. 171 // doesn't require the dashes to exist. See nsMultiMixedConv::FindToken.
176 size_t MultipartImageResourceParser::findBoundary(const Vector<char>& data, Vect or<char>* boundary) 172 size_t MultipartImageResourceParser::findBoundary(const Vector<char>& data, Vect or<char>* boundary)
177 { 173 {
178 auto it = std::search(data.data(), data.data() + data.size(), boundary->data (), boundary->data() + boundary->size()); 174 auto it = std::search(data.data(), data.data() + data.size(), boundary->data (), boundary->data() + boundary->size());
179 if (it == data.data() + data.size()) 175 if (it == data.data() + data.size())
180 return kNotFound; 176 return kNotFound;
(...skipping 12 matching lines...) Expand all
193 } 189 }
194 return boundaryPosition; 190 return boundaryPosition;
195 } 191 }
196 192
197 DEFINE_TRACE(MultipartImageResourceParser) 193 DEFINE_TRACE(MultipartImageResourceParser)
198 { 194 {
199 visitor->trace(m_client); 195 visitor->trace(m_client);
200 } 196 }
201 197
202 } // namespace blink 198 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698