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..0fc321841932358dc74d0871d2d21e358545f015 100644 |
| --- a/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp |
| +++ b/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp |
| @@ -77,6 +77,7 @@ void CSSStyleSheetResource::setParsedStyleSheetCache( |
| m_parsedStyleSheetCache = newSheet; |
| if (m_parsedStyleSheetCache) |
| m_parsedStyleSheetCache->setReferencedFromResource(this); |
|
kouhei (in TOK)
2016/11/07 09:29:39
Can we add a comment here:
// update decoded size
hiroshige
2016/11/07 09:36:06
Done.
|
| + updateDecodedSize(); |
| } |
| DEFINE_TRACE(CSSStyleSheetResource) { |
| @@ -136,6 +137,7 @@ void CSSStyleSheetResource::checkNotify() { |
| // Decode the data to find out the encoding and cache the decoded sheet text. |
| if (data()) { |
| m_decodedSheetText = decodedText(); |
| + updateDecodedSize(); |
| } |
| ResourceClientWalker<StyleSheetResourceClient> w(clients()); |
| @@ -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,11 @@ void CSSStyleSheetResource::destroyDecodedDataIfPossible() { |
| return; |
| setParsedStyleSheetCache(nullptr); |
| - setDecodedSize(0); |
| } |
| void CSSStyleSheetResource::destroyDecodedDataForFailedRevalidation() { |
| m_decodedSheetText = String(); |
| + updateDecodedSize(); |
|
kouhei (in TOK)
2016/11/07 09:29:39
Can we skip it here? destroyDecodedDataIfPossible
hiroshige
2016/11/07 09:36:07
I thought destroyDecodedDataIfPossible() doesn't c
kouhei (in TOK)
2016/11/07 09:57:42
Makes sense. lgtm
|
| destroyDecodedDataIfPossible(); |
| } |
| @@ -217,7 +220,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 |