| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 cachedResourceLeakCounter.decrement(); | 255 cachedResourceLeakCounter.decrement(); |
| 256 #endif | 256 #endif |
| 257 | 257 |
| 258 if (m_owningCachedResourceLoader) | 258 if (m_owningCachedResourceLoader) |
| 259 m_owningCachedResourceLoader->removeCachedResource(this); | 259 m_owningCachedResourceLoader->removeCachedResource(this); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void CachedResource::failBeforeStarting() | 262 void CachedResource::failBeforeStarting() |
| 263 { | 263 { |
| 264 // FIXME: What if resources in other frames were waiting for this revalidati
on? | 264 // FIXME: What if resources in other frames were waiting for this revalidati
on? |
| 265 LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1().da
ta()); | 265 LOG_INFO(ResourceLoading, "Cannot start loading '%s'", url().string().latin1
().data()); |
| 266 if (m_resourceToRevalidate) | 266 if (m_resourceToRevalidate) |
| 267 memoryCache()->revalidationFailed(this); | 267 memoryCache()->revalidationFailed(this); |
| 268 error(CachedResource::LoadError); | 268 error(CachedResource::LoadError); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void CachedResource::addAdditionalRequestHeaders(CachedResourceLoader* cachedRes
ourceLoader) | 271 void CachedResource::addAdditionalRequestHeaders(CachedResourceLoader* cachedRes
ourceLoader) |
| 272 { | 272 { |
| 273 // Note: We skip the Content-Security-Policy check here because we check | 273 // Note: We skip the Content-Security-Policy check here because we check |
| 274 // the Content-Security-Policy at the CachedResourceLoader layer so we can | 274 // the Content-Security-Policy at the CachedResourceLoader layer so we can |
| 275 // handle different resource types differently. | 275 // handle different resource types differently. |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 690 } |
| 691 | 691 |
| 692 void CachedResource::setResourceToRevalidate(CachedResource* resource) | 692 void CachedResource::setResourceToRevalidate(CachedResource* resource) |
| 693 { | 693 { |
| 694 ASSERT(resource); | 694 ASSERT(resource); |
| 695 ASSERT(!m_resourceToRevalidate); | 695 ASSERT(!m_resourceToRevalidate); |
| 696 ASSERT(resource != this); | 696 ASSERT(resource != this); |
| 697 ASSERT(m_handlesToRevalidate.isEmpty()); | 697 ASSERT(m_handlesToRevalidate.isEmpty()); |
| 698 ASSERT(resource->type() == type()); | 698 ASSERT(resource->type() == type()); |
| 699 | 699 |
| 700 LOG(ResourceLoading, "CachedResource %p setResourceToRevalidate %p", this, r
esource); | 700 LOG_INFO(ResourceLoading, "CachedResource %p setResourceToRevalidate %p", th
is, resource); |
| 701 | 701 |
| 702 // The following assert should be investigated whenever it occurs. Although
it should never fire, it currently does in rare circumstances. | 702 // The following assert should be investigated whenever it occurs. Although
it should never fire, it currently does in rare circumstances. |
| 703 // https://bugs.webkit.org/show_bug.cgi?id=28604. | 703 // https://bugs.webkit.org/show_bug.cgi?id=28604. |
| 704 // So the code needs to be robust to this assert failing thus the "if (m_res
ourceToRevalidate->m_proxyResource == this)" in CachedResource::clearResourceToR
evalidate. | 704 // So the code needs to be robust to this assert failing thus the "if (m_res
ourceToRevalidate->m_proxyResource == this)" in CachedResource::clearResourceToR
evalidate. |
| 705 ASSERT(!resource->m_proxyResource); | 705 ASSERT(!resource->m_proxyResource); |
| 706 | 706 |
| 707 resource->m_proxyResource = this; | 707 resource->m_proxyResource = this; |
| 708 m_resourceToRevalidate = resource; | 708 m_resourceToRevalidate = resource; |
| 709 } | 709 } |
| 710 | 710 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 723 m_resourceToRevalidate = 0; | 723 m_resourceToRevalidate = 0; |
| 724 deleteIfPossible(); | 724 deleteIfPossible(); |
| 725 } | 725 } |
| 726 | 726 |
| 727 void CachedResource::switchClientsToRevalidatedResource() | 727 void CachedResource::switchClientsToRevalidatedResource() |
| 728 { | 728 { |
| 729 ASSERT(m_resourceToRevalidate); | 729 ASSERT(m_resourceToRevalidate); |
| 730 ASSERT(m_resourceToRevalidate->inCache()); | 730 ASSERT(m_resourceToRevalidate->inCache()); |
| 731 ASSERT(!inCache()); | 731 ASSERT(!inCache()); |
| 732 | 732 |
| 733 LOG(ResourceLoading, "CachedResource %p switchClientsToRevalidatedResource %
p", this, m_resourceToRevalidate); | 733 LOG_INFO(ResourceLoading, "CachedResource %p switchClientsToRevalidatedResou
rce %p", this, m_resourceToRevalidate); |
| 734 | 734 |
| 735 m_switchingClientsToRevalidatedResource = true; | 735 m_switchingClientsToRevalidatedResource = true; |
| 736 HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end
(); | 736 HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end
(); |
| 737 for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate
.begin(); it != end; ++it) { | 737 for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate
.begin(); it != end; ++it) { |
| 738 CachedResourceHandleBase* handle = *it; | 738 CachedResourceHandleBase* handle = *it; |
| 739 handle->m_resource = m_resourceToRevalidate; | 739 handle->m_resource = m_resourceToRevalidate; |
| 740 m_resourceToRevalidate->registerHandle(handle); | 740 m_resourceToRevalidate->registerHandle(handle); |
| 741 --m_handleCount; | 741 --m_handleCount; |
| 742 } | 742 } |
| 743 ASSERT(!m_handleCount); | 743 ASSERT(!m_handleCount); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 822 } |
| 823 | 823 |
| 824 bool CachedResource::mustRevalidateDueToCacheHeaders(CachePolicy cachePolicy) co
nst | 824 bool CachedResource::mustRevalidateDueToCacheHeaders(CachePolicy cachePolicy) co
nst |
| 825 { | 825 { |
| 826 ASSERT(cachePolicy == CachePolicyRevalidate || cachePolicy == CachePolicyCac
he || cachePolicy == CachePolicyVerify); | 826 ASSERT(cachePolicy == CachePolicyRevalidate || cachePolicy == CachePolicyCac
he || cachePolicy == CachePolicyVerify); |
| 827 | 827 |
| 828 if (cachePolicy == CachePolicyRevalidate) | 828 if (cachePolicy == CachePolicyRevalidate) |
| 829 return true; | 829 return true; |
| 830 | 830 |
| 831 if (m_response.cacheControlContainsNoCache() || m_response.cacheControlConta
insNoStore()) { | 831 if (m_response.cacheControlContainsNoCache() || m_response.cacheControlConta
insNoStore()) { |
| 832 LOG(ResourceLoading, "CachedResource %p mustRevalidate because of m_resp
onse.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()\n
", this); | 832 LOG_INFO(ResourceLoading, "CachedResource %p mustRevalidate because of m
_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStor
e()\n", this); |
| 833 return true; | 833 return true; |
| 834 } | 834 } |
| 835 | 835 |
| 836 if (cachePolicy == CachePolicyCache) { | 836 if (cachePolicy == CachePolicyCache) { |
| 837 if (m_response.cacheControlContainsMustRevalidate() && isExpired()) { | 837 if (m_response.cacheControlContainsMustRevalidate() && isExpired()) { |
| 838 LOG(ResourceLoading, "CachedResource %p mustRevalidate because of ca
chePolicy == CachePolicyCache and m_response.cacheControlContainsMustRevalidate(
) && isExpired()\n", this); | 838 LOG_INFO(ResourceLoading, "CachedResource %p mustRevalidate because
of cachePolicy == CachePolicyCache and m_response.cacheControlContainsMustRevali
date() && isExpired()\n", this); |
| 839 return true; | 839 return true; |
| 840 } | 840 } |
| 841 return false; | 841 return false; |
| 842 } | 842 } |
| 843 | 843 |
| 844 // CachePolicyVerify | 844 // CachePolicyVerify |
| 845 if (isExpired()) { | 845 if (isExpired()) { |
| 846 LOG(ResourceLoading, "CachedResource %p mustRevalidate because of isExpi
red()\n", this); | 846 LOG_INFO(ResourceLoading, "CachedResource %p mustRevalidate because of i
sExpired()\n", this); |
| 847 return true; | 847 return true; |
| 848 } | 848 } |
| 849 | 849 |
| 850 return false; | 850 return false; |
| 851 } | 851 } |
| 852 | 852 |
| 853 bool CachedResource::isSafeToMakePurgeable() const | 853 bool CachedResource::isSafeToMakePurgeable() const |
| 854 { | 854 { |
| 855 return !hasClients() && !m_proxyResource && !m_resourceToRevalidate; | 855 return !hasClients() && !m_proxyResource && !m_resourceToRevalidate; |
| 856 } | 856 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 // Because the disk cache is asynchronous and racey with regards to the data
we might be asked to replace, | 978 // Because the disk cache is asynchronous and racey with regards to the data
we might be asked to replace, |
| 979 // we need to verify that the new buffer has the same contents as our old bu
ffer. | 979 // we need to verify that the new buffer has the same contents as our old bu
ffer. |
| 980 if (m_data->size() != newBuffer->size() || memcmp(m_data->data(), newBuffer-
>data(), m_data->size())) | 980 if (m_data->size() != newBuffer->size() || memcmp(m_data->data(), newBuffer-
>data(), m_data->size())) |
| 981 return; | 981 return; |
| 982 | 982 |
| 983 m_data->tryReplaceSharedBufferContents(newBuffer.get()); | 983 m_data->tryReplaceSharedBufferContents(newBuffer.get()); |
| 984 } | 984 } |
| 985 #endif | 985 #endif |
| 986 | 986 |
| 987 } | 987 } |
| OLD | NEW |