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

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: Created 4 years, 8 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 8aa33d13f76e3b233933654410925106089ba313..030b735cda2a257997ab3248274e2cba55ed3b3b 100644
--- a/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/CSSStyleSheetResource.cpp
@@ -28,7 +28,6 @@
#include "core/css/StyleSheetContents.h"
#include "core/fetch/FetchRequest.h"
-#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceClientOrObserverWalker.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/fetch/StyleSheetResourceClient.h"
@@ -58,12 +57,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 +126,7 @@ void CSSStyleSheetResource::destroyDecodedDataIfPossible()
if (!m_parsedStyleSheetCache)
return;
- m_parsedStyleSheetCache->removedFromMemoryCache();
- m_parsedStyleSheetCache.clear();
-
+ setParsedStyleSheetCache(nullptr);
setDecodedSize(0);
}
@@ -150,13 +153,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,16 +173,8 @@ void CSSStyleSheetResource::saveParsedStyleSheet(StyleSheetContents* sheet)
{
ASSERT(sheet && sheet->isCacheable());
- if (m_parsedStyleSheetCache)
- m_parsedStyleSheetCache->removedFromMemoryCache();
- m_parsedStyleSheetCache = sheet;
-
+ setParsedStyleSheetCache(sheet);
setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes());
-
- // Check if this stylesheet resource didn't conflict with
- // another resource and has indeed been added to the cache.
- if (memoryCache()->contains(this))
- m_parsedStyleSheetCache->addedToMemoryCache();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698