Title: [182064] trunk/Source/WebCore
Revision
182064
Author
[email protected]
Date
2015-03-27 09:49:21 -0700 (Fri, 27 Mar 2015)

Log Message

Move CacheValidation to platform
https://bugs.webkit.org/show_bug.cgi?id=143133

Reviewed by Chris Dumez.

It deals with platform types only and is currently violating layering.

* WebCore.xcodeproj/project.pbxproj:
* loader/cache/CacheValidation.cpp: Removed.
* loader/cache/CacheValidation.h: Removed.
* platform/network/CacheValidation.cpp: Copied from Source/WebCore/loader/cache/CacheValidation.cpp.
* platform/network/CacheValidation.h: Copied from Source/WebCore/loader/cache/CacheValidation.h.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (182063 => 182064)


--- trunk/Source/WebCore/CMakeLists.txt	2015-03-27 16:42:16 UTC (rev 182063)
+++ trunk/Source/WebCore/CMakeLists.txt	2015-03-27 16:49:21 UTC (rev 182064)
@@ -1888,7 +1888,6 @@
     loader/cache/CachedSVGDocumentReference.cpp
     loader/cache/CachedScript.cpp
     loader/cache/CachedXSLStyleSheet.cpp
-    loader/cache/CacheValidation.cpp
     loader/cache/MemoryCache.cpp
 
     loader/icon/IconController.cpp
@@ -2212,6 +2211,7 @@
     platform/network/BlobRegistry.cpp
     platform/network/BlobRegistryImpl.cpp
     platform/network/BlobResourceHandle.cpp
+    platform/network/CacheValidation.cpp
     platform/network/CredentialBase.cpp
     platform/network/CredentialStorage.cpp
     platform/network/DNSResolveQueue.cpp

Modified: trunk/Source/WebCore/ChangeLog (182063 => 182064)


--- trunk/Source/WebCore/ChangeLog	2015-03-27 16:42:16 UTC (rev 182063)
+++ trunk/Source/WebCore/ChangeLog	2015-03-27 16:49:21 UTC (rev 182064)
@@ -1,3 +1,18 @@
+2015-03-27  Antti Koivisto  <[email protected]>
+
+        Move CacheValidation to platform
+        https://bugs.webkit.org/show_bug.cgi?id=143133
+
+        Reviewed by Chris Dumez.
+
+        It deals with platform types only and is currently violating layering.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/cache/CacheValidation.cpp: Removed.
+        * loader/cache/CacheValidation.h: Removed.
+        * platform/network/CacheValidation.cpp: Copied from Source/WebCore/loader/cache/CacheValidation.cpp.
+        * platform/network/CacheValidation.h: Copied from Source/WebCore/loader/cache/CacheValidation.h.
+
 2015-03-27  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r177896.

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (182063 => 182064)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2015-03-27 16:42:16 UTC (rev 182063)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2015-03-27 16:49:21 UTC (rev 182064)
@@ -7357,7 +7357,6 @@
     <ClCompile Include="..\loader\cache\CachedSVGDocumentReference.cpp" />
     <ClCompile Include="..\loader\cache\CachedTextTrack.cpp" />
     <ClCompile Include="..\loader\cache\CachedXSLStyleSheet.cpp" />
-    <ClCompile Include="..\loader\cache\CacheValidation.cpp" />
     <ClCompile Include="..\loader\cache\MemoryCache.cpp" />
     <ClCompile Include="..\platform\audio\AudioHardwareListener.cpp" />
     <ClCompile Include="..\platform\CalculationValue.cpp" />
@@ -8680,6 +8679,7 @@
     <ClCompile Include="..\platform\network\BlobResourceHandle.cpp" />
     <ClCompile Include="..\platform\network\BlobRegistry.cpp" />
     <ClCompile Include="..\platform\network\BlobRegistryImpl.cpp" />
+    <ClCompile Include="..\platform\network\CacheValidation.cpp" />
     <ClCompile Include="..\platform\network\CredentialBase.cpp" />
     <ClCompile Include="..\platform\network\CredentialStorage.cpp" />
     <ClCompile Include="..\platform\network\DataURL.cpp" />
@@ -19421,7 +19421,6 @@
     <ClInclude Include="..\loader\cache\CachedTextTrack.h" />
     <ClInclude Include="..\loader\cache\CachedXSLStyleSheet.h" />
     <ClInclude Include="..\loader\cache\CachePolicy.h" />
-    <ClInclude Include="..\loader\cache\CacheValidation.h" />
     <ClInclude Include="..\loader\cache\MemoryCache.h" />
     <ClInclude Include="..\platform\audio\AudioHardwareListener.h" />
     <ClInclude Include="..\platform\CalculationValue.h" />
@@ -19889,6 +19888,7 @@
     <ClInclude Include="..\platform\network\BlobRegistryImpl.h" />
     <ClInclude Include="..\platform\network\BlobResourceHandle.h" />
     <ClInclude Include="..\platform\network\CookieStorage.h" />
+    <ClInclude Include="..\platform\network\CacheValidation.h" />
     <ClInclude Include="..\platform\network\Credential.h" />
     <ClInclude Include="..\platform\network\CredentialBase.h" />
     <ClInclude Include="..\platform\network\CredentialStorage.h" />

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (182063 => 182064)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-03-27 16:42:16 UTC (rev 182063)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2015-03-27 16:49:21 UTC (rev 182064)
@@ -6206,6 +6206,8 @@
 		E43105BB16750F1600DB2FB8 /* NodeTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E43105BA16750F1600DB2FB8 /* NodeTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E43A023B17EB370A004CDD25 /* RenderElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E43A023A17EB370A004CDD25 /* RenderElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E43A023D17EB3713004CDD25 /* RenderElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43A023C17EB3713004CDD25 /* RenderElement.cpp */; };
+		E43AF8E61AC5B7E800CA717E /* CacheValidation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43AF8E41AC5B7DD00CA717E /* CacheValidation.cpp */; };
+		E43AF8E71AC5B7EC00CA717E /* CacheValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E43AF8E51AC5B7DD00CA717E /* CacheValidation.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E44613A10CD6331000FADA75 /* HTMLAudioElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */; };
 		E44613A20CD6331000FADA75 /* HTMLAudioElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613900CD6331000FADA75 /* HTMLAudioElement.h */; };
 		E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44613920CD6331000FADA75 /* HTMLMediaElement.cpp */; };
@@ -6254,8 +6256,6 @@
 		E453904D0EAFD637003695C8 /* WidgetIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = E453903C0EAFD637003695C8 /* WidgetIOS.mm */; };
 		E45390AE0EAFF4B5003695C8 /* SystemMemoryIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */; };
 		E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		E467680E1A0177EE00B9E26B /* CacheValidation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E467680D1A0177EE00B9E26B /* CacheValidation.cpp */; };
-		E46768101A0177F900B9E26B /* CacheValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E467680F1A0177F900B9E26B /* CacheValidation.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E47127CA163438A100ED6F5A /* StyleInvalidationAnalysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47A97CE163059FC005DCD99 /* StyleInvalidationAnalysis.cpp */; };
@@ -13808,6 +13808,8 @@
 		E43105BA16750F1600DB2FB8 /* NodeTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeTraversal.h; sourceTree = "<group>"; };
 		E43A023A17EB370A004CDD25 /* RenderElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderElement.h; sourceTree = "<group>"; };
 		E43A023C17EB3713004CDD25 /* RenderElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderElement.cpp; sourceTree = "<group>"; };
+		E43AF8E41AC5B7DD00CA717E /* CacheValidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheValidation.cpp; sourceTree = "<group>"; };
+		E43AF8E51AC5B7DD00CA717E /* CacheValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheValidation.h; sourceTree = "<group>"; };
 		E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLAudioElement.cpp; sourceTree = "<group>"; };
 		E44613900CD6331000FADA75 /* HTMLAudioElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLAudioElement.h; sourceTree = "<group>"; };
 		E44613910CD6331000FADA75 /* HTMLAudioElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLAudioElement.idl; sourceTree = "<group>"; };
@@ -13848,8 +13850,6 @@
 		E453903C0EAFD637003695C8 /* WidgetIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WidgetIOS.mm; path = ios/WidgetIOS.mm; sourceTree = "<group>"; };
 		E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemMemoryIOS.cpp; path = ios/SystemMemoryIOS.cpp; sourceTree = "<group>"; };
 		E462A4A0113E71BE004A4220 /* IntPointHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntPointHash.h; sourceTree = "<group>"; };
-		E467680D1A0177EE00B9E26B /* CacheValidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CacheValidation.cpp; path = loader/cache/CacheValidation.cpp; sourceTree = SOURCE_ROOT; };
-		E467680F1A0177F900B9E26B /* CacheValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CacheValidation.h; path = loader/cache/CacheValidation.h; sourceTree = SOURCE_ROOT; };
 		E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedElementDescendantIterator.h; sourceTree = "<group>"; };
 		E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementChildIterator.h; sourceTree = "<group>"; };
 		E4778B7D115A581A00B5D372 /* JSCustomEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomEvent.cpp; sourceTree = "<group>"; };
@@ -16573,6 +16573,8 @@
 				2EDEF1F1121B0EFC00726DB2 /* BlobRegistryImpl.h */,
 				2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */,
 				2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */,
+				E43AF8E41AC5B7DD00CA717E /* CacheValidation.cpp */,
+				E43AF8E51AC5B7DD00CA717E /* CacheValidation.h */,
 				E13F01EA1270E10D00DFBA71 /* CookieStorage.h */,
 				514C76590CE923A1007EF3CD /* Credential.h */,
 				514C76580CE923A1007EF3CD /* CredentialBase.cpp */,
@@ -19833,8 +19835,6 @@
 				BCB16C0E0979C3BD00467741 /* CachedXSLStyleSheet.cpp */,
 				BCB16C0F0979C3BD00467741 /* CachedXSLStyleSheet.h */,
 				F587864902DE3A9A01EA4122 /* CachePolicy.h */,
-				E467680D1A0177EE00B9E26B /* CacheValidation.cpp */,
-				E467680F1A0177F900B9E26B /* CacheValidation.h */,
 				BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */,
 				BCB16BFF0979C3BD00467741 /* MemoryCache.h */,
 				1C0939E81A13E12900B788E5 /* CachedSVGFont.cpp */,
@@ -23807,7 +23807,6 @@
 				0753860314489E9800B78452 /* CachedTextTrack.h in Headers */,
 				BCB16C280979C3BD00467741 /* CachedXSLStyleSheet.h in Headers */,
 				93F1995008245E59001E9ABC /* CachePolicy.h in Headers */,
-				E46768101A0177F900B9E26B /* CacheValidation.h in Headers */,
 				49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */,
 				B1D5ECB5134B58DA0087C78F /* CallbackFunction.h in Headers */,
 				6E4E91AD10F7FB3100A2779C /* CanvasContextAttributes.h in Headers */,
@@ -25331,6 +25330,7 @@
 				AA7FEEA716A4E6F3004C0C33 /* JSSpeechSynthesisUtterance.h in Headers */,
 				AA7FEEA916A4E6F3004C0C33 /* JSSpeechSynthesisVoice.h in Headers */,
 				BC8243290D0CE8A200460C8F /* JSSQLError.h in Headers */,
+				E43AF8E71AC5B7EC00CA717E /* CacheValidation.h in Headers */,
 				B525A96511CA2340003A23A8 /* JSSQLException.h in Headers */,
 				1AE82FED0CAB07EE002237AE /* JSSQLResultSet.h in Headers */,
 				1AFE119A0CBFFCC4003017FA /* JSSQLResultSetRowList.h in Headers */,
@@ -27549,7 +27549,6 @@
 				E1B533471717D0A100F205F9 /* CachedSVGDocumentReference.cpp in Sources */,
 				0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */,
 				BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */,
-				E467680E1A0177EE00B9E26B /* CacheValidation.cpp in Sources */,
 				49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */,
 				B1827493134CA4C100B98C2D /* CallbackFunction.cpp in Sources */,
 				6E4E91AC10F7FB3100A2779C /* CanvasContextAttributes.cpp in Sources */,
@@ -29537,6 +29536,7 @@
 				A454424E119B3687009BE912 /* RenderMeter.cpp in Sources */,
 				1A3586DF15264C450022A659 /* RenderMultiColumnFlowThread.cpp in Sources */,
 				BCE32B9E1517C22700F542EC /* RenderMultiColumnSet.cpp in Sources */,
+				E43AF8E61AC5B7E800CA717E /* CacheValidation.cpp in Sources */,
 				BC1A7D9718FCB5B000421879 /* RenderMultiColumnSpannerPlaceholder.cpp in Sources */,
 				8AC822FC180FC03300FB64D5 /* RenderNamedFlowFragment.cpp in Sources */,
 				1A3FF9C315265359002288A1 /* RenderNamedFlowThread.cpp in Sources */,

Deleted: trunk/Source/WebCore/loader/cache/CacheValidation.cpp (182063 => 182064)


--- trunk/Source/WebCore/loader/cache/CacheValidation.cpp	2015-03-27 16:42:16 UTC (rev 182063)
+++ trunk/Source/WebCore/loader/cache/CacheValidation.cpp	2015-03-27 16:49:21 UTC (rev 182064)
@@ -1,293 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CacheValidation.h"
-
-#include "HTTPHeaderMap.h"
-#include "ResourceResponse.h"
-#include <wtf/CurrentTime.h>
-
-namespace WebCore {
-
-// These response headers are not copied from a revalidated response to the
-// cached response headers. For compatibility, this list is based on Chromium's
-// net/http/http_response_headers.cc.
-const char* const headersToIgnoreAfterRevalidation[] = {
-    "allow",
-    "connection",
-    "etag",
-    "expires",
-    "keep-alive",
-    "last-modified"
-    "proxy-authenticate",
-    "proxy-connection",
-    "trailer",
-    "transfer-encoding",
-    "upgrade",
-    "www-authenticate",
-    "x-frame-options",
-    "x-xss-protection",
-};
-
-// Some header prefixes mean "Don't copy this header from a 304 response.".
-// Rather than listing all the relevant headers, we can consolidate them into
-// this list, also grabbed from Chromium's net/http/http_response_headers.cc.
-const char* const headerPrefixesToIgnoreAfterRevalidation[] = {
-    "content-",
-    "x-content-",
-    "x-webkit-"
-};
-
-static inline bool shouldUpdateHeaderAfterRevalidation(const String& header)
-{
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(headersToIgnoreAfterRevalidation); i++) {
-        if (equalIgnoringCase(header, headersToIgnoreAfterRevalidation[i]))
-            return false;
-    }
-    for (size_t i = 0; i < WTF_ARRAY_LENGTH(headerPrefixesToIgnoreAfterRevalidation); i++) {
-        if (header.startsWith(headerPrefixesToIgnoreAfterRevalidation[i], false))
-            return false;
-    }
-    return true;
-}
-
-void updateResponseHeadersAfterRevalidation(ResourceResponse& response, const ResourceResponse& validatingResponse)
-{
-    // RFC2616 10.3.5
-    // Update cached headers from the 304 response
-    for (const auto& header : validatingResponse.httpHeaderFields()) {
-        // Entity headers should not be sent by servers when generating a 304
-        // response; misconfigured servers send them anyway. We shouldn't allow
-        // such headers to update the original request. We'll base this on the
-        // list defined by RFC2616 7.1, with a few additions for extension headers
-        // we care about.
-        if (!shouldUpdateHeaderAfterRevalidation(header.key))
-            continue;
-        response.setHTTPHeaderField(header.key, header.value);
-    }
-}
-
-double computeCurrentAge(const ResourceResponse& response, double responseTimestamp)
-{
-    // RFC2616 13.2.3
-    // No compensation for latency as that is not terribly important in practice
-    double dateValue = response.date();
-    double apparentAge = std::isfinite(dateValue) ? std::max(0., responseTimestamp - dateValue) : 0;
-    double ageValue = response.age();
-    double correctedReceivedAge = std::isfinite(ageValue) ? std::max(apparentAge, ageValue) : apparentAge;
-    double residentTime = currentTime() - responseTimestamp;
-    return correctedReceivedAge + residentTime;
-}
-
-double computeFreshnessLifetimeForHTTPFamily(const ResourceResponse& response, double responseTimestamp)
-{
-    ASSERT(response.url().protocolIsInHTTPFamily());
-    // RFC2616 13.2.4
-    double maxAgeValue = response.cacheControlMaxAge();
-    if (std::isfinite(maxAgeValue))
-        return maxAgeValue;
-    double expiresValue = response.expires();
-    double dateValue = response.date();
-    double creationTime = std::isfinite(dateValue) ? dateValue : responseTimestamp;
-    if (std::isfinite(expiresValue))
-        return expiresValue - creationTime;
-    double lastModifiedValue = response.lastModified();
-    if (std::isfinite(lastModifiedValue))
-        return (creationTime - lastModifiedValue) * 0.1;
-    // If no cache headers are present, the specification leaves the decision to the UA. Other browsers seem to opt for 0.
-    return 0;
-}
-
-void updateRedirectChainStatus(RedirectChainCacheStatus& redirectChainCacheStatus, const ResourceResponse& response)
-{
-    if (redirectChainCacheStatus.status == RedirectChainCacheStatus::NotCachedRedirection)
-        return;
-    if (response.cacheControlContainsNoStore() || response.cacheControlContainsNoCache() || response.cacheControlContainsMustRevalidate()) {
-        redirectChainCacheStatus.status = RedirectChainCacheStatus::NotCachedRedirection;
-        return;
-    }
-    redirectChainCacheStatus.status = RedirectChainCacheStatus::CachedRedirection;
-    double responseTimestamp = currentTime();
-    // Store the nearest end of cache validity date
-    double endOfValidity = responseTimestamp + computeFreshnessLifetimeForHTTPFamily(response, responseTimestamp) - computeCurrentAge(response, responseTimestamp);
-    redirectChainCacheStatus.endOfValidity = std::min(redirectChainCacheStatus.endOfValidity, endOfValidity);
-}
-
-bool redirectChainAllowsReuse(RedirectChainCacheStatus redirectChainCacheStatus, ReuseExpiredRedirectionOrNot reuseExpiredRedirection)
-{
-    switch (redirectChainCacheStatus.status) {
-    case RedirectChainCacheStatus::NoRedirection:
-        return true;
-    case RedirectChainCacheStatus::NotCachedRedirection:
-        return false;
-    case RedirectChainCacheStatus::CachedRedirection:
-        return reuseExpiredRedirection || currentTime() <= redirectChainCacheStatus.endOfValidity;
-    }
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
-inline bool isCacheHeaderSeparator(UChar c)
-{
-    // See RFC 2616, Section 2.2
-    switch (c) {
-    case '(':
-    case ')':
-    case '<':
-    case '>':
-    case '@':
-    case ',':
-    case ';':
-    case ':':
-    case '\\':
-    case '"':
-    case '/':
-    case '[':
-    case ']':
-    case '?':
-    case '=':
-    case '{':
-    case '}':
-    case ' ':
-    case '\t':
-        return true;
-    default:
-        return false;
-    }
-}
-
-inline bool isControlCharacter(UChar c)
-{
-    return c < ' ' || c == 127;
-}
-
-inline String trimToNextSeparator(const String& str)
-{
-    return str.substring(0, str.find(isCacheHeaderSeparator));
-}
-
-static Vector<std::pair<String, String>> parseCacheHeader(const String& header)
-{
-    Vector<std::pair<String, String>> result;
-
-    const String safeHeader = header.removeCharacters(isControlCharacter);
-    unsigned max = safeHeader.length();
-    unsigned pos = 0;
-    while (pos < max) {
-        size_t nextCommaPosition = safeHeader.find(',', pos);
-        size_t nextEqualSignPosition = safeHeader.find('=', pos);
-        if (nextEqualSignPosition == notFound && nextCommaPosition == notFound) {
-            // Add last directive to map with empty string as value
-            result.append(std::make_pair(trimToNextSeparator(safeHeader.substring(pos, max - pos).stripWhiteSpace()), ""));
-            return result;
-        }
-        if (nextCommaPosition != notFound && (nextCommaPosition < nextEqualSignPosition || nextEqualSignPosition == notFound)) {
-            // Add directive to map with empty string as value
-            result.append(std::make_pair(trimToNextSeparator(safeHeader.substring(pos, nextCommaPosition - pos).stripWhiteSpace()), ""));
-            pos += nextCommaPosition - pos + 1;
-            continue;
-        }
-        // Get directive name, parse right hand side of equal sign, then add to map
-        String directive = trimToNextSeparator(safeHeader.substring(pos, nextEqualSignPosition - pos).stripWhiteSpace());
-        pos += nextEqualSignPosition - pos + 1;
-
-        String value = safeHeader.substring(pos, max - pos).stripWhiteSpace();
-        if (value[0] == '"') {
-            // The value is a quoted string
-            size_t nextDoubleQuotePosition = value.find('"', 1);
-            if (nextDoubleQuotePosition == notFound) {
-                // Parse error; just use the rest as the value
-                result.append(std::make_pair(directive, trimToNextSeparator(value.substring(1, value.length() - 1).stripWhiteSpace())));
-                return result;
-            }
-            // Store the value as a quoted string without quotes
-            result.append(std::make_pair(directive, value.substring(1, nextDoubleQuotePosition - 1).stripWhiteSpace()));
-            pos += (safeHeader.find('"', pos) - pos) + nextDoubleQuotePosition + 1;
-            // Move past next comma, if there is one
-            size_t nextCommaPosition2 = safeHeader.find(',', pos);
-            if (nextCommaPosition2 == notFound)
-                return result; // Parse error if there is anything left with no comma
-            pos += nextCommaPosition2 - pos + 1;
-            continue;
-        }
-        // The value is a token until the next comma
-        size_t nextCommaPosition2 = value.find(',');
-        if (nextCommaPosition2 == notFound) {
-            // The rest is the value; no change to value needed
-            result.append(std::make_pair(directive, trimToNextSeparator(value)));
-            return result;
-        }
-        // The value is delimited by the next comma
-        result.append(std::make_pair(directive, trimToNextSeparator(value.substring(0, nextCommaPosition2).stripWhiteSpace())));
-        pos += (safeHeader.find(',', pos) - pos) + 1;
-    }
-    return result;
-}
-
-CacheControlDirectives parseCacheControlDirectives(const HTTPHeaderMap& headers)
-{
-    CacheControlDirectives result;
-
-    String cacheControlValue = headers.get(HTTPHeaderName::CacheControl);
-    if (!cacheControlValue.isEmpty()) {
-        auto directives = parseCacheHeader(cacheControlValue);
-
-        size_t directivesSize = directives.size();
-        for (size_t i = 0; i < directivesSize; ++i) {
-            // RFC2616 14.9.1: A no-cache directive with a value is only meaningful for proxy caches.
-            // It should be ignored by a browser level cache.
-            if (equalIgnoringCase(directives[i].first, "no-cache") && directives[i].second.isEmpty())
-                result.noCache = true;
-            else if (equalIgnoringCase(directives[i].first, "no-store"))
-                result.noStore = true;
-            else if (equalIgnoringCase(directives[i].first, "must-revalidate"))
-                result.mustRevalidate = true;
-            else if (equalIgnoringCase(directives[i].first, "max-age")) {
-                if (!std::isnan(result.maxAge)) {
-                    // First max-age directive wins if there are multiple ones.
-                    continue;
-                }
-                bool ok;
-                double maxAge = directives[i].second.toDouble(&ok);
-                if (ok)
-                    result.maxAge = maxAge;
-            }
-        }
-    }
-
-    if (!result.noCache) {
-        // Handle Pragma: no-cache
-        // This is deprecated and equivalent to Cache-control: no-cache
-        // Don't bother tokenizing the value, it is not important
-        String pragmaValue = headers.get(HTTPHeaderName::Pragma);
-
-        result.noCache = pragmaValue.contains("no-cache", false);
-    }
-
-    return result;
-}
-
-}

Deleted: trunk/Source/WebCore/loader/cache/CacheValidation.h (182063 => 182064)


--- trunk/Source/WebCore/loader/cache/CacheValidation.h	2015-03-27 16:42:16 UTC (rev 182063)
+++ trunk/Source/WebCore/loader/cache/CacheValidation.h	2015-03-27 16:49:21 UTC (rev 182064)
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CacheValidation_h
-#define CacheValidation_h
-
-namespace WebCore {
-
-class HTTPHeaderMap;
-class ResourceResponse;
-
-struct RedirectChainCacheStatus {
-    enum Status {
-        NoRedirection,
-        NotCachedRedirection,
-        CachedRedirection
-    };
-    RedirectChainCacheStatus()
-        : status(NoRedirection)
-        , endOfValidity(std::numeric_limits<double>::max())
-    { }
-    Status status;
-    double endOfValidity;
-};
-
-WEBCORE_EXPORT double computeCurrentAge(const ResourceResponse&, double responseTimestamp);
-WEBCORE_EXPORT double computeFreshnessLifetimeForHTTPFamily(const ResourceResponse&, double responseTimestamp);
-WEBCORE_EXPORT void updateResponseHeadersAfterRevalidation(ResourceResponse&, const ResourceResponse& validatingResponse);
-WEBCORE_EXPORT void updateRedirectChainStatus(RedirectChainCacheStatus&, const ResourceResponse&);
-
-enum ReuseExpiredRedirectionOrNot { DoNotReuseExpiredRedirection, ReuseExpiredRedirection };
-WEBCORE_EXPORT bool redirectChainAllowsReuse(RedirectChainCacheStatus, ReuseExpiredRedirectionOrNot);
-
-struct CacheControlDirectives {
-    double maxAge { std::numeric_limits<double>::quiet_NaN() };
-    bool noCache { false };
-    bool noStore { false };
-    bool mustRevalidate { false };
-};
-WEBCORE_EXPORT CacheControlDirectives parseCacheControlDirectives(const HTTPHeaderMap&);
-
-}
-
-#endif

Copied: trunk/Source/WebCore/platform/network/CacheValidation.cpp (from rev 182059, trunk/Source/WebCore/loader/cache/CacheValidation.cpp) (0 => 182064)


--- trunk/Source/WebCore/platform/network/CacheValidation.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/CacheValidation.cpp	2015-03-27 16:49:21 UTC (rev 182064)
@@ -0,0 +1,293 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CacheValidation.h"
+
+#include "HTTPHeaderMap.h"
+#include "ResourceResponse.h"
+#include <wtf/CurrentTime.h>
+
+namespace WebCore {
+
+// These response headers are not copied from a revalidated response to the
+// cached response headers. For compatibility, this list is based on Chromium's
+// net/http/http_response_headers.cc.
+const char* const headersToIgnoreAfterRevalidation[] = {
+    "allow",
+    "connection",
+    "etag",
+    "expires",
+    "keep-alive",
+    "last-modified"
+    "proxy-authenticate",
+    "proxy-connection",
+    "trailer",
+    "transfer-encoding",
+    "upgrade",
+    "www-authenticate",
+    "x-frame-options",
+    "x-xss-protection",
+};
+
+// Some header prefixes mean "Don't copy this header from a 304 response.".
+// Rather than listing all the relevant headers, we can consolidate them into
+// this list, also grabbed from Chromium's net/http/http_response_headers.cc.
+const char* const headerPrefixesToIgnoreAfterRevalidation[] = {
+    "content-",
+    "x-content-",
+    "x-webkit-"
+};
+
+static inline bool shouldUpdateHeaderAfterRevalidation(const String& header)
+{
+    for (size_t i = 0; i < WTF_ARRAY_LENGTH(headersToIgnoreAfterRevalidation); i++) {
+        if (equalIgnoringCase(header, headersToIgnoreAfterRevalidation[i]))
+            return false;
+    }
+    for (size_t i = 0; i < WTF_ARRAY_LENGTH(headerPrefixesToIgnoreAfterRevalidation); i++) {
+        if (header.startsWith(headerPrefixesToIgnoreAfterRevalidation[i], false))
+            return false;
+    }
+    return true;
+}
+
+void updateResponseHeadersAfterRevalidation(ResourceResponse& response, const ResourceResponse& validatingResponse)
+{
+    // RFC2616 10.3.5
+    // Update cached headers from the 304 response
+    for (const auto& header : validatingResponse.httpHeaderFields()) {
+        // Entity headers should not be sent by servers when generating a 304
+        // response; misconfigured servers send them anyway. We shouldn't allow
+        // such headers to update the original request. We'll base this on the
+        // list defined by RFC2616 7.1, with a few additions for extension headers
+        // we care about.
+        if (!shouldUpdateHeaderAfterRevalidation(header.key))
+            continue;
+        response.setHTTPHeaderField(header.key, header.value);
+    }
+}
+
+double computeCurrentAge(const ResourceResponse& response, double responseTimestamp)
+{
+    // RFC2616 13.2.3
+    // No compensation for latency as that is not terribly important in practice
+    double dateValue = response.date();
+    double apparentAge = std::isfinite(dateValue) ? std::max(0., responseTimestamp - dateValue) : 0;
+    double ageValue = response.age();
+    double correctedReceivedAge = std::isfinite(ageValue) ? std::max(apparentAge, ageValue) : apparentAge;
+    double residentTime = currentTime() - responseTimestamp;
+    return correctedReceivedAge + residentTime;
+}
+
+double computeFreshnessLifetimeForHTTPFamily(const ResourceResponse& response, double responseTimestamp)
+{
+    ASSERT(response.url().protocolIsInHTTPFamily());
+    // RFC2616 13.2.4
+    double maxAgeValue = response.cacheControlMaxAge();
+    if (std::isfinite(maxAgeValue))
+        return maxAgeValue;
+    double expiresValue = response.expires();
+    double dateValue = response.date();
+    double creationTime = std::isfinite(dateValue) ? dateValue : responseTimestamp;
+    if (std::isfinite(expiresValue))
+        return expiresValue - creationTime;
+    double lastModifiedValue = response.lastModified();
+    if (std::isfinite(lastModifiedValue))
+        return (creationTime - lastModifiedValue) * 0.1;
+    // If no cache headers are present, the specification leaves the decision to the UA. Other browsers seem to opt for 0.
+    return 0;
+}
+
+void updateRedirectChainStatus(RedirectChainCacheStatus& redirectChainCacheStatus, const ResourceResponse& response)
+{
+    if (redirectChainCacheStatus.status == RedirectChainCacheStatus::NotCachedRedirection)
+        return;
+    if (response.cacheControlContainsNoStore() || response.cacheControlContainsNoCache() || response.cacheControlContainsMustRevalidate()) {
+        redirectChainCacheStatus.status = RedirectChainCacheStatus::NotCachedRedirection;
+        return;
+    }
+    redirectChainCacheStatus.status = RedirectChainCacheStatus::CachedRedirection;
+    double responseTimestamp = currentTime();
+    // Store the nearest end of cache validity date
+    double endOfValidity = responseTimestamp + computeFreshnessLifetimeForHTTPFamily(response, responseTimestamp) - computeCurrentAge(response, responseTimestamp);
+    redirectChainCacheStatus.endOfValidity = std::min(redirectChainCacheStatus.endOfValidity, endOfValidity);
+}
+
+bool redirectChainAllowsReuse(RedirectChainCacheStatus redirectChainCacheStatus, ReuseExpiredRedirectionOrNot reuseExpiredRedirection)
+{
+    switch (redirectChainCacheStatus.status) {
+    case RedirectChainCacheStatus::NoRedirection:
+        return true;
+    case RedirectChainCacheStatus::NotCachedRedirection:
+        return false;
+    case RedirectChainCacheStatus::CachedRedirection:
+        return reuseExpiredRedirection || currentTime() <= redirectChainCacheStatus.endOfValidity;
+    }
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+inline bool isCacheHeaderSeparator(UChar c)
+{
+    // See RFC 2616, Section 2.2
+    switch (c) {
+    case '(':
+    case ')':
+    case '<':
+    case '>':
+    case '@':
+    case ',':
+    case ';':
+    case ':':
+    case '\\':
+    case '"':
+    case '/':
+    case '[':
+    case ']':
+    case '?':
+    case '=':
+    case '{':
+    case '}':
+    case ' ':
+    case '\t':
+        return true;
+    default:
+        return false;
+    }
+}
+
+inline bool isControlCharacter(UChar c)
+{
+    return c < ' ' || c == 127;
+}
+
+inline String trimToNextSeparator(const String& str)
+{
+    return str.substring(0, str.find(isCacheHeaderSeparator));
+}
+
+static Vector<std::pair<String, String>> parseCacheHeader(const String& header)
+{
+    Vector<std::pair<String, String>> result;
+
+    const String safeHeader = header.removeCharacters(isControlCharacter);
+    unsigned max = safeHeader.length();
+    unsigned pos = 0;
+    while (pos < max) {
+        size_t nextCommaPosition = safeHeader.find(',', pos);
+        size_t nextEqualSignPosition = safeHeader.find('=', pos);
+        if (nextEqualSignPosition == notFound && nextCommaPosition == notFound) {
+            // Add last directive to map with empty string as value
+            result.append(std::make_pair(trimToNextSeparator(safeHeader.substring(pos, max - pos).stripWhiteSpace()), ""));
+            return result;
+        }
+        if (nextCommaPosition != notFound && (nextCommaPosition < nextEqualSignPosition || nextEqualSignPosition == notFound)) {
+            // Add directive to map with empty string as value
+            result.append(std::make_pair(trimToNextSeparator(safeHeader.substring(pos, nextCommaPosition - pos).stripWhiteSpace()), ""));
+            pos += nextCommaPosition - pos + 1;
+            continue;
+        }
+        // Get directive name, parse right hand side of equal sign, then add to map
+        String directive = trimToNextSeparator(safeHeader.substring(pos, nextEqualSignPosition - pos).stripWhiteSpace());
+        pos += nextEqualSignPosition - pos + 1;
+
+        String value = safeHeader.substring(pos, max - pos).stripWhiteSpace();
+        if (value[0] == '"') {
+            // The value is a quoted string
+            size_t nextDoubleQuotePosition = value.find('"', 1);
+            if (nextDoubleQuotePosition == notFound) {
+                // Parse error; just use the rest as the value
+                result.append(std::make_pair(directive, trimToNextSeparator(value.substring(1, value.length() - 1).stripWhiteSpace())));
+                return result;
+            }
+            // Store the value as a quoted string without quotes
+            result.append(std::make_pair(directive, value.substring(1, nextDoubleQuotePosition - 1).stripWhiteSpace()));
+            pos += (safeHeader.find('"', pos) - pos) + nextDoubleQuotePosition + 1;
+            // Move past next comma, if there is one
+            size_t nextCommaPosition2 = safeHeader.find(',', pos);
+            if (nextCommaPosition2 == notFound)
+                return result; // Parse error if there is anything left with no comma
+            pos += nextCommaPosition2 - pos + 1;
+            continue;
+        }
+        // The value is a token until the next comma
+        size_t nextCommaPosition2 = value.find(',');
+        if (nextCommaPosition2 == notFound) {
+            // The rest is the value; no change to value needed
+            result.append(std::make_pair(directive, trimToNextSeparator(value)));
+            return result;
+        }
+        // The value is delimited by the next comma
+        result.append(std::make_pair(directive, trimToNextSeparator(value.substring(0, nextCommaPosition2).stripWhiteSpace())));
+        pos += (safeHeader.find(',', pos) - pos) + 1;
+    }
+    return result;
+}
+
+CacheControlDirectives parseCacheControlDirectives(const HTTPHeaderMap& headers)
+{
+    CacheControlDirectives result;
+
+    String cacheControlValue = headers.get(HTTPHeaderName::CacheControl);
+    if (!cacheControlValue.isEmpty()) {
+        auto directives = parseCacheHeader(cacheControlValue);
+
+        size_t directivesSize = directives.size();
+        for (size_t i = 0; i < directivesSize; ++i) {
+            // RFC2616 14.9.1: A no-cache directive with a value is only meaningful for proxy caches.
+            // It should be ignored by a browser level cache.
+            if (equalIgnoringCase(directives[i].first, "no-cache") && directives[i].second.isEmpty())
+                result.noCache = true;
+            else if (equalIgnoringCase(directives[i].first, "no-store"))
+                result.noStore = true;
+            else if (equalIgnoringCase(directives[i].first, "must-revalidate"))
+                result.mustRevalidate = true;
+            else if (equalIgnoringCase(directives[i].first, "max-age")) {
+                if (!std::isnan(result.maxAge)) {
+                    // First max-age directive wins if there are multiple ones.
+                    continue;
+                }
+                bool ok;
+                double maxAge = directives[i].second.toDouble(&ok);
+                if (ok)
+                    result.maxAge = maxAge;
+            }
+        }
+    }
+
+    if (!result.noCache) {
+        // Handle Pragma: no-cache
+        // This is deprecated and equivalent to Cache-control: no-cache
+        // Don't bother tokenizing the value, it is not important
+        String pragmaValue = headers.get(HTTPHeaderName::Pragma);
+
+        result.noCache = pragmaValue.contains("no-cache", false);
+    }
+
+    return result;
+}
+
+}

Copied: trunk/Source/WebCore/platform/network/CacheValidation.h (from rev 182059, trunk/Source/WebCore/loader/cache/CacheValidation.h) (0 => 182064)


--- trunk/Source/WebCore/platform/network/CacheValidation.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/CacheValidation.h	2015-03-27 16:49:21 UTC (rev 182064)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CacheValidation_h
+#define CacheValidation_h
+
+namespace WebCore {
+
+class HTTPHeaderMap;
+class ResourceResponse;
+
+struct RedirectChainCacheStatus {
+    enum Status {
+        NoRedirection,
+        NotCachedRedirection,
+        CachedRedirection
+    };
+    RedirectChainCacheStatus()
+        : status(NoRedirection)
+        , endOfValidity(std::numeric_limits<double>::max())
+    { }
+    Status status;
+    double endOfValidity;
+};
+
+WEBCORE_EXPORT double computeCurrentAge(const ResourceResponse&, double responseTimestamp);
+WEBCORE_EXPORT double computeFreshnessLifetimeForHTTPFamily(const ResourceResponse&, double responseTimestamp);
+WEBCORE_EXPORT void updateResponseHeadersAfterRevalidation(ResourceResponse&, const ResourceResponse& validatingResponse);
+WEBCORE_EXPORT void updateRedirectChainStatus(RedirectChainCacheStatus&, const ResourceResponse&);
+
+enum ReuseExpiredRedirectionOrNot { DoNotReuseExpiredRedirection, ReuseExpiredRedirection };
+WEBCORE_EXPORT bool redirectChainAllowsReuse(RedirectChainCacheStatus, ReuseExpiredRedirectionOrNot);
+
+struct CacheControlDirectives {
+    double maxAge { std::numeric_limits<double>::quiet_NaN() };
+    bool noCache { false };
+    bool noStore { false };
+    bool mustRevalidate { false };
+};
+WEBCORE_EXPORT CacheControlDirectives parseCacheControlDirectives(const HTTPHeaderMap&);
+
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to