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

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

Issue 2066763002: [WeakMemoryCache] Remove Resource from MemoryCache just before destructed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.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/MemoryCache.cpp
diff --git a/third_party/WebKit/Source/core/fetch/MemoryCache.cpp b/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
index 8aad84ef9bff434fae49d13d63ca1421cd1fa296..925962d2e82aee962489dfa50439bf63dd3e1cdf 100644
--- a/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
+++ b/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
@@ -79,13 +79,21 @@ MemoryCacheEntry::MemoryCacheEntry(Resource* resource)
DEFINE_TRACE(MemoryCacheEntry)
{
visitor->trace(m_resource);
- visitor->trace(m_resourceWeak);
+ visitor->template registerWeakMembers<MemoryCacheEntry, &MemoryCacheEntry::clearResourceWeak>(this);
Nate Chapin 2016/06/20 21:54:17 I don't speak templates, and it stuns me that this
visitor->trace(m_previousInLiveResourcesList);
visitor->trace(m_nextInLiveResourcesList);
visitor->trace(m_previousInAllResourcesList);
visitor->trace(m_nextInAllResourcesList);
}
+void MemoryCacheEntry::clearResourceWeak(Visitor* visitor)
haraken 2016/06/15 08:21:05 This is not called when the MemoryCacheEntry is de
hiroshige 2016/06/15 11:53:41 It's OK (because MemoryCacheEntry is alive unless
+{
+ if (!m_resourceWeak || ThreadHeap::isHeapObjectAlive(m_resourceWeak))
+ return;
+ memoryCache()->remove(m_resourceWeak.get());
+ m_resourceWeak.clear();
+}
+
void MemoryCacheEntry::dispose()
{
m_resource.clear();
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698