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

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

Issue 1807323002: [WeakMemoryCache 1a] Make Reference from Inspector to Resource weak, remove removedFromMemoryCache() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove some comments Created 4 years, 7 months 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/CSSStyleSheetResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp b/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
index 91e27ac76e3550979bfbead8967394a2f501be7d..66090f422ccc49ad3c753a8f3c679cc740772035 100644
--- a/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
@@ -58,12 +58,18 @@ CSSStyleSheetResource::~CSSStyleSheetResource()
{
}
-void CSSStyleSheetResource::removedFromMemoryCache()
+void CSSStyleSheetResource::willDestroyResourceInternal()
{
+ setParsedStyleSheetCache(nullptr);
+}
+
+void CSSStyleSheetResource::setParsedStyleSheetCache(StyleSheetContents* newSheet)
+{
+ if (m_parsedStyleSheetCache)
+ m_parsedStyleSheetCache->setReferencedFromResource(false);
+ m_parsedStyleSheetCache = newSheet;
if (m_parsedStyleSheetCache)
- m_parsedStyleSheetCache->removedFromMemoryCache();
- m_parsedStyleSheetCache.clear();
- Resource::removedFromMemoryCache();
+ m_parsedStyleSheetCache->setReferencedFromResource(true);
}
DEFINE_TRACE(CSSStyleSheetResource)
@@ -121,9 +127,7 @@ void CSSStyleSheetResource::destroyDecodedDataIfPossible()
if (!m_parsedStyleSheetCache)
return;
- m_parsedStyleSheetCache->removedFromMemoryCache();
- m_parsedStyleSheetCache.clear();
-
+ setParsedStyleSheetCache(nullptr);
setDecodedSize(0);
}
@@ -150,13 +154,12 @@ StyleSheetContents* CSSStyleSheetResource::restoreParsedStyleSheet(const CSSPars
if (!m_parsedStyleSheetCache)
return nullptr;
if (m_parsedStyleSheetCache->hasFailedOrCanceledSubresources()) {
- m_parsedStyleSheetCache->removedFromMemoryCache();
- m_parsedStyleSheetCache.clear();
+ setParsedStyleSheetCache(nullptr);
return nullptr;
}
ASSERT(m_parsedStyleSheetCache->isCacheable());
- ASSERT(m_parsedStyleSheetCache->isInMemoryCache());
+ ASSERT(m_parsedStyleSheetCache->isReferencedFromResource());
// Contexts must be identical so we know we would get the same exact result if we parsed again.
if (m_parsedStyleSheetCache->parserContext() != context)
@@ -171,18 +174,13 @@ void CSSStyleSheetResource::saveParsedStyleSheet(StyleSheetContents* sheet)
{
ASSERT(sheet && sheet->isCacheable());
- if (m_parsedStyleSheetCache)
- m_parsedStyleSheetCache->removedFromMemoryCache();
-
if (!memoryCache()->contains(this)) {
// This stylesheet resource did conflict with another resource and was
// not added to the cache.
- m_parsedStyleSheetCache = nullptr;
+ setParsedStyleSheetCache(nullptr);
return;
}
- m_parsedStyleSheetCache = sheet;
- m_parsedStyleSheetCache->addedToMemoryCache();
-
+ setParsedStyleSheetCache(sheet);
setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes());
}
« no previous file with comments | « third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.h ('k') | third_party/WebKit/Source/core/fetch/MemoryCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698