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

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

Issue 2477293002: Report the size of |CSSStyleSheetResource::m_decodedSheetText| as decoded size (Closed)
Patch Set: setDecodedSheetText() Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp b/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
index 7f26ff82e2f1300f289e7edda3d99cbf4b8b64e7..a595c0ce909563dcbde58c606ce6bca34d210f86 100644
--- a/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
@@ -77,6 +77,9 @@ void CSSStyleSheetResource::setParsedStyleSheetCache(
m_parsedStyleSheetCache = newSheet;
if (m_parsedStyleSheetCache)
m_parsedStyleSheetCache->setReferencedFromResource(this);
+
+ // Updates the decoded size to take parsed stylesheet cache into account.
+ updateDecodedSize();
}
DEFINE_TRACE(CSSStyleSheetResource) {
@@ -134,9 +137,8 @@ void CSSStyleSheetResource::appendData(const char* data, size_t length) {
void CSSStyleSheetResource::checkNotify() {
// Decode the data to find out the encoding and cache the decoded sheet text.
- if (data()) {
- m_decodedSheetText = decodedText();
- }
+ if (data())
+ setDecodedSheetText(decodedText());
ResourceClientWalker<StyleSheetResourceClient> w(clients());
while (StyleSheetResourceClient* c = w.next()) {
@@ -151,6 +153,7 @@ void CSSStyleSheetResource::checkNotify() {
// Note that LinkStyle::setCSSStyleSheet can be called from didAddClient too,
// but is safe as we should have a cached ResourceIntegrityDisposition.
clearData();
+ setEncodedSizeMemoryUsage(0);
}
void CSSStyleSheetResource::destroyDecodedDataIfPossible() {
@@ -158,11 +161,10 @@ void CSSStyleSheetResource::destroyDecodedDataIfPossible() {
return;
setParsedStyleSheetCache(nullptr);
- setDecodedSize(0);
}
void CSSStyleSheetResource::destroyDecodedDataForFailedRevalidation() {
- m_decodedSheetText = String();
+ setDecodedSheetText(String());
destroyDecodedDataIfPossible();
}
@@ -217,7 +219,19 @@ void CSSStyleSheetResource::saveParsedStyleSheet(StyleSheetContents* sheet) {
return;
}
setParsedStyleSheetCache(sheet);
- setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes());
+}
+
+void CSSStyleSheetResource::setDecodedSheetText(
+ const String& decodedSheetText) {
+ m_decodedSheetText = decodedSheetText;
+ updateDecodedSize();
+}
+
+void CSSStyleSheetResource::updateDecodedSize() {
+ size_t decodedSize = m_decodedSheetText.charactersSizeInBytes();
+ if (m_parsedStyleSheetCache)
+ decodedSize += m_parsedStyleSheetCache->estimatedSizeInBytes();
+ setDecodedSize(decodedSize);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698