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

Unified Diff: third_party/WebKit/Source/core/fetch/ScriptResource.cpp

Issue 1389383003: WIP: Introduce CompressibleString Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/ScriptResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ScriptResource.cpp b/third_party/WebKit/Source/core/fetch/ScriptResource.cpp
index 20ab4a340557c1a2672025a4b7243bf79ae3dc26..e81c175bf68a2dd565f2b7391960af384d5cef9c 100644
--- a/third_party/WebKit/Source/core/fetch/ScriptResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/ScriptResource.cpp
@@ -79,7 +79,7 @@ void ScriptResource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebP
Resource::onMemoryDump(levelOfDetail, memoryDump);
const String name = getMemoryDumpName() + "/decoded_script";
auto dump = memoryDump->createMemoryAllocatorDump(name);
- dump->addScalar("size", "bytes", m_script.string().sizeInBytes());
+ dump->addScalar("size", "bytes", m_script.sizeInBytes());
memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName));
}
@@ -88,27 +88,27 @@ AtomicString ScriptResource::mimeType() const
return extractMIMETypeFromMediaType(m_response.httpHeaderField("Content-Type")).lower();
}
-const String& ScriptResource::script()
+const CompressableString& ScriptResource::script()
{
ASSERT(!isPurgeable());
ASSERT(isLoaded());
- if (!m_script && m_data) {
+ if (m_script.isNull() && m_data) {
String script = decodedText();
m_data.clear();
// We lie a it here and claim that script counts as encoded data (even though it's really decoded data).
// That's because the MemoryCache thinks that it can clear out decoded data by calling destroyDecodedData(),
// but we can't destroy script in destroyDecodedData because that's our only copy of the data!
setEncodedSize(script.sizeInBytes());
- m_script = AtomicString(script);
+ m_script = CompressableString(script.impl());
}
- return m_script.string();
+ return m_script;
}
void ScriptResource::destroyDecodedDataForFailedRevalidation()
{
- m_script = AtomicString();
+ m_script = CompressableString(StringImpl::empty());
}
bool ScriptResource::mimeTypeAllowedByNosniff() const

Powered by Google App Engine
This is Rietveld 408576698