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

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: comment 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..635457845497f48faa4aad3af553de693aba3864 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) {
@@ -136,6 +139,7 @@ void CSSStyleSheetResource::checkNotify() {
// Decode the data to find out the encoding and cache the decoded sheet text.
if (data()) {
m_decodedSheetText = decodedText();
+ updateDecodedSize();
hajimehoshi 2016/11/07 11:11:34 I'd make setDecodedSheetText and call updateDecode
hiroshige 2016/11/07 11:41:20 Done.
}
ResourceClientWalker<StyleSheetResourceClient> w(clients());
@@ -151,6 +155,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 +163,11 @@ void CSSStyleSheetResource::destroyDecodedDataIfPossible() {
return;
setParsedStyleSheetCache(nullptr);
- setDecodedSize(0);
}
void CSSStyleSheetResource::destroyDecodedDataForFailedRevalidation() {
m_decodedSheetText = String();
+ updateDecodedSize();
destroyDecodedDataIfPossible();
}
@@ -217,7 +222,13 @@ void CSSStyleSheetResource::saveParsedStyleSheet(StyleSheetContents* sheet) {
return;
}
setParsedStyleSheetCache(sheet);
- setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes());
+}
+
+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