diff options
author | Ben Murdoch <benm@google.com> | 2010-10-22 13:02:20 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-10-26 15:21:41 +0100 |
commit | a94275402997c11dd2e778633dacf4b7e630a35d (patch) | |
tree | e66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/loader/CachedResource.cpp | |
parent | 09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff) | |
download | external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2 |
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/loader/CachedResource.cpp')
-rw-r--r-- | WebCore/loader/CachedResource.cpp | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/WebCore/loader/CachedResource.cpp b/WebCore/loader/CachedResource.cpp index a6ff0ff..e519c29 100644 --- a/WebCore/loader/CachedResource.cpp +++ b/WebCore/loader/CachedResource.cpp @@ -33,6 +33,7 @@ #include "Frame.h" #include "FrameLoaderClient.h" #include "KURL.h" +#include "Logging.h" #include "PurgeableBuffer.h" #include "Request.h" #include "ResourceHandle.h" @@ -350,6 +351,8 @@ void CachedResource::setResourceToRevalidate(CachedResource* resource) ASSERT(m_handlesToRevalidate.isEmpty()); ASSERT(resource->type() == type()); + LOG(ResourceLoading, "CachedResource %p setResourceToRevalidate %p", this, resource); + // The following assert should be investigated whenever it occurs. Although it should never fire, it currently does in rare circumstances. // https://bugs.webkit.org/show_bug.cgi?id=28604. // So the code needs to be robust to this assert failing thus the "if (m_resourceToRevalidate->m_proxyResource == this)" in CachedResource::clearResourceToRevalidate. @@ -378,6 +381,8 @@ void CachedResource::switchClientsToRevalidatedResource() ASSERT(m_resourceToRevalidate->inCache()); ASSERT(!inCache()); + LOG(ResourceLoading, "CachedResource %p switchClientsToRevalidatedResource %p", this, m_resourceToRevalidate); + HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end(); for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate.begin(); it != end; ++it) { CachedResourceHandleBase* handle = *it; @@ -428,6 +433,25 @@ void CachedResource::updateResponseAfterRevalidation(const ResourceResponse& val } } +void CachedResource::registerHandle(CachedResourceHandleBase* h) +{ + ++m_handleCount; + if (m_resourceToRevalidate) + m_handlesToRevalidate.add(h); +} + +void CachedResource::unregisterHandle(CachedResourceHandleBase* h) +{ + ASSERT(m_handleCount > 0); + --m_handleCount; + + if (m_resourceToRevalidate) + m_handlesToRevalidate.remove(h); + + if (!m_handleCount) + deleteIfPossible(); +} + bool CachedResource::canUseCacheValidator() const { if (m_loading || m_errorOccurred) @@ -443,19 +467,33 @@ bool CachedResource::canUseCacheValidator() const bool CachedResource::mustRevalidate(CachePolicy cachePolicy) const { - if (m_errorOccurred) + if (m_errorOccurred) { + LOG(ResourceLoading, "CachedResource %p mustRevalidate because of m_errorOccurred\n", this); return true; + } if (m_loading) return false; - if (m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()) + if (m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()) { + LOG(ResourceLoading, "CachedResource %p mustRevalidate because of m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()\n", this); return true; + } - if (cachePolicy == CachePolicyCache) - return m_response.cacheControlContainsMustRevalidate() && isExpired(); + if (cachePolicy == CachePolicyCache) { + if (m_response.cacheControlContainsMustRevalidate() && isExpired()) { + LOG(ResourceLoading, "CachedResource %p mustRevalidate because of cachePolicy == CachePolicyCache and m_response.cacheControlContainsMustRevalidate() && isExpired()\n", this); + return true; + } + return false; + } + + if (isExpired()) { + LOG(ResourceLoading, "CachedResource %p mustRevalidate because of isExpired()\n", this); + return true; + } - return isExpired(); + return false; } bool CachedResource::isSafeToMakePurgeable() const |