Index: Source/core/inspector/NetworkResourcesData.cpp |
diff --git a/Source/core/inspector/NetworkResourcesData.cpp b/Source/core/inspector/NetworkResourcesData.cpp |
index dab7c31bde2f38c46ef9769c39aef63ed1fbe554..ebfe00042e7f661e485cf5cc193999719bde927b 100644 |
--- a/Source/core/inspector/NetworkResourcesData.cpp |
+++ b/Source/core/inspector/NetworkResourcesData.cpp |
@@ -80,10 +80,20 @@ void NetworkResourcesData::ResourceData::setContent(const String& content, bool |
{ |
ASSERT(!hasData()); |
ASSERT(!hasContent()); |
+ ASSERT(!hasBlob()); |
m_content = content; |
m_base64Encoded = base64Encoded; |
} |
+void NetworkResourcesData::ResourceData::setBlob(PassRefPtr<Blob> blob, const String& textEncodingName) |
+{ |
+ ASSERT(!hasData()); |
+ ASSERT(!hasContent()); |
+ ASSERT(!hasBlob()); |
+ m_blob = blob; |
+ m_blobTextEncodingName = textEncodingName; |
+} |
+ |
static size_t contentSizeInBytes(const String& content) |
{ |
return content.isNull() ? 0 : content.impl()->sizeInBytes(); |
@@ -93,16 +103,23 @@ unsigned NetworkResourcesData::ResourceData::removeContent() |
{ |
unsigned result = 0; |
if (hasData()) { |
- ASSERT(!hasContent()); |
+ ASSERT(!hasContent() && !hasBlob()); |
result = m_dataBuffer->size(); |
m_dataBuffer = nullptr; |
} |
if (hasContent()) { |
- ASSERT(!hasData()); |
+ ASSERT(!hasData() && !hasBlob()); |
result = contentSizeInBytes(m_content); |
m_content = String(); |
} |
+ |
+ if (hasBlob()) { |
+ ASSERT(!hasData() && !hasContent()); |
+ result = m_blob->size(); |
+ m_blob = nullptr; |
+ m_blobTextEncodingName = String(); |
+ } |
return result; |
} |
@@ -119,7 +136,7 @@ size_t NetworkResourcesData::ResourceData::dataLength() const |
void NetworkResourcesData::ResourceData::appendData(const char* data, size_t dataLength) |
{ |
- ASSERT(!hasContent()); |
+ ASSERT(!hasContent() && !hasBlob()); |
if (!m_dataBuffer) |
m_dataBuffer = SharedBuffer::create(data, dataLength); |
else |
@@ -128,7 +145,7 @@ void NetworkResourcesData::ResourceData::appendData(const char* data, size_t dat |
size_t NetworkResourcesData::ResourceData::decodeDataToContent() |
{ |
- ASSERT(!hasContent()); |
+ ASSERT(!hasContent() && !hasBlob()); |
size_t dataLength = m_dataBuffer->size(); |
m_content = m_decoder->decode(m_dataBuffer->data(), m_dataBuffer->size()); |
m_content.append(m_decoder->flush()); |
@@ -209,7 +226,7 @@ void NetworkResourcesData::setResourceContent(const String& requestId, const Str |
return; |
if (ensureFreeSpace(dataLength) && !resourceData->isContentEvicted()) { |
// We can not be sure that we didn't try to save this request data while it was loading, so remove it, if any. |
- if (resourceData->hasContent()) |
+ if (resourceData->hasContent() || resourceData->hasBlob()) |
m_contentSize -= resourceData->removeContent(); |
m_requestIdsDeque.append(requestId); |
resourceData->setContent(content, base64Encoded); |
@@ -217,6 +234,27 @@ void NetworkResourcesData::setResourceContent(const String& requestId, const Str |
} |
} |
+void NetworkResourcesData::setResourceBlob(const String& requestId, PassRefPtr<Blob> prpBlob, const String& textEncodingName) |
+{ |
+ RefPtr<Blob> blob = prpBlob; |
+ ResourceData* resourceData = resourceDataForRequestId(requestId); |
+ if (!resourceData) |
+ return; |
+ size_t dataLength = blob->size(); |
+ if (dataLength > m_maximumSingleResourceContentSize) |
+ return; |
+ if (resourceData->isContentEvicted()) |
+ return; |
+ if (ensureFreeSpace(dataLength) && !resourceData->isContentEvicted()) { |
+ // We can not be sure that we didn't try to save this request data while it was loading, so remove it, if any. |
+ if (resourceData->hasContent() || resourceData->hasBlob()) |
+ m_contentSize -= resourceData->removeContent(); |
+ m_requestIdsDeque.append(requestId); |
+ resourceData->setBlob(blob, textEncodingName); |
+ m_contentSize += dataLength; |
+ } |
+} |
+ |
void NetworkResourcesData::maybeAddResourceData(const String& requestId, const char* data, size_t dataLength) |
{ |
ResourceData* resourceData = resourceDataForRequestId(requestId); |
@@ -366,7 +404,7 @@ void NetworkResourcesData::ensureNoDataForRequestId(const String& requestId) |
ResourceData* resourceData = resourceDataForRequestId(requestId); |
if (!resourceData) |
return; |
- if (resourceData->hasContent() || resourceData->hasData()) |
+ if (resourceData->hasContent() || resourceData->hasData() || resourceData->hasBlob()) |
m_contentSize -= resourceData->evictContent(); |
delete resourceData; |
m_requestIdToResourceDataMap.remove(requestId); |