Chromium Code Reviews| Index: third_party/WebKit/Source/core/fetch/Resource.cpp |
| diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp |
| index fb32fc9cb99bbfe20480f148aad71201944379dc..12621de8365409e9784d700520514048d1d857c3 100644 |
| --- a/third_party/WebKit/Source/core/fetch/Resource.cpp |
| +++ b/third_party/WebKit/Source/core/fetch/Resource.cpp |
| @@ -204,6 +204,8 @@ DEFINE_TRACE(Resource) |
| #if ENABLE(OILPAN) |
| visitor->trace(m_cacheHandler); |
| #endif |
| + visitor->trace(m_multipartParser); |
| + MultipartImageResourceParser::Client::trace(visitor); |
| } |
| void Resource::load(ResourceFetcher* fetcher, const ResourceLoaderOptions& options) |
| @@ -247,6 +249,15 @@ void Resource::checkNotify() |
| void Resource::appendData(const char* data, size_t length) |
| { |
| TRACE_EVENT0("blink", "Resource::appendData"); |
| + if (isMultipartImage()) { |
| + m_multipartParser->addData(data, length); |
| + return; |
| + } |
| + appendDataInternal(data, length); |
| +} |
| + |
| +void Resource::appendDataInternal(const char* data, size_t length) |
| +{ |
| ASSERT(m_revalidatingRequest.isNull()); |
| ASSERT(!errorOccurred()); |
| if (m_options.dataBufferingPolicy == DoNotBufferData) |
| @@ -287,6 +298,9 @@ void Resource::markClientsFinished() |
| void Resource::error(Resource::Status status) |
| { |
| + if (m_multipartParser) |
| + m_multipartParser->cancel(); |
| + |
| if (!m_revalidatingRequest.isNull()) |
| m_revalidatingRequest = ResourceRequest(); |
| @@ -312,6 +326,9 @@ void Resource::finish() |
| { |
| ASSERT(m_revalidatingRequest.isNull()); |
| ASSERT(!errorOccurred()); |
| + if (m_multipartParser) |
| + m_multipartParser->finish(); |
| + |
| finishOnePart(); |
| markClientsFinished(); |
| if (!errorOccurred()) |
| @@ -456,7 +473,10 @@ void Resource::responseReceived(const ResourceResponse& response, PassOwnPtr<Web |
| } |
| revalidationFailed(); |
| } |
| - |
| + // If there's no boundary, just handle the request normally. In the gecko |
|
Nate Chapin
2016/02/25 22:07:53
This comment looks like very outdated.
yhirano
2016/02/27 01:27:45
Deleted.
|
| + // code, nsMultiMixedConv::OnStartRequest throws an exception. |
| + if (response.isMultipart() && !response.multipartBoundary().isEmpty() && (m_type == Resource::Image || m_type == Resource::MainResource) && !m_multipartParser) |
| + m_multipartParser = new MultipartImageResourceParser(response, response.multipartBoundary(), this); |
| setResponse(response); |
| String encoding = response.textEncodingName(); |
| if (!encoding.isNull()) |
| @@ -516,6 +536,30 @@ WeakPtrWillBeRawPtr<Resource> Resource::asWeakPtr() |
| #endif |
| } |
| +bool Resource::isMultipartImage() const |
| +{ |
| + return m_multipartParser; |
| +} |
| + |
| +void Resource::didReceiveResponse(const ResourceResponse& response) |
| +{ |
| + ASSERT(isMultipartImage()); |
| + responseReceived(response, nullptr); |
| + if (response.isMultipartPayload()) { |
| + // Since a subresource loader does not load multipart sections progressively, data was delivered to the loader all at once. |
| + // After the first multipart section is complete, signal to delegates that this load is "finished" |
| + m_loader->fetcher()->subresourceLoaderFinishedLoadingOnePart(m_loader); |
|
Nate Chapin
2016/02/25 22:07:53
Instead of Exposing ResourceLoader::fetcher(), can
yhirano
2016/02/27 01:27:45
Done.
|
| + if (m_loader) |
| + m_loader->didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEncodedDataLength); |
| + } |
| +} |
| + |
| +void Resource::didReceiveData(const char* bytes, size_t size) |
|
Nate Chapin
2016/02/25 22:07:53
I agree with hiroshige's comment on https://codere
yhirano
2016/02/27 01:27:45
Done.
|
| +{ |
| + ASSERT(isMultipartImage()); |
| + appendDataInternal(bytes, size); |
| +} |
| + |
| String Resource::reasonNotDeletable() const |
| { |
| StringBuilder builder; |
| @@ -669,6 +713,8 @@ void Resource::allClientsRemoved() |
| else if (!m_cancelTimer.isActive()) |
| m_cancelTimer.startOneShot(0, BLINK_FROM_HERE); |
| + if (m_multipartParser) |
| + m_multipartParser->cancel(); |
| unlock(); |
| } |