| Index: Source/core/fetch/Resource.cpp
|
| diff --git a/Source/core/fetch/Resource.cpp b/Source/core/fetch/Resource.cpp
|
| index d0970510712f634412b9f6adf49856c0c7cb3540..e96ad6f42cb5466d12f1eaca56926a928c1e534d 100644
|
| --- a/Source/core/fetch/Resource.cpp
|
| +++ b/Source/core/fetch/Resource.cpp
|
| @@ -102,14 +102,12 @@ Resource::Resource(const ResourceRequest& request, Type type)
|
| , m_identifier(0)
|
| , m_encodedSize(0)
|
| , m_decodedSize(0)
|
| - , m_accessCount(0)
|
| , m_handleCount(0)
|
| , m_preloadCount(0)
|
| , m_protectorCount(0)
|
| , m_preloadResult(PreloadNotReferenced)
|
| , m_cacheLiveResourcePriority(CacheLiveResourcePriorityLow)
|
| , m_requestedFromNetworkingLayer(false)
|
| - , m_inCache(false)
|
| , m_loading(false)
|
| , m_switchingClientsToRevalidatedResource(false)
|
| , m_type(type)
|
| @@ -140,7 +138,7 @@ Resource::~Resource()
|
| {
|
| ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() checks this.
|
| ASSERT(canDelete());
|
| - RELEASE_ASSERT(!inCache());
|
| + RELEASE_ASSERT(!memoryCache()->contains(this));
|
| RELEASE_ASSERT(!ResourceCallback::callbackHandler()->isScheduled(this));
|
| ASSERT(!m_deleted);
|
| ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this);
|
| @@ -350,7 +348,7 @@ bool Resource::unlock()
|
| if (!m_data->isLocked())
|
| return true;
|
|
|
| - if (!inCache() || hasClients() || m_handleCount > 1 || m_proxyResource || m_resourceToRevalidate || !m_loadFinishTime || !isSafeToUnlock())
|
| + if (!memoryCache()->contains(this) || hasClients() || m_handleCount > 1 || m_proxyResource || m_resourceToRevalidate || !m_loadFinishTime || !isSafeToUnlock())
|
| return false;
|
|
|
| m_data->unlock();
|
| @@ -405,7 +403,7 @@ CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const
|
|
|
| void Resource::setCacheLiveResourcePriority(CacheLiveResourcePriority priority)
|
| {
|
| - if (inCache() && memoryCache()->isInLiveDecodedResourcesList(this) && cacheLiveResourcePriority() != static_cast<unsigned>(priority)) {
|
| + if (memoryCache()->contains(this) && memoryCache()->isInLiveDecodedResourcesList(this) && cacheLiveResourcePriority() != static_cast<unsigned>(priority)) {
|
| memoryCache()->removeFromLiveDecodedResourcesList(this);
|
| m_cacheLiveResourcePriority = priority;
|
| memoryCache()->insertInLiveDecodedResourcesList(this);
|
| @@ -461,7 +459,7 @@ bool Resource::addClientToSet(ResourceClient* client)
|
| else
|
| m_preloadResult = PreloadReferenced;
|
| }
|
| - if (!hasClients() && inCache())
|
| + if (!hasClients() && memoryCache()->contains(this))
|
| memoryCache()->addToLiveResourcesSize(this);
|
|
|
| // If we have existing data to send to the new client and the resource type supprts it, send it asynchronously.
|
| @@ -490,7 +488,7 @@ void Resource::removeClient(ResourceClient* client)
|
|
|
| bool deleted = deleteIfPossible();
|
| if (!deleted && !hasClients()) {
|
| - if (inCache()) {
|
| + if (memoryCache()->contains(this)) {
|
| memoryCache()->removeFromLiveResourcesSize(this);
|
| memoryCache()->removeFromLiveDecodedResourcesList(this);
|
| }
|
| @@ -536,7 +534,7 @@ void Resource::cancelTimerFired(Timer<Resource>* timer)
|
|
|
| bool Resource::deleteIfPossible()
|
| {
|
| - if (canDelete() && !inCache()) {
|
| + if (canDelete() && !memoryCache()->contains(this)) {
|
| InspectorInstrumentation::willDestroyResource(this);
|
| delete this;
|
| return true;
|
| @@ -544,25 +542,14 @@ bool Resource::deleteIfPossible()
|
| return false;
|
| }
|
|
|
| -void Resource::setDecodedSize(size_t size)
|
| +void Resource::setDecodedSize(size_t decodedSize)
|
| {
|
| - if (size == m_decodedSize)
|
| + if (decodedSize == m_decodedSize)
|
| return;
|
| + size_t oldSize = size();
|
| + m_decodedSize = decodedSize;
|
|
|
| - ptrdiff_t delta = size - m_decodedSize;
|
| -
|
| - // The object must now be moved to a different queue, since its size has been changed.
|
| - // We have to remove explicitly before updating m_decodedSize, so that we find the correct previous
|
| - // queue.
|
| - if (inCache())
|
| - memoryCache()->removeFromLRUList(this);
|
| -
|
| - m_decodedSize = size;
|
| -
|
| - if (inCache()) {
|
| - // Now insert into the new LRU list.
|
| - memoryCache()->insertInLRUList(this);
|
| -
|
| + if (memoryCache()->contains(this)) {
|
| // Insert into or remove from the live decoded list if necessary.
|
| // When inserting into the LiveDecodedResourcesList it is possible
|
| // that the m_lastDecodedAccessTime is still zero or smaller than
|
| @@ -576,38 +563,24 @@ void Resource::setDecodedSize(size_t size)
|
| memoryCache()->removeFromLiveDecodedResourcesList(this);
|
|
|
| // Update the cache's size totals.
|
| - memoryCache()->adjustSize(hasClients(), delta);
|
| + memoryCache()->update(this, oldSize, size());
|
| }
|
| }
|
|
|
| -void Resource::setEncodedSize(size_t size)
|
| +void Resource::setEncodedSize(size_t encodedSize)
|
| {
|
| - if (size == m_encodedSize)
|
| + if (encodedSize == m_encodedSize)
|
| return;
|
| -
|
| - ptrdiff_t delta = size - m_encodedSize;
|
| -
|
| - // The object must now be moved to a different queue, since its size has been changed.
|
| - // We have to remove explicitly before updating m_encodedSize, so that we find the correct previous
|
| - // queue.
|
| - if (inCache())
|
| - memoryCache()->removeFromLRUList(this);
|
| -
|
| - m_encodedSize = size;
|
| -
|
| - if (inCache()) {
|
| - // Now insert into the new LRU list.
|
| - memoryCache()->insertInLRUList(this);
|
| -
|
| - // Update the cache's size totals.
|
| - memoryCache()->adjustSize(hasClients(), delta);
|
| - }
|
| + size_t oldSize = size();
|
| + m_encodedSize = encodedSize;
|
| + if (memoryCache()->contains(this))
|
| + memoryCache()->update(this, oldSize, size());
|
| }
|
|
|
| void Resource::didAccessDecodedData(double timeStamp)
|
| {
|
| m_lastDecodedAccessTime = timeStamp;
|
| - if (inCache()) {
|
| + if (memoryCache()->contains(this)) {
|
| if (memoryCache()->isInLiveDecodedResourcesList(this)) {
|
| memoryCache()->removeFromLiveDecodedResourcesList(this);
|
| memoryCache()->insertInLiveDecodedResourcesList(this);
|
| @@ -670,8 +643,8 @@ void Resource::clearResourceToRevalidate()
|
| void Resource::switchClientsToRevalidatedResource()
|
| {
|
| ASSERT(m_resourceToRevalidate);
|
| - ASSERT(m_resourceToRevalidate->inCache());
|
| - ASSERT(!inCache());
|
| + ASSERT(memoryCache()->contains(m_resourceToRevalidate));
|
| + ASSERT(!memoryCache()->contains(this));
|
|
|
| WTF_LOG(ResourceLoading, "Resource %p switchClientsToRevalidatedResource %p", this, m_resourceToRevalidate);
|
|
|
| @@ -740,9 +713,9 @@ void Resource::updateResponseAfterRevalidation(const ResourceResponse& validatin
|
| void Resource::revalidationSucceeded(const ResourceResponse& response)
|
| {
|
| ASSERT(m_resourceToRevalidate);
|
| - ASSERT(!m_resourceToRevalidate->inCache());
|
| + ASSERT(!memoryCache()->contains(m_resourceToRevalidate));
|
| ASSERT(m_resourceToRevalidate->isLoaded());
|
| - ASSERT(inCache());
|
| + ASSERT(memoryCache()->contains(this));
|
|
|
| // Calling evict() can potentially delete revalidatingResource, which we use
|
| // below. This mustn't be the case since revalidation means it is loaded
|
| @@ -766,22 +739,6 @@ void Resource::revalidationFailed()
|
| clearResourceToRevalidate();
|
| }
|
|
|
| -void Resource::updateForAccess()
|
| -{
|
| - ASSERT(inCache());
|
| -
|
| - // Need to make sure to remove before we increase the access count, since
|
| - // the queue will possibly change.
|
| - memoryCache()->removeFromLRUList(this);
|
| -
|
| - // If this is the first time the resource has been accessed, adjust the size of the cache to account for its initial size.
|
| - if (!m_accessCount)
|
| - memoryCache()->adjustSize(hasClients(), size());
|
| -
|
| - m_accessCount++;
|
| - memoryCache()->insertInLRUList(this);
|
| -}
|
| -
|
| void Resource::registerHandle(ResourcePtrBase* h)
|
| {
|
| ++m_handleCount;
|
| @@ -801,7 +758,7 @@ void Resource::unregisterHandle(ResourcePtrBase* h)
|
| if (deleteIfPossible())
|
| return;
|
| unlock();
|
| - } else if (m_handleCount == 1 && inCache()) {
|
| + } else if (m_handleCount == 1 && memoryCache()->contains(this)) {
|
| unlock();
|
| }
|
| }
|
|
|