Chromium Code Reviews| 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 |