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

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

Issue 2327643003: Replace ASSERT*() with DCHECK*() in core/fetch/ and core/loader/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 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"
11 11
12 #include <algorithm> 12 #include <algorithm>
13 13
14 namespace blink { 14 namespace blink {
15 15
16 MultipartImageResourceParser::MultipartImageResourceParser(const ResourceRespons e& response, const Vector<char>& boundary, Client* client) 16 MultipartImageResourceParser::MultipartImageResourceParser(const ResourceRespons e& response, const Vector<char>& boundary, Client* client)
17 : m_originalResponse(response) 17 : m_originalResponse(response)
18 , m_boundary(boundary) 18 , m_boundary(boundary)
19 , m_client(client) 19 , m_client(client)
20 { 20 {
21 // Some servers report a boundary prefixed with "--". See https://crbug.com /5786. 21 // Some servers report a boundary prefixed with "--". See https://crbug.com /5786.
22 if (m_boundary.size() < 2 || m_boundary[0] != '-' || m_boundary[1] != '-') 22 if (m_boundary.size() < 2 || m_boundary[0] != '-' || m_boundary[1] != '-')
23 m_boundary.prepend("--", 2); 23 m_boundary.prepend("--", 2);
24 } 24 }
25 25
26 void MultipartImageResourceParser::appendData(const char* bytes, size_t size) 26 void MultipartImageResourceParser::appendData(const char* bytes, size_t size)
27 { 27 {
28 ASSERT(!isCancelled()); 28 DCHECK(!isCancelled());
29 // m_sawLastBoundary means that we've already received the final boundary 29 // m_sawLastBoundary means that we've already received the final boundary
30 // token. The server should stop sending us data at this point, but if it 30 // token. The server should stop sending us data at this point, but if it
31 // does, we just throw it away. 31 // does, we just throw it away.
32 if (m_sawLastBoundary) 32 if (m_sawLastBoundary)
33 return; 33 return;
34 m_data.append(bytes, size); 34 m_data.append(bytes, size);
35 35
36 if (m_isParsingTop) { 36 if (m_isParsingTop) {
37 // Eat leading \r\n 37 // Eat leading \r\n
38 size_t pos = skippableLength(m_data, 0); 38 size_t pos = skippableLength(m_data, 0);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // "+2" for CRLF, as we may ignore the last CRLF. 107 // "+2" for CRLF, as we may ignore the last CRLF.
108 if (!m_isParsingHeaders && m_data.size() > m_boundary.size() + 2) { 108 if (!m_isParsingHeaders && m_data.size() > m_boundary.size() + 2) {
109 size_t sendLength = m_data.size() - m_boundary.size() - 2; 109 size_t sendLength = m_data.size() - m_boundary.size() - 2;
110 m_client->multipartDataReceived(m_data.data(), sendLength); 110 m_client->multipartDataReceived(m_data.data(), sendLength);
111 m_data.remove(0, sendLength); 111 m_data.remove(0, sendLength);
112 } 112 }
113 } 113 }
114 114
115 void MultipartImageResourceParser::finish() 115 void MultipartImageResourceParser::finish()
116 { 116 {
117 ASSERT(!isCancelled()); 117 DCHECK(!isCancelled());
118 if (m_sawLastBoundary) 118 if (m_sawLastBoundary)
119 return; 119 return;
120 // If we have any pending data and we're not in a header, go ahead and send 120 // If we have any pending data and we're not in a header, go ahead and send
121 // it to the client. 121 // it to the client.
122 if (!m_isParsingHeaders && !m_data.isEmpty()) 122 if (!m_isParsingHeaders && !m_data.isEmpty())
123 m_client->multipartDataReceived(m_data.data(), m_data.size()); 123 m_client->multipartDataReceived(m_data.data(), m_data.size());
124 m_data.clear(); 124 m_data.clear();
125 m_sawLastBoundary = true; 125 m_sawLastBoundary = true;
126 } 126 }
127 127
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 return boundaryPosition; 178 return boundaryPosition;
179 } 179 }
180 180
181 DEFINE_TRACE(MultipartImageResourceParser) 181 DEFINE_TRACE(MultipartImageResourceParser)
182 { 182 {
183 visitor->trace(m_client); 183 visitor->trace(m_client);
184 } 184 }
185 185
186 } // namespace blink 186 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.cpp ('k') | third_party/WebKit/Source/core/fetch/RawResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698