<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[175342] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/175342">175342</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2014-10-29 13:54:45 -0700 (Wed, 29 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Factor cache validity computation functions out of CachedResource
https://bugs.webkit.org/show_bug.cgi?id=138156

Reviewed by Andreas Kling.

These can be used to implement cache logic on WebKit level.

* CMakeLists.txt:
* WebCore.exp.in:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* loader/CacheValidation.cpp: Added.
(WebCore::computeCurrentAge):
(WebCore::computeFreshnessLifetimeForHTTPFamily):
(WebCore::updateRedirectChainStatus):
(WebCore::redirectChainAllowsReuse):
* loader/CacheValidation.h: Added.
(WebCore::RedirectChainCacheStatus::RedirectChainCacheStatus):
* loader/cache/CachedResource.cpp:
(WebCore::updateResponseHeadersAfterRevalidation):
(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::isExpired):
(WebCore::CachedResource::freshnessLifetime):
(WebCore::CachedResource::willSendRequest):
(WebCore::CachedResource::updateResponseAfterRevalidation):
(WebCore::CachedResource::redirectChainAllowsReuse):
(WebCore::currentAge): Deleted.
* loader/cache/CachedResource.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourcecpp">trunk/Source/WebCore/loader/cache/CachedResource.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceh">trunk/Source/WebCore/loader/cache/CachedResource.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreloaderCacheValidationcpp">trunk/Source/WebCore/loader/CacheValidation.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderCacheValidationh">trunk/Source/WebCore/loader/CacheValidation.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (175341 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-10-29 20:48:31 UTC (rev 175341)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -1857,6 +1857,7 @@
</span><span class="cx">     loader/cache/CachedSVGDocumentReference.cpp
</span><span class="cx">     loader/cache/CachedScript.cpp
</span><span class="cx">     loader/cache/CachedXSLStyleSheet.cpp
</span><ins>+    loader/cache/CacheValidation.cpp
</ins><span class="cx">     loader/cache/MemoryCache.cpp
</span><span class="cx"> 
</span><span class="cx">     loader/icon/IconController.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175341 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-29 20:48:31 UTC (rev 175341)
+++ trunk/Source/WebCore/ChangeLog        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2014-10-29  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Factor cache validity computation functions out of CachedResource
+        https://bugs.webkit.org/show_bug.cgi?id=138156
+
+        Reviewed by Andreas Kling.
+
+        These can be used to implement cache logic on WebKit level.
+
+        * CMakeLists.txt:
+        * WebCore.exp.in:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/CacheValidation.cpp: Added.
+        (WebCore::computeCurrentAge):
+        (WebCore::computeFreshnessLifetimeForHTTPFamily):
+        (WebCore::updateRedirectChainStatus):
+        (WebCore::redirectChainAllowsReuse):
+        * loader/CacheValidation.h: Added.
+        (WebCore::RedirectChainCacheStatus::RedirectChainCacheStatus):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::updateResponseHeadersAfterRevalidation):
+        (WebCore::CachedResource::CachedResource):
+        (WebCore::CachedResource::isExpired):
+        (WebCore::CachedResource::freshnessLifetime):
+        (WebCore::CachedResource::willSendRequest):
+        (WebCore::CachedResource::updateResponseAfterRevalidation):
+        (WebCore::CachedResource::redirectChainAllowsReuse):
+        (WebCore::currentAge): Deleted.
+        * loader/cache/CachedResource.h:
+
</ins><span class="cx"> 2014-10-28  Ada Chan  &lt;adachan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add API to mute/unmute a page.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (175341 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-10-29 20:48:31 UTC (rev 175341)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -779,6 +779,7 @@
</span><span class="cx"> __ZN7WebCore17SQLiteTransactionD1Ev
</span><span class="cx"> __ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestERKNS_21ResourceLoaderOptionsE
</span><span class="cx"> __ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
</span><ins>+__ZN7WebCore17computeCurrentAgeERKNS_16ResourceResponseEd
</ins><span class="cx"> __ZN7WebCore17encodeForFileNameERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore17execStateFromPageERNS_15DOMWrapperWorldEPNS_4PageE
</span><span class="cx"> __ZN7WebCore17languageDidChangeEv
</span><span class="lines">@@ -844,6 +845,7 @@
</span><span class="cx"> __ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore19ResourceRequestBase15setHTTPReferrerERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore19ResourceRequestBase18setHTTPContentTypeERKN3WTF6StringE
</span><ins>+__ZN7WebCore19ResourceRequestBase18setHTTPHeaderFieldENS_14HTTPHeaderNameERKN3WTF6StringE
</ins><span class="cx"> __ZN7WebCore19ResourceRequestBase19setHTTPHeaderFieldsENS_13HTTPHeaderMapE
</span><span class="cx"> __ZN7WebCore19ResourceRequestBase22defaultTimeoutIntervalEv
</span><span class="cx"> __ZN7WebCore19ResourceRequestBase24s_defaultTimeoutIntervalE
</span><span class="lines">@@ -1042,10 +1044,12 @@
</span><span class="cx"> __ZN7WebCore24fileSystemRepresentationERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore24notifyHistoryItemChangedE
</span><span class="cx"> __ZN7WebCore24pathByAppendingComponentERKN3WTF6StringES3_
</span><ins>+__ZN7WebCore24redirectChainAllowsReuseENS_24RedirectChainCacheStatusE
</ins><span class="cx"> __ZN7WebCore25addLanguageChangeObserverEPvPFvS0_E
</span><span class="cx"> __ZN7WebCore25computeViewportAttributesENS_17ViewportArgumentsEiiifNS_7IntSizeE
</span><span class="cx"> __ZN7WebCore25createCanonicalUUIDStringEv
</span><span class="cx"> __ZN7WebCore25getOutOfLineCachedWrapperEPNS_17JSDOMGlobalObjectEPNS_4NodeE
</span><ins>+__ZN7WebCore25updateRedirectChainStatusERNS_24RedirectChainCacheStatusERKNS_16ResourceResponseE
</ins><span class="cx"> __ZN7WebCore26ContextDestructionObserver16contextDestroyedEv
</span><span class="cx"> __ZN7WebCore26ContextDestructionObserverC2EPNS_22ScriptExecutionContextE
</span><span class="cx"> __ZN7WebCore26ContextDestructionObserverD2Ev
</span><span class="lines">@@ -1087,6 +1091,8 @@
</span><span class="cx"> __ZN7WebCore36standardUserAgentWithApplicationNameERKN3WTF6StringES3_
</span><span class="cx"> __ZN7WebCore37WidgetHierarchyUpdatesSuspensionScope11moveWidgetsEv
</span><span class="cx"> __ZN7WebCore37WidgetHierarchyUpdatesSuspensionScope35s_widgetHierarchyUpdateSuspendCountE
</span><ins>+__ZN7WebCore37computeFreshnessLifetimeForHTTPFamilyERKNS_16ResourceResponseEd
+__ZN7WebCore38updateResponseHeadersAfterRevalidationERNS_16ResourceResponseERKS0_
</ins><span class="cx"> __ZN7WebCore3URL10invalidateEv
</span><span class="cx"> __ZN7WebCore3URL11setProtocolERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore3URL7setPathERKN3WTF6StringE
</span><span class="lines">@@ -1842,7 +1848,11 @@
</span><span class="cx"> __ZNK7WebCore19ProtectionSpaceBase5realmEv
</span><span class="cx"> __ZNK7WebCore19ProtectionSpaceBase7isProxyEv
</span><span class="cx"> __ZNK7WebCore19ResourceRequestBase10httpMethodEv
</span><ins>+__ZNK7WebCore19ResourceRequestBase11cachePolicyEv
+__ZNK7WebCore19ResourceRequestBase13isConditionalEv
</ins><span class="cx"> __ZNK7WebCore19ResourceRequestBase15httpContentTypeEv
</span><ins>+__ZNK7WebCore19ResourceRequestBase15httpHeaderFieldENS_14HTTPHeaderNameE
+__ZNK7WebCore19ResourceRequestBase15httpHeaderFieldERKN3WTF6StringE
</ins><span class="cx"> __ZNK7WebCore19ResourceRequestBase20firstPartyForCookiesEv
</span><span class="cx"> __ZNK7WebCore19ResourceRequestBase3urlEv
</span><span class="cx"> __ZNK7WebCore19ResourceRequestBase6isNullEv
</span><span class="lines">@@ -1863,6 +1873,10 @@
</span><span class="cx"> __ZNK7WebCore20ResourceResponseBase17suggestedFilenameEv
</span><span class="cx"> __ZNK7WebCore20ResourceResponseBase21expectedContentLengthEv
</span><span class="cx"> __ZNK7WebCore20ResourceResponseBase22includeCertificateInfoEv
</span><ins>+__ZNK7WebCore20ResourceResponseBase23hasCacheValidatorFieldsEv
+__ZNK7WebCore20ResourceResponseBase27cacheControlContainsNoCacheEv
+__ZNK7WebCore20ResourceResponseBase27cacheControlContainsNoStoreEv
+__ZNK7WebCore20ResourceResponseBase34cacheControlContainsMustRevalidateEv
</ins><span class="cx"> __ZNK7WebCore20ResourceResponseBase3urlEv
</span><span class="cx"> __ZNK7WebCore20ResourceResponseBase6isHTTPEv
</span><span class="cx"> __ZNK7WebCore20ResourceResponseBase8lazyInitENS0_9InitLevelE
</span><span class="lines">@@ -2279,6 +2293,7 @@
</span><span class="cx"> __ZN7WebCore15ResourceRequest41updateFromDelegatePreservingOldPropertiesERKS0_
</span><span class="cx"> __ZN7WebCore16FontPlatformDataC1EP6NSFontfbbbNS_15FontOrientationENS_16FontWidthVariantE
</span><span class="cx"> __ZN7WebCore16FontPlatformDataC2EP6NSFontfbbbNS_15FontOrientationENS_16FontWidthVariantE
</span><ins>+__ZN7WebCore16JSXMLHttpRequest9toWrappedEN3JSC7JSValueE
</ins><span class="cx"> __ZN7WebCore16colorFromNSColorEP7NSColor
</span><span class="cx"> __ZN7WebCore16deleteAllCookiesERKNS_21NetworkStorageSessionE
</span><span class="cx"> __ZN7WebCore16enclosingIntRectERK7_NSRect
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (175341 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-10-29 20:48:31 UTC (rev 175341)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -7340,6 +7340,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\cache\CachedSVGDocumentReference.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\cache\CachedTextTrack.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\cache\CachedXSLStyleSheet.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\loader\cache\CacheValidation.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\loader\cache\MemoryCache.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\audio\AudioHardwareListener.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\platform\CalculationValue.cpp&quot; /&gt;
</span><span class="lines">@@ -19308,6 +19309,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\cache\CachedTextTrack.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\cache\CachedXSLStyleSheet.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\cache\CachePolicy.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\loader\cache\CacheValidation.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\loader\cache\MemoryCache.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\audio\AudioHardwareListener.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\CalculationValue.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (175341 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-10-29 20:48:31 UTC (rev 175341)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -6164,6 +6164,8 @@
</span><span class="cx">                 E453904D0EAFD637003695C8 /* WidgetIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = E453903C0EAFD637003695C8 /* WidgetIOS.mm */; };
</span><span class="cx">                 E45390AE0EAFF4B5003695C8 /* SystemMemoryIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */; };
</span><span class="cx">                 E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                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, ); }; };
</ins><span class="cx">                 E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E47127CA163438A100ED6F5A /* StyleInvalidationAnalysis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47A97CE163059FC005DCD99 /* StyleInvalidationAnalysis.cpp */; };
</span><span class="lines">@@ -13693,6 +13695,8 @@
</span><span class="cx">                 E453903C0EAFD637003695C8 /* WidgetIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WidgetIOS.mm; path = ios/WidgetIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SystemMemoryIOS.cpp; path = ios/SystemMemoryIOS.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E462A4A0113E71BE004A4220 /* IntPointHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntPointHash.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E467680D1A0177EE00B9E26B /* CacheValidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CacheValidation.cpp; path = loader/CacheValidation.cpp; sourceTree = SOURCE_ROOT; };
+                E467680F1A0177F900B9E26B /* CacheValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CacheValidation.h; path = loader/CacheValidation.h; sourceTree = SOURCE_ROOT; };
</ins><span class="cx">                 E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedElementDescendantIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementChildIterator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4778B7D115A581A00B5D372 /* JSCustomEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomEvent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -19625,6 +19629,8 @@
</span><span class="cx">                                 BCB16C0E0979C3BD00467741 /* CachedXSLStyleSheet.cpp */,
</span><span class="cx">                                 BCB16C0F0979C3BD00467741 /* CachedXSLStyleSheet.h */,
</span><span class="cx">                                 F587864902DE3A9A01EA4122 /* CachePolicy.h */,
</span><ins>+                                E467680D1A0177EE00B9E26B /* CacheValidation.cpp */,
+                                E467680F1A0177F900B9E26B /* CacheValidation.h */,
</ins><span class="cx">                                 BCB16BFE0979C3BD00467741 /* MemoryCache.cpp */,
</span><span class="cx">                                 BCB16BFF0979C3BD00467741 /* MemoryCache.h */,
</span><span class="cx">                         );
</span><span class="lines">@@ -23669,6 +23675,7 @@
</span><span class="cx">                                 975CA28B130365F800E99AD9 /* Crypto.h in Headers */,
</span><span class="cx">                                 E172AF6E180F24C600FBADB9 /* CryptoAlgorithm.h in Headers */,
</span><span class="cx">                                 E125F8421824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h in Headers */,
</span><ins>+                                E46768101A0177F900B9E26B /* CacheValidation.h in Headers */,
</ins><span class="cx">                                 E1FE137B184D21BB00892F13 /* CryptoAlgorithmAES_KW.h in Headers */,
</span><span class="cx">                                 E125F83A1824104800D84CD9 /* CryptoAlgorithmAesCbcParams.h in Headers */,
</span><span class="cx">                                 E19AC3F71824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h in Headers */,
</span><span class="lines">@@ -27189,6 +27196,7 @@
</span><span class="cx">                                 FD3160BB12B0272A00C1A359 /* AudioBusMac.mm in Sources */,
</span><span class="cx">                                 FD31607D12B026F700C1A359 /* AudioChannel.cpp in Sources */,
</span><span class="cx">                                 FD31600412B0267600C1A359 /* AudioContext.cpp in Sources */,
</span><ins>+                                E467680E1A0177EE00B9E26B /* CacheValidation.cpp in Sources */,
</ins><span class="cx">                                 CD0EEE0E14743F39003EAFA2 /* AudioDestinationIOS.cpp in Sources */,
</span><span class="cx">                                 FD3160BC12B0272A00C1A359 /* AudioDestinationMac.cpp in Sources */,
</span><span class="cx">                                 FD31600712B0267600C1A359 /* AudioDestinationNode.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderCacheValidationcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/CacheValidation.cpp (0 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CacheValidation.cpp                                (rev 0)
+++ trunk/Source/WebCore/loader/CacheValidation.cpp        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+/*
+    Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
+    Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
+    Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
+    Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
+    Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include &quot;config.h&quot;
+#include &quot;CacheValidation.h&quot;
+
+#include &quot;ResourceResponse.h&quot;
+#include &lt;wtf/CurrentTime.h&gt;
+
+namespace WebCore {
+
+double computeCurrentAge(const ResourceResponse&amp; 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&amp; 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&amp; redirectChainCacheStatus, const ResourceResponse&amp; 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)
+{
+    switch (redirectChainCacheStatus.status) {
+    case RedirectChainCacheStatus::NoRedirection:
+        return true;
+    case RedirectChainCacheStatus::NotCachedRedirection:
+        return false;
+    case RedirectChainCacheStatus::CachedRedirection:
+        return currentTime() &lt;= redirectChainCacheStatus.endOfValidity;
+    }
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderCacheValidationh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/CacheValidation.h (0 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CacheValidation.h                                (rev 0)
+++ trunk/Source/WebCore/loader/CacheValidation.h        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+    Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
+    Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
+    Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
+    Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved.
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CacheValidation_h
+#define CacheValidation_h
+
+namespace WebCore {
+
+class ResourceResponse;
+
+struct RedirectChainCacheStatus {
+    enum Status {
+        NoRedirection,
+        NotCachedRedirection,
+        CachedRedirection
+    };
+    RedirectChainCacheStatus()
+        : status(NoRedirection)
+        , endOfValidity(std::numeric_limits&lt;double&gt;::max())
+    { }
+    Status status;
+    double endOfValidity;
+};
+
+double computeCurrentAge(const ResourceResponse&amp;, double responseTimestamp);
+double computeFreshnessLifetimeForHTTPFamily(const ResourceResponse&amp;, double responseTimestamp);
+void updateResponseHeadersAfterRevalidation(ResourceResponse&amp;, const ResourceResponse&amp; validatingResponse);
+void updateRedirectChainStatus(RedirectChainCacheStatus&amp;, const ResourceResponse&amp;);
+bool redirectChainAllowsReuse(RedirectChainCacheStatus);
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (175341 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.cpp        2014-10-29 20:48:31 UTC (rev 175341)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx">     Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
</span><span class="cx">     Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
</span><span class="cx">     Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
</span><del>-    Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
</del><ins>+    Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> 
</span><span class="cx">     This library is free software; you can redistribute it and/or
</span><span class="cx">     modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -104,6 +104,22 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void updateResponseHeadersAfterRevalidation(ResourceResponse&amp; response, const ResourceResponse&amp; validatingResponse)
+{
+    // RFC2616 10.3.5
+    // Update cached headers from the 304 response
+    for (const auto&amp; 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);
+    }
+}
+
</ins><span class="cx"> static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type type)
</span><span class="cx"> {
</span><span class="cx">     switch (type) {
</span><span class="lines">@@ -146,18 +162,6 @@
</span><span class="cx">     return memoryCache()-&gt;deadDecodedDataDeletionInterval();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static double currentAge(const ResourceResponse&amp; 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;
-}
-
</del><span class="cx"> DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, cachedResourceLeakCounter, (&quot;CachedResource&quot;));
</span><span class="cx"> 
</span><span class="cx"> CachedResource::CachedResource(const ResourceRequest&amp; request, Type type, SessionID sessionID)
</span><span class="lines">@@ -192,8 +196,6 @@
</span><span class="cx">     , m_owningCachedResourceLoader(0)
</span><span class="cx">     , m_resourceToRevalidate(0)
</span><span class="cx">     , m_proxyResource(0)
</span><del>-    , m_redirectChainCacheStatus(NoRedirection)
-    , m_redirectChainEndOfValidity(std::numeric_limits&lt;double&gt;::max())
</del><span class="cx"> {
</span><span class="cx">     ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests careless updates of the enum.
</span><span class="cx">     ASSERT(sessionID.isValid());
</span><span class="lines">@@ -400,7 +402,7 @@
</span><span class="cx">     if (m_response.isNull())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    return currentAge(m_response, m_responseTimestamp) &gt; freshnessLifetime(m_response);
</del><ins>+    return computeCurrentAge(m_response, m_responseTimestamp) &gt; freshnessLifetime(m_response);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double CachedResource::freshnessLifetime(const ResourceResponse&amp; response) const
</span><span class="lines">@@ -415,20 +417,7 @@
</span><span class="cx">         return std::numeric_limits&lt;double&gt;::max();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // 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 : m_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;
</del><ins>+    return computeFreshnessLifetimeForHTTPFamily(response, m_responseTimestamp);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CachedResource::willSendRequest(ResourceRequest&amp;, const ResourceResponse&amp; response)
</span><span class="lines">@@ -436,19 +425,7 @@
</span><span class="cx">     m_requestedFromNetworkingLayer = true;
</span><span class="cx">     if (response.isNull())
</span><span class="cx">         return;
</span><del>-    if (m_redirectChainCacheStatus == NotCachedRedirection)
-        return;
-    if (response.cacheControlContainsNoStore()
-        || response.cacheControlContainsNoCache()
-        || response.cacheControlContainsMustRevalidate())
-        m_redirectChainCacheStatus = NotCachedRedirection;
-    else {
-        m_redirectChainCacheStatus = CachedRedirection;
-        double responseTimestamp = currentTime();
-        // Store the nearest end of cache validity date
-        m_redirectChainEndOfValidity = std::min(m_redirectChainEndOfValidity, 
-            responseTimestamp + freshnessLifetime(response) - currentAge(response, responseTimestamp));
-    }
</del><ins>+    updateRedirectChainStatus(m_redirectChainCacheStatus, response);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CachedResource::responseReceived(const ResourceResponse&amp; response)
</span><span class="lines">@@ -733,18 +710,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_responseTimestamp = currentTime();
</span><span class="cx"> 
</span><del>-    // RFC2616 10.3.5
-    // Update cached headers from the 304 response
-    for (const auto&amp; 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;
-        m_response.setHTTPHeaderField(header.key, header.value);
-    }
</del><ins>+    updateResponseHeadersAfterRevalidation(m_response, validatingResponse);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CachedResource::registerHandle(CachedResourceHandleBase* h)
</span><span class="lines">@@ -807,15 +773,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool CachedResource::redirectChainAllowsReuse() const
</span><span class="cx"> {
</span><del>-    switch (m_redirectChainCacheStatus) {
-    case NoRedirection:
-        return true;
-    case NotCachedRedirection:
-        return false;
-    case CachedRedirection:
-        return currentTime() &lt;= m_redirectChainEndOfValidity;
-    }
-    return true;
</del><ins>+    return WebCore::redirectChainAllowsReuse(m_redirectChainCacheStatus);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned CachedResource::overheadSize() const
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (175341 => 175342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.h        2014-10-29 20:48:31 UTC (rev 175341)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h        2014-10-29 20:54:45 UTC (rev 175342)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #define CachedResource_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CachePolicy.h&quot;
</span><ins>+#include &quot;CacheValidation.h&quot;
</ins><span class="cx"> #include &quot;FrameLoaderTypes.h&quot;
</span><span class="cx"> #include &quot;ResourceError.h&quot;
</span><span class="cx"> #include &quot;ResourceLoadPriority.h&quot;
</span><span class="lines">@@ -88,12 +89,6 @@
</span><span class="cx">         DecodeError
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    enum RedirectChainCacheStatus {
-        NoRedirection,
-        NotCachedRedirection,
-        CachedRedirection
-    };
-
</del><span class="cx">     CachedResource(const ResourceRequest&amp;, Type, SessionID);
</span><span class="cx">     virtual ~CachedResource();
</span><span class="cx"> 
</span><span class="lines">@@ -358,7 +353,6 @@
</span><span class="cx">     HashSet&lt;CachedResourceHandleBase*&gt; m_handlesToRevalidate;
</span><span class="cx"> 
</span><span class="cx">     RedirectChainCacheStatus m_redirectChainCacheStatus;
</span><del>-    double m_redirectChainEndOfValidity;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>