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) ...@@ -85,6 +85,13 @@ void MemoryCacheEntry::trace(Visitor* visitor)
visitor->trace(m_nextInAllResourcesList); visitor->trace(m_nextInAllResourcesList);
} }
#if ENABLE(OILPAN)
void MemoryCacheEntry::dispose()
{
m_resource.clear();
}
#endif
void MemoryCacheLRUList::trace(Visitor* visitor) void MemoryCacheLRUList::trace(Visitor* visitor)
{ {
visitor->trace(m_head); visitor->trace(m_head);
...@@ -372,11 +379,17 @@ bool MemoryCache::evict(MemoryCacheEntry* entry) ...@@ -372,11 +379,17 @@ bool MemoryCache::evict(MemoryCacheEntry* entry)
ResourceMap::iterator it = m_resources.find(resource->url()); ResourceMap::iterator it = m_resources.find(resource->url());
ASSERT(it != m_resources.end()); ASSERT(it != m_resources.end());
#if !ENABLE(OILPAN) #if ENABLE(OILPAN)
MemoryCacheEntry* entryPtr = it->value;
#else
OwnPtr<MemoryCacheEntry> entryPtr; OwnPtr<MemoryCacheEntry> entryPtr;
entryPtr.swap(it->value); entryPtr.swap(it->value);
#endif #endif
m_resources.remove(it); m_resources.remove(it);
#if ENABLE(OILPAN)
if (entryPtr)
entryPtr->dispose();
#endif
return canDelete; return canDelete;
} }
......
...@@ -74,8 +74,14 @@ enum UpdateReason { ...@@ -74,8 +74,14 @@ enum UpdateReason {
// from MemoryCacheLRUList. // from MemoryCacheLRUList.
class MemoryCacheEntry final : public NoBaseWillBeGarbageCollectedFinalized<MemoryCacheEntry> { class MemoryCacheEntry final : public NoBaseWillBeGarbageCollectedFinalized<MemoryCacheEntry> {
public: 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*); void trace(Visitor*);
#if ENABLE(OILPAN)
void dispose();
#endif
ResourcePtr<Resource> m_resource; ResourcePtr<Resource> m_resource;
bool m_inLiveDecodedResourcesList; 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