Commit 9ada122f authored by sigbjornf@opera.com's avatar sigbjornf@opera.com

Oilpan: eager resource disposal on MemoryCache eviction.

Promptly let go of a memory cache entry's Resource when evicting it,
and do not wait until the next GC to strike. This provides the same
behavior & lifetime for the resource as non-Oilpan.

R=mkwst
BUG=420068

Review URL: https://codereview.chromium.org/649213002

git-svn-id: svn://svn.chromium.org/blink/trunk@183606 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b1e55eef
......@@ -85,6 +85,13 @@ void MemoryCacheEntry::trace(Visitor* visitor)
visitor->trace(m_nextInAllResourcesList);
}
#if ENABLE(OILPAN)
void MemoryCacheEntry::dispose()
{
m_resource.clear();
}
#endif
void MemoryCacheLRUList::trace(Visitor* visitor)
{
visitor->trace(m_head);
......@@ -372,11 +379,17 @@ bool MemoryCache::evict(MemoryCacheEntry* entry)
ResourceMap::iterator it = m_resources.find(resource->url());
ASSERT(it != m_resources.end());
#if !ENABLE(OILPAN)
#if ENABLE(OILPAN)
MemoryCacheEntry* entryPtr = it->value;
#else
OwnPtr<MemoryCacheEntry> entryPtr;
entryPtr.swap(it->value);
#endif
m_resources.remove(it);
#if ENABLE(OILPAN)
if (entryPtr)
entryPtr->dispose();
#endif
return canDelete;
}
......
......@@ -74,8 +74,14 @@ enum UpdateReason {
// from MemoryCacheLRUList.
class MemoryCacheEntry final : public NoBaseWillBeGarbageCollectedFinalized<MemoryCacheEntry> {
public:
static PassOwnPtrWillBeRawPtr<MemoryCacheEntry> create(Resource* resource) { return adoptPtrWillBeNoop(new MemoryCacheEntry(resource)); }
static PassOwnPtrWillBeRawPtr<MemoryCacheEntry> create(Resource* resource)
{
return adoptPtrWillBeNoop(new MemoryCacheEntry(resource));
}
void trace(Visitor*);
#if ENABLE(OILPAN)
void dispose();
#endif
ResourcePtr<Resource> m_resource;
bool m_inLiveDecodedResourcesList;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment