Index: Source/core/fetch/Resource.cpp |
diff --git a/Source/core/fetch/Resource.cpp b/Source/core/fetch/Resource.cpp |
index fcbb7ce19a58503553f48890fe1d515554b2bdd0..e60ee341f51838a6314a8c22b4348ae09a831b84 100644 |
--- a/Source/core/fetch/Resource.cpp |
+++ b/Source/core/fetch/Resource.cpp |
@@ -364,6 +364,12 @@ bool Resource::unlock() |
return true; |
} |
+bool Resource::hasRightHandleCountApartFromCache(unsigned targetCount) |
+{ |
+ bool inCache = memoryCache()->contains(this); |
+ return (inCache && m_handleCount == targetCount + 1) || (!inCache && m_handleCount == targetCount); |
Philippe
2014/03/26 16:04:07
Nit: not sure this is more readable but in case yo
Philippe
2014/03/26 17:08:33
You might not even need the '!!' though. We usuall
clamy
2014/03/27 10:47:16
Done.
|
+} |
+ |
void Resource::responseReceived(const ResourceResponse& response) |
{ |
setResponse(response); |
@@ -403,6 +409,17 @@ void Resource::setCachedMetadata(unsigned dataTypeID, const char* data, size_t s |
blink::Platform::current()->cacheMetadata(m_response.url(), m_response.responseTime(), serializedData.data(), serializedData.size()); |
} |
+bool Resource::canDelete() |
+{ |
+ return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountApartFromCache(0) |
+ && !m_protectorCount && !m_resourceToRevalidate && !m_proxyResource; |
+} |
+ |
+bool Resource::hasOneHandleApartFromCache() |
+{ |
+ return hasRightHandleCountApartFromCache(1); |
+} |
+ |
CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const |
{ |
if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) |
@@ -771,6 +788,8 @@ void Resource::unregisterHandle(ResourcePtrBase* h) |
unlock(); |
} else if (m_handleCount == 1 && memoryCache()->contains(this)) { |
unlock(); |
+ if (!hasClients()) |
Philippe
2014/03/26 16:04:07
Nit: Do we still need this change?
clamy
2014/03/27 10:47:16
Yes this is what is making it work with the rebase
|
+ memoryCache()->prune(this); |
} |
} |