No subject
Tue May 3 15:05:30 PDT 2016
loaderStrategy()->storeDerivedDataToCache(key, partition, type, data);
The data is keyed with the body hash of a network resource. It can be retrieved along
with the resource by specifying the type in ResourceLoaderOptions. If a related data
blob is found it will be deliver via CachedResource::didRetrieveDerivedDataFromCache()
callback.
This patch adds the mechanism but doesn't yet use it for anything.
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::storeDerivedDataToCache):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* NetworkProcess/NetworkResourceLoadParameters.h:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
Look for related resources to return if needed.
(WebKit::NetworkResourceLoader::sendResultForCacheEntry):
* NetworkProcess/NetworkResourceLoader.h:
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::resourceType):
(WebKit::NetworkCache::Cache::retrieveData):
(WebKit::NetworkCache::Cache::storeData):
(WebKit::NetworkCache::Cache::makeCacheKey): Deleted.
* NetworkProcess/cache/NetworkCache.h:
* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::encodeAsStorageRecord):
(WebKit::NetworkCache::Entry::decodeStorageRecord):
* NetworkProcess/cache/NetworkCacheKey.cpp:
(WebKit::NetworkCache::Key::Key):
* NetworkProcess/cache/NetworkCacheKey.h:
(WebKit::NetworkCache::DataKey::encode):
(WebKit::NetworkCache::DataKey::decode):
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::readRecord):
(WebKit::NetworkCache::Storage::traverse):
* NetworkProcess/cache/NetworkCacheStorage.h:
Return body hash with the Record.
* NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
(WebKit::NetworkCache::SubresourcesEntry::encodeAsStorageRecord):
* Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<SHA1::Digest>::encode):
(IPC::ArgumentCoder<SHA1::Digest>::decode):
* Platform/IPC/ArgumentCoders.h:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad):
(WebKit::WebLoaderStrategy::storeDerivedDataToCache):
* WebProcess/Network/WebLoaderStrategy.h:
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didRetrieveDerivedData):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Network/WebResourceLoader.messages.in:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderLoaderStrategyh">trunk/Source/WebCore/loader/LoaderStrategy.h</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadercpp">trunk/Source/WebCore/loader/ResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoaderh">trunk/Source/WebCore/loader/ResourceLoader.h</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoaderOptionsh">trunk/Source/WebCore/loader/ResourceLoaderOptions.h</a></li>
<li><a href="#trunkSourceWebCoreloaderSubresourceLoadercpp">trunk/Source/WebCore/loader/SubresourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderSubresourceLoaderh">trunk/Source/WebCore/loader/SubresourceLoader.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceh">trunk/Source/WebCore/loader/cache/CachedResource.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceResponseBaseh">trunk/Source/WebCore/platform/network/ResourceResponseBase.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebCoreSupportWebResourceLoadSchedulerh">trunk/Source/WebKit/WebCoreSupport/WebResourceLoadScheduler.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessh">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessmessagesin">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkResourceLoadParameterscpp">trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkResourceLoadParametersh">trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkResourceLoadercpp">trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkResourceLoaderh">trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheEntrycpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheKeycpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheKeyh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheStoragecpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheStorageh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheSubresourcesEntrycpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCArgumentCoderscpp">trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCArgumentCodersh">trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebLoaderStrategycpp">trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebLoaderStrategyh">trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadercpp">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoaderh">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadermessagesin">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/ChangeLog 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2017-01-17 Antti Koivisto <antti at apple.com>
+
+ Persist derived data
+ https://bugs.webkit.org/show_bug.cgi?id=167136
+
+ Reviewed by Andreas Kling.
+
+ * loader/LoaderStrategy.h:
+ * loader/ResourceLoader.cpp:
+ (WebCore::ResourceLoader::didRetrieveDerivedDataFromCache):
+ * loader/ResourceLoader.h:
+ (WebCore::ResourceLoader::options):
+ * loader/ResourceLoaderOptions.h:
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::didRetrieveDerivedDataFromCache):
+ * loader/SubresourceLoader.h:
+ * loader/cache/CachedResource.h:
+ (WebCore::CachedResource::didRetrieveDerivedDataFromCache):
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::defaultCachedResourceOptions):
+ * platform/network/ResourceResponseBase.h:
+ (WebCore::ResourceResponseBase::cacheBodyKey):
+ (WebCore::ResourceResponseBase::setCacheBodyKey):
+ (WebCore::ResourceResponseBase::encode):
+ (WebCore::ResourceResponseBase::decode):
+
</ins><span class="cx"> 2017-01-17 Antoine Quint <graouts at apple.com>
</span><span class="cx">
</span><span class="cx"> [Modern Media Controls] Turn modern media controls on by default
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderLoaderStrategyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/LoaderStrategy.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/LoaderStrategy.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/LoaderStrategy.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "ResourceHandleTypes.h"
</span><span class="cx"> #include "ResourceLoadPriority.h"
</span><span class="cx"> #include "ResourceLoaderOptions.h"
</span><ins>+#include <wtf/SHA1.h>
</ins><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -41,6 +42,7 @@
</span><span class="cx"> class ResourceLoader;
</span><span class="cx"> class ResourceRequest;
</span><span class="cx"> class ResourceResponse;
</span><ins>+class SharedBuffer;
</ins><span class="cx"> class SubresourceLoader;
</span><span class="cx"> class URL;
</span><span class="cx">
</span><span class="lines">@@ -59,6 +61,8 @@
</span><span class="cx">
</span><span class="cx"> virtual void createPingHandle(NetworkingContext*, ResourceRequest&, bool shouldUseCredentialStorage, bool shouldFollowRedirects) = 0;
</span><span class="cx">
</span><ins>+ virtual void storeDerivedDataToCache(const SHA1::Digest& bodyKey, const String& type, const String& partition, WebCore::SharedBuffer&) = 0;
+
</ins><span class="cx"> protected:
</span><span class="cx"> virtual ~LoaderStrategy();
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -744,4 +744,8 @@
</span><span class="cx"> return frameLoader() && frameLoader()->isAlwaysOnLoggingAllowed();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ResourceLoader::didRetrieveDerivedDataFromCache(const String&, SharedBuffer&)
+{
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/ResourceLoader.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx"> #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
</span><span class="cx"> virtual void didReceiveDataArray(CFArrayRef dataArray);
</span><span class="cx"> #endif
</span><ins>+ virtual void didRetrieveDerivedDataFromCache(const String& type, SharedBuffer&);
</ins><span class="cx">
</span><span class="cx"> virtual bool shouldUseCredentialStorage();
</span><span class="cx"> virtual void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
</span><span class="lines">@@ -147,6 +148,8 @@
</span><span class="cx"> const Frame* frame() const { return m_frame.get(); }
</span><span class="cx"> WEBCORE_EXPORT bool isAlwaysOnLoggingAllowed() const;
</span><span class="cx">
</span><ins>+ const ResourceLoaderOptions& options() const { return m_options; }
+
</ins><span class="cx"> protected:
</span><span class="cx"> ResourceLoader(Frame&, ResourceLoaderOptions);
</span><span class="cx">
</span><span class="lines">@@ -157,8 +160,6 @@
</span><span class="cx">
</span><span class="cx"> void didReceiveDataOrBuffer(const char*, unsigned, RefPtr<SharedBuffer>&&, long long encodedDataLength, DataPayloadType);
</span><span class="cx">
</span><del>- const ResourceLoaderOptions& options() { return m_options; }
-
</del><span class="cx"> #if PLATFORM(COCOA) && !USE(CFURLCONNECTION)
</span><span class="cx"> NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoaderOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoaderOptions.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoaderOptions.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/ResourceLoaderOptions.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -32,6 +32,8 @@
</span><span class="cx">
</span><span class="cx"> #include "FetchOptions.h"
</span><span class="cx"> #include "ResourceHandleTypes.h"
</span><ins>+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -119,6 +121,8 @@
</span><span class="cx">
</span><span class="cx"> ClientCredentialPolicy clientCredentialPolicy { ClientCredentialPolicy::CannotAskClientForCredentials };
</span><span class="cx"> unsigned maxRedirectCount { 20 };
</span><ins>+
+ Vector<String> derivedCachedDataTypesToRetrieve;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderSubresourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -621,6 +621,13 @@
</span><span class="cx"> notifyDone();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void SubresourceLoader::didRetrieveDerivedDataFromCache(const String& type, SharedBuffer& buffer)
+{
+ if (m_state != Initialized)
+ return;
+ m_resource->didRetrieveDerivedDataFromCache(type, buffer);
+}
+
</ins><span class="cx"> void SubresourceLoader::notifyDone()
</span><span class="cx"> {
</span><span class="cx"> if (reachedTerminalState())
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderSubresourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/SubresourceLoader.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/SubresourceLoader.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/SubresourceLoader.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -75,6 +75,7 @@
</span><span class="cx"> void didFail(const ResourceError&) override;
</span><span class="cx"> void willCancel(const ResourceError&) override;
</span><span class="cx"> void didCancel(const ResourceError&) override;
</span><ins>+ void didRetrieveDerivedDataFromCache(const String& type, SharedBuffer&) override;
</ins><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA) && !USE(CFURLCONNECTION)
</span><span class="cx"> NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -258,6 +258,8 @@
</span><span class="cx">
</span><span class="cx"> virtual void didSendData(unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { }
</span><span class="cx">
</span><ins>+ virtual void didRetrieveDerivedDataFromCache(const String& /* type */, SharedBuffer&) { }
+
</ins><span class="cx"> void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; }
</span><span class="cx"> double loadFinishTime() const { return m_loadFinishTime; }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -1313,7 +1313,7 @@
</span><span class="cx">
</span><span class="cx"> const ResourceLoaderOptions& CachedResourceLoader::defaultCachedResourceOptions()
</span><span class="cx"> {
</span><del>- static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, ClientCredentialPolicy::MayAskClientForCredentials, FetchOptions::Credentials::Include, DoSecurityCheck, FetchOptions::Mode::NoCors, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching);
</del><ins>+ static NeverDestroyed<ResourceLoaderOptions> options(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, ClientCredentialPolicy::MayAskClientForCredentials, FetchOptions::Credentials::Include, DoSecurityCheck, FetchOptions::Mode::NoCors, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching);
</ins><span class="cx"> return options;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceResponseBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include "NetworkLoadTiming.h"
</span><span class="cx"> #include "ParsedContentRange.h"
</span><span class="cx"> #include "URL.h"
</span><ins>+#include <wtf/SHA1.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -135,6 +136,9 @@
</span><span class="cx"> WEBCORE_EXPORT Source source() const;
</span><span class="cx"> WEBCORE_EXPORT void setSource(Source);
</span><span class="cx">
</span><ins>+ const std::optional<SHA1::Digest>& cacheBodyKey() const { return m_cacheBodyKey; }
+ void setCacheBodyKey(const SHA1::Digest& key) { m_cacheBodyKey = key; }
+
</ins><span class="cx"> NetworkLoadTiming& networkLoadTiming() const { return m_networkLoadTiming; }
</span><span class="cx">
</span><span class="cx"> // The ResourceResponse subclass may "shadow" this method to provide platform-specific memory usage information
</span><span class="lines">@@ -210,6 +214,8 @@
</span><span class="cx">
</span><span class="cx"> Source m_source { Source::Unknown };
</span><span class="cx">
</span><ins>+ std::optional<SHA1::Digest> m_cacheBodyKey;
+
</ins><span class="cx"> Type m_type { Type::Default };
</span><span class="cx"> bool m_isRedirected { false };
</span><span class="cx"> };
</span><span class="lines">@@ -241,6 +247,7 @@
</span><span class="cx"> encoder << m_httpStatusCode;
</span><span class="cx"> encoder << m_certificateInfo;
</span><span class="cx"> encoder.encodeEnum(m_source);
</span><ins>+ encoder << m_cacheBodyKey;
</ins><span class="cx"> encoder.encodeEnum(m_type);
</span><span class="cx"> encoder << m_isRedirected;
</span><span class="cx"> }
</span><span class="lines">@@ -280,6 +287,8 @@
</span><span class="cx"> return false;
</span><span class="cx"> if (!decoder.decodeEnum(response.m_source))
</span><span class="cx"> return false;
</span><ins>+ if (!decoder.decode(response.m_cacheBodyKey))
+ return false;
</ins><span class="cx"> if (!decoder.decodeEnum(response.m_type))
</span><span class="cx"> return false;
</span><span class="cx"> if (!decoder.decode(response.m_isRedirected))
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit/ChangeLog 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2017-01-17 Antti Koivisto <antti at apple.com>
+
+ Persist derived data
+ https://bugs.webkit.org/show_bug.cgi?id=167136
+
+ Reviewed by Andreas Kling.
+
+ * WebCoreSupport/WebResourceLoadScheduler.h:
+
</ins><span class="cx"> 2017-01-05 Per Arne Vollan <pvollan at apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Compile error.
</span></span></pre></div>
<a id="trunkSourceWebKitWebCoreSupportWebResourceLoadSchedulerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebCoreSupport/WebResourceLoadScheduler.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebCoreSupport/WebResourceLoadScheduler.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit/WebCoreSupport/WebResourceLoadScheduler.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -56,6 +56,8 @@
</span><span class="cx">
</span><span class="cx"> void createPingHandle(WebCore::NetworkingContext*, WebCore::ResourceRequest&, bool shouldUseCredentialStorage, bool shouldFollowRedirects) override;
</span><span class="cx">
</span><ins>+ void storeDerivedDataToCache(const SHA1::Digest&, const String&, const String&, WebCore::SharedBuffer&) override { }
+
</ins><span class="cx"> bool isSerialLoadingEnabled() const { return m_isSerialLoadingEnabled; }
</span><span class="cx"> void setSerialLoadingEnabled(bool b) { m_isSerialLoadingEnabled = b; }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/ChangeLog 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -1,3 +1,74 @@
</span><ins>+2017-01-17 Antti Koivisto <antti at apple.com>
+
+ Persist derived data
+ https://bugs.webkit.org/show_bug.cgi?id=167136
+
+ Reviewed by Andreas Kling.
+
+ Add a mechanism for storing arbitrary data into disk cache.
+
+ From WebCore level data can be stored using
+
+ loaderStrategy()->storeDerivedDataToCache(key, partition, type, data);
+
+ The data is keyed with the body hash of a network resource. It can be retrieved along
+ with the resource by specifying the type in ResourceLoaderOptions. If a related data
+ blob is found it will be deliver via CachedResource::didRetrieveDerivedDataFromCache()
+ callback.
+
+ This patch adds the mechanism but doesn't yet use it for anything.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::storeDerivedDataToCache):
+ * NetworkProcess/NetworkConnectionToWebProcess.h:
+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+ * NetworkProcess/NetworkResourceLoadParameters.cpp:
+ (WebKit::NetworkResourceLoadParameters::encode):
+ (WebKit::NetworkResourceLoadParameters::decode):
+ * NetworkProcess/NetworkResourceLoadParameters.h:
+ * NetworkProcess/NetworkResourceLoader.cpp:
+ (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
+
+ Look for related resources to return if needed.
+
+ (WebKit::NetworkResourceLoader::sendResultForCacheEntry):
+ * NetworkProcess/NetworkResourceLoader.h:
+ * NetworkProcess/cache/NetworkCache.cpp:
+ (WebKit::NetworkCache::resourceType):
+ (WebKit::NetworkCache::Cache::retrieveData):
+ (WebKit::NetworkCache::Cache::storeData):
+ (WebKit::NetworkCache::Cache::makeCacheKey): Deleted.
+ * NetworkProcess/cache/NetworkCache.h:
+ * NetworkProcess/cache/NetworkCacheEntry.cpp:
+ (WebKit::NetworkCache::Entry::encodeAsStorageRecord):
+ (WebKit::NetworkCache::Entry::decodeStorageRecord):
+ * NetworkProcess/cache/NetworkCacheKey.cpp:
+ (WebKit::NetworkCache::Key::Key):
+ * NetworkProcess/cache/NetworkCacheKey.h:
+ (WebKit::NetworkCache::DataKey::encode):
+ (WebKit::NetworkCache::DataKey::decode):
+ * NetworkProcess/cache/NetworkCacheStorage.cpp:
+ (WebKit::NetworkCache::Storage::readRecord):
+ (WebKit::NetworkCache::Storage::traverse):
+ * NetworkProcess/cache/NetworkCacheStorage.h:
+
+ Return body hash with the Record.
+
+ * NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
+ (WebKit::NetworkCache::SubresourcesEntry::encodeAsStorageRecord):
+ * Platform/IPC/ArgumentCoders.cpp:
+ (IPC::ArgumentCoder<SHA1::Digest>::encode):
+ (IPC::ArgumentCoder<SHA1::Digest>::decode):
+ * Platform/IPC/ArgumentCoders.h:
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::scheduleLoad):
+ (WebKit::WebLoaderStrategy::storeDerivedDataToCache):
+ * WebProcess/Network/WebLoaderStrategy.h:
+ * WebProcess/Network/WebResourceLoader.cpp:
+ (WebKit::WebResourceLoader::didRetrieveDerivedData):
+ * WebProcess/Network/WebResourceLoader.h:
+ * WebProcess/Network/WebResourceLoader.messages.in:
+
</ins><span class="cx"> 2017-01-17 Antoine Quint <graouts at apple.com>
</span><span class="cx">
</span><span class="cx"> [Modern Media Controls] Turn modern media controls on by default
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -27,7 +27,9 @@
</span><span class="cx"> #include "NetworkConnectionToWebProcess.h"
</span><span class="cx">
</span><span class="cx"> #include "BlobDataFileReferenceWithSandboxExtension.h"
</span><ins>+#include "DataReference.h"
</ins><span class="cx"> #include "NetworkBlobRegistry.h"
</span><ins>+#include "NetworkCache.h"
</ins><span class="cx"> #include "NetworkConnectionToWebProcessMessages.h"
</span><span class="cx"> #include "NetworkLoad.h"
</span><span class="cx"> #include "NetworkProcess.h"
</span><span class="lines">@@ -322,6 +324,11 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void NetworkConnectionToWebProcess::storeDerivedDataToCache(const WebKit::NetworkCache::DataKey& dataKey, const IPC::DataReference& data)
+{
+ NetworkCache::singleton().storeData(dataKey, data.data(), data.size());
+}
+
</ins><span class="cx"> void NetworkConnectionToWebProcess::ensureLegacyPrivateBrowsingSession()
</span><span class="cx"> {
</span><span class="cx"> NetworkProcess::singleton().ensurePrivateBrowsingSession(SessionID::legacyPrivateSessionID());
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -44,6 +44,10 @@
</span><span class="cx"> class SyncNetworkResourceLoader;
</span><span class="cx"> typedef uint64_t ResourceLoadIdentifier;
</span><span class="cx">
</span><ins>+namespace NetworkCache {
+struct DataKey;
+}
+
</ins><span class="cx"> class NetworkConnectionToWebProcess : public RefCounted<NetworkConnectionToWebProcess>, IPC::Connection::Client {
</span><span class="cx"> public:
</span><span class="cx"> static Ref<NetworkConnectionToWebProcess> create(IPC::Connection::Identifier);
</span><span class="lines">@@ -97,6 +101,8 @@
</span><span class="cx"> void unregisterBlobURL(const WebCore::URL&);
</span><span class="cx"> void writeBlobsToTemporaryFiles(const Vector<String>& blobURLs, uint64_t requestIdentifier);
</span><span class="cx">
</span><ins>+ void storeDerivedDataToCache(const WebKit::NetworkCache::DataKey&, const IPC::DataReference&);
+
</ins><span class="cx"> void ensureLegacyPrivateBrowsingSession();
</span><span class="cx">
</span><span class="cx"> Ref<IPC::Connection> m_connection;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -50,5 +50,7 @@
</span><span class="cx"> BlobSize(WebCore::URL url) -> (uint64_t resultSize)
</span><span class="cx"> WriteBlobsToTemporaryFiles(Vector<String> blobURLs, uint64_t requestIdentifier)
</span><span class="cx">
</span><ins>+ StoreDerivedDataToCache(WebKit::NetworkCache::DataKey key, IPC::DataReference data)
+
</ins><span class="cx"> EnsureLegacyPrivateBrowsingSession()
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkResourceLoadParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -80,6 +80,7 @@
</span><span class="cx"> encoder << defersLoading;
</span><span class="cx"> encoder << needsCertificateInfo;
</span><span class="cx"> encoder << maximumBufferingTime;
</span><ins>+ encoder << derivedCachedDataTypesToRetrieve;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool NetworkResourceLoadParameters::decode(IPC::Decoder& decoder, NetworkResourceLoadParameters& result)
</span><span class="lines">@@ -141,6 +142,8 @@
</span><span class="cx"> return false;
</span><span class="cx"> if (!decoder.decode(result.maximumBufferingTime))
</span><span class="cx"> return false;
</span><ins>+ if (!decoder.decode(result.derivedCachedDataTypesToRetrieve))
+ return false;
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkResourceLoadParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoadParameters.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> Vector<RefPtr<SandboxExtension>> requestBodySandboxExtensions; // Created automatically for the sender.
</span><span class="cx"> RefPtr<SandboxExtension> resourceSandboxExtension; // Created automatically for the sender.
</span><span class="cx"> std::chrono::milliseconds maximumBufferingTime { 0ms };
</span><ins>+ Vector<String> derivedCachedDataTypesToRetrieve;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -563,25 +563,62 @@
</span><span class="cx"> if (isSynchronous()) {
</span><span class="cx"> m_synchronousLoadData->response = entry->response();
</span><span class="cx"> sendReplyToSynchronousRequest(*m_synchronousLoadData, entry->buffer());
</span><del>- } else {
- bool needsContinueDidReceiveResponseMessage = isMainResource();
- send(Messages::WebResourceLoader::DidReceiveResponse(entry->response(), needsContinueDidReceiveResponseMessage));
</del><ins>+ cleanup();
+ return;
+ }
</ins><span class="cx">
</span><del>-#if ENABLE(SHAREABLE_RESOURCE)
- if (!entry->shareableResourceHandle().isNull())
- send(Messages::WebResourceLoader::DidReceiveResource(entry->shareableResourceHandle(), currentTime()));
- else {
</del><ins>+ bool needsContinueDidReceiveResponseMessage = isMainResource();
+ send(Messages::WebResourceLoader::DidReceiveResponse(entry->response(), needsContinueDidReceiveResponseMessage));
+
+ if (entry->sourceStorageRecord().bodyHash && !m_parameters.derivedCachedDataTypesToRetrieve.isEmpty()) {
+#if ENABLE(CACHE_PARTITIONING)
+ String partition = originalRequest().cachePartition();
+#else
+ String partition;
</ins><span class="cx"> #endif
</span><del>- sendBuffer(*entry->buffer(), entry->buffer()->size());
- send(Messages::WebResourceLoader::DidFinishResourceLoad(currentTime()));
-#if ENABLE(SHAREABLE_RESOURCE)
</del><ins>+ auto bodyHash = *entry->sourceStorageRecord().bodyHash;
+ auto* entryPtr = entry.release();
+ auto retrieveCount = m_parameters.derivedCachedDataTypesToRetrieve.size();
+
+ for (auto& type : m_parameters.derivedCachedDataTypesToRetrieve) {
+ NetworkCache::DataKey key { partition, type, bodyHash };
+ NetworkCache::singleton().retrieveData(key, [loader = makeRef(*this), entryPtr, type, retrieveCount] (const uint8_t* data, size_t size) mutable {
+ loader->m_retrievedDerivedDataCount++;
+ bool retrievedAll = loader->m_retrievedDerivedDataCount == retrieveCount;
+ std::unique_ptr<NetworkCache::Entry> entry(retrievedAll ? entryPtr : nullptr);
+ if (loader->hasOneRef())
+ return;
+ if (data) {
+ IPC::DataReference dataReference(data, size);
+ loader->send(Messages::WebResourceLoader::DidRetrieveDerivedData(type, dataReference));
+ }
+ if (retrievedAll) {
+ loader->sendResultForCacheEntry(WTFMove(entry));
+ loader->cleanup();
+ }
+ });
</ins><span class="cx"> }
</span><del>-#endif
</del><ins>+ return;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ sendResultForCacheEntry(WTFMove(entry));
+
</ins><span class="cx"> cleanup();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void NetworkResourceLoader::sendResultForCacheEntry(std::unique_ptr<NetworkCache::Entry> entry)
+{
+#if ENABLE(SHAREABLE_RESOURCE)
+ if (!entry->shareableResourceHandle().isNull()) {
+ send(Messages::WebResourceLoader::DidReceiveResource(entry->shareableResourceHandle(), currentTime()));
+ return;
+ }
+#endif
+
+ sendBuffer(*entry->buffer(), entry->buffer()->size());
+ send(Messages::WebResourceLoader::DidFinishResourceLoad(currentTime()));
+}
+
</ins><span class="cx"> void NetworkResourceLoader::validateCacheEntry(std::unique_ptr<NetworkCache::Entry> entry)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!m_networkLoad);
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx"> void tryStoreAsCacheEntry();
</span><span class="cx"> void retrieveCacheEntry(const WebCore::ResourceRequest&);
</span><span class="cx"> void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>);
</span><ins>+ void sendResultForCacheEntry(std::unique_ptr<NetworkCache::Entry>);
</ins><span class="cx"> void validateCacheEntry(std::unique_ptr<NetworkCache::Entry>);
</span><span class="cx"> void dispatchWillSendRequestForCacheEntry(std::unique_ptr<NetworkCache::Entry>);
</span><span class="cx"> #endif
</span><span class="lines">@@ -154,6 +155,8 @@
</span><span class="cx"> bool m_defersLoading { false };
</span><span class="cx"> bool m_hasReceivedData { false };
</span><span class="cx">
</span><ins>+ unsigned m_retrievedDerivedDataCount { 0 };
+
</ins><span class="cx"> WebCore::Timer m_bufferingTimer;
</span><span class="cx"> #if ENABLE(NETWORK_CACHE)
</span><span class="cx"> RefPtr<WebCore::SharedBuffer> m_bufferedDataForCache;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -351,7 +351,7 @@
</span><span class="cx"> auto startTime = std::chrono::system_clock::now();
</span><span class="cx"> auto priority = static_cast<unsigned>(request.priority());
</span><span class="cx">
</span><del>- m_storage->retrieve(storageKey, priority, [this, request, completionHandler = WTFMove(completionHandler), startTime, storageKey, frameID](std::unique_ptr<Storage::Record> record) {
</del><ins>+ m_storage->retrieve(storageKey, priority, [this, request, completionHandler = WTFMove(completionHandler), startTime, storageKey, frameID](auto record) {
</ins><span class="cx"> if (!record) {
</span><span class="cx"> LOG(NetworkCache, "(NetworkProcess) not found in storage");
</span><span class="cx">
</span><span class="lines">@@ -615,7 +615,31 @@
</span><span class="cx"> return m_storage ? m_storage->recordsPath() : String();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void Cache::retrieveData(const DataKey& dataKey, Function<void (const uint8_t* data, size_t size)> completionHandler)
+{
+ ASSERT(isEnabled());
+
+ Key key { dataKey, m_storage->salt() };
+ m_storage->retrieve(key, 4, [completionHandler = WTFMove(completionHandler)] (auto record) {
+ if (!record || !record->body.size()) {
+ completionHandler(nullptr, 0);
+ return true;
+ }
+ completionHandler(record->body.data(), record->body.size());
+ return true;
+ });
</ins><span class="cx"> }
</span><ins>+
+void Cache::storeData(const DataKey& dataKey, const uint8_t* data, size_t size)
+{
+ if (!m_storage)
+ return;
+ Key key { dataKey, m_storage->salt() };
+ Storage::Record record { key, std::chrono::system_clock::now(), { }, Data { data, size }, { } };
+ m_storage->store(record, { });
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -121,6 +121,9 @@
</span><span class="cx"> void clear();
</span><span class="cx"> void clear(std::chrono::system_clock::time_point modifiedSince, Function<void ()>&& completionHandler);
</span><span class="cx">
</span><ins>+ void retrieveData(const DataKey&, Function<void (const uint8_t* data, size_t size)>);
+ void storeData(const DataKey&, const uint8_t* data, size_t);
+
</ins><span class="cx"> void dumpContentsToFile();
</span><span class="cx">
</span><span class="cx"> String recordsPath() const;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheEntrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> if (m_buffer)
</span><span class="cx"> body = { reinterpret_cast<const uint8_t*>(m_buffer->data()), m_buffer->size() };
</span><span class="cx">
</span><del>- return { m_key, m_timeStamp, header, body };
</del><ins>+ return { m_key, m_timeStamp, header, body, { } };
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<Entry> Entry::decodeStorageRecord(const Storage::Record& storageEntry)
</span><span class="lines">@@ -112,6 +112,8 @@
</span><span class="cx"> if (!decoder.decode(entry->m_response))
</span><span class="cx"> return nullptr;
</span><span class="cx"> entry->m_response.setSource(WebCore::ResourceResponse::Source::DiskCache);
</span><ins>+ if (storageEntry.bodyHash)
+ entry->m_response.setCacheBodyKey(*storageEntry.bodyHash);
</ins><span class="cx">
</span><span class="cx"> bool hasVaryingRequestHeaders;
</span><span class="cx"> if (!decoder.decode(hasVaryingRequestHeaders))
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheKeycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -64,6 +64,15 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Key::Key(const DataKey& dataKey, const Salt& salt)
+ : m_partition(dataKey.partition)
+ , m_type(dataKey.type)
+ , m_identifier(hashAsString(dataKey.identifier))
+ , m_hash(computeHash(salt))
+ , m_partitionHash(computePartitionHash(salt))
+{
+}
+
</ins><span class="cx"> Key& Key::operator=(const Key& other)
</span><span class="cx"> {
</span><span class="cx"> m_partition = other.m_partition.isolatedCopy();
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheKeyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -36,6 +36,22 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> namespace NetworkCache {
</span><span class="cx">
</span><ins>+struct DataKey {
+ String partition;
+ String type;
+ SHA1::Digest identifier;
+
+ template <class Encoder> void encode(Encoder& encoder) const
+ {
+ encoder << partition << type << identifier;
+ }
+
+ template <class Decoder> static bool decode(Decoder& decoder, DataKey& dataKey)
+ {
+ return decoder.decode(dataKey.partition) && decoder.decode(dataKey.type) && decoder.decode(dataKey.identifier);
+ }
+};
+
</ins><span class="cx"> class Key {
</span><span class="cx"> public:
</span><span class="cx"> typedef SHA1::Digest HashType;
</span><span class="lines">@@ -44,6 +60,7 @@
</span><span class="cx"> Key(const Key&);
</span><span class="cx"> Key(Key&&) = default;
</span><span class="cx"> Key(const String& partition, const String& type, const String& range, const String& identifier, const Salt&);
</span><ins>+ Key(const DataKey&, const Salt&);
</ins><span class="cx">
</span><span class="cx"> Key& operator=(const Key&);
</span><span class="cx"> Key& operator=(Key&&) = default;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheStoragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -458,7 +458,8 @@
</span><span class="cx"> metaData.key,
</span><span class="cx"> timeStamp,
</span><span class="cx"> headerData,
</span><del>- bodyData
</del><ins>+ bodyData,
+ metaData.bodyHash
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -837,7 +838,8 @@
</span><span class="cx"> metaData.key,
</span><span class="cx"> std::chrono::system_clock::time_point(metaData.epochRelativeTimeStamp),
</span><span class="cx"> headerData,
</span><del>- { }
</del><ins>+ { },
+ metaData.bodyHash
</ins><span class="cx"> };
</span><span class="cx"> RecordInfo info {
</span><span class="cx"> static_cast<size_t>(metaData.bodySize),
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheStorageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> std::chrono::system_clock::time_point timeStamp;
</span><span class="cx"> Data header;
</span><span class="cx"> Data body;
</span><ins>+ std::optional<SHA1::Digest> bodyHash;
</ins><span class="cx"> };
</span><span class="cx"> // This may call completion handler synchronously on failure.
</span><span class="cx"> typedef Function<bool (std::unique_ptr<Record>)> RetrieveCompletionHandler;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheSubresourcesEntrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx">
</span><span class="cx"> encoder.encodeChecksum();
</span><span class="cx">
</span><del>- return { m_key, m_timeStamp, { encoder.buffer(), encoder.bufferSize() } , { } };
</del><ins>+ return { m_key, m_timeStamp, { encoder.buffer(), encoder.bufferSize() }, { }, { }};
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<SubresourcesEntry> SubresourcesEntry::decodeStorageRecord(const Storage::Record& storageEntry)
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCArgumentCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -162,4 +162,15 @@
</span><span class="cx"> return decodeStringText<UChar>(decoder, length, result);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+void ArgumentCoder<SHA1::Digest>::encode(Encoder& encoder, const SHA1::Digest& digest)
+{
+ encoder.encodeFixedLengthData(digest.data(), sizeof(digest), 1);
+}
+
+bool ArgumentCoder<SHA1::Digest>::decode(Decoder& decoder, SHA1::Digest& digest)
+{
+ return decoder.decodeFixedLengthData(digest.data(), sizeof(digest), 1);
+}
+
</ins><span class="cx"> } // namespace IPC
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCArgumentCodersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/Platform/IPC/ArgumentCoders.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include <wtf/HashSet.h>
</span><span class="cx"> #include <wtf/OptionSet.h>
</span><span class="cx"> #include <wtf/Optional.h>
</span><ins>+#include <wtf/SHA1.h>
</ins><span class="cx"> #include <wtf/Variant.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="lines">@@ -399,4 +400,9 @@
</span><span class="cx"> static bool decode(Decoder&, String&);
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+template<> struct ArgumentCoder<SHA1::Digest> {
+ static void encode(Encoder&, const SHA1::Digest&);
+ static bool decode(Decoder&, SHA1::Digest&);
+};
+
</ins><span class="cx"> } // namespace IPC
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebLoaderStrategycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "WebLoaderStrategy.h"
</span><span class="cx">
</span><ins>+#include "DataReference.h"
</ins><span class="cx"> #include "HangDetectionDisabler.h"
</span><span class="cx"> #include "Logging.h"
</span><span class="cx"> #include "NetworkConnectionToWebProcessMessages.h"
</span><span class="lines">@@ -216,6 +217,7 @@
</span><span class="cx"> loadParameters.defersLoading = resourceLoader.defersLoading();
</span><span class="cx"> loadParameters.needsCertificateInfo = resourceLoader.shouldIncludeCertificateInfo();
</span><span class="cx"> loadParameters.maximumBufferingTime = maximumBufferingTime(resource);
</span><ins>+ loadParameters.derivedCachedDataTypesToRetrieve = resourceLoader.options().derivedCachedDataTypesToRetrieve;
</ins><span class="cx">
</span><span class="cx"> ASSERT((loadParameters.webPageID && loadParameters.webFrameID) || loadParameters.clientCredentialPolicy == ClientCredentialPolicy::CannotAskClientForCredentials);
</span><span class="cx">
</span><span class="lines">@@ -375,5 +377,11 @@
</span><span class="cx"> WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::LoadPing(loadParameters), 0);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebLoaderStrategy::storeDerivedDataToCache(const SHA1::Digest& bodyHash, const String& type, const String& partition, WebCore::SharedBuffer& data)
+{
+ NetworkCache::DataKey key { partition, type, bodyHash };
+ IPC::SharedBufferDataReference dataReference { &data };
+ WebProcess::singleton().networkConnection().connection().send(Messages::NetworkConnectionToWebProcess::StoreDerivedDataToCache(key, dataReference), 0);
+}
</ins><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebLoaderStrategyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -57,6 +57,8 @@
</span><span class="cx">
</span><span class="cx"> void createPingHandle(WebCore::NetworkingContext*, WebCore::ResourceRequest&, bool shouldUseCredentialStorage, bool shouldFollowRedirects) override;
</span><span class="cx">
</span><ins>+ void storeDerivedDataToCache(const SHA1::Digest& bodyHash, const String& type, const String& partition, WebCore::SharedBuffer&) override;
+
</ins><span class="cx"> WebResourceLoader* webResourceLoaderForIdentifier(ResourceLoadIdentifier identifier) const { return m_webResourceLoaders.get(identifier); }
</span><span class="cx"> RefPtr<WebCore::NetscapePlugInStreamLoader> schedulePluginStreamLoad(WebCore::Frame&, WebCore::NetscapePlugInStreamLoaderClient&, const WebCore::ResourceRequest&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -135,6 +135,14 @@
</span><span class="cx"> m_coreLoader->didReceiveData(reinterpret_cast<const char*>(data.data()), data.size(), encodedDataLength, DataPayloadBytes);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebResourceLoader::didRetrieveDerivedData(const String& type, const IPC::DataReference& data)
+{
+ LOG(Network, "(WebProcess) WebResourceLoader::didRetrieveDerivedData of size %lu for '%s'", data.size(), m_coreLoader->url().string().latin1().data());
+
+ auto buffer = SharedBuffer::create(data.data(), data.size());
+ m_coreLoader->didRetrieveDerivedDataFromCache(type, buffer.get());
+}
+
</ins><span class="cx"> void WebResourceLoader::didFinishResourceLoad(double finishTime)
</span><span class="cx"> {
</span><span class="cx"> LOG(Network, "(WebProcess) WebResourceLoader::didFinishResourceLoad for '%s'", m_coreLoader->url().string().latin1().data());
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -78,6 +78,7 @@
</span><span class="cx"> void didSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent);
</span><span class="cx"> void didReceiveResponse(const WebCore::ResourceResponse&, bool needsContinueDidReceiveResponseMessage);
</span><span class="cx"> void didReceiveData(const IPC::DataReference&, int64_t encodedDataLength);
</span><ins>+ void didRetrieveDerivedData(const String& type, const IPC::DataReference&);
</ins><span class="cx"> void didFinishResourceLoad(double finishTime);
</span><span class="cx"> void didFailResourceLoad(const WebCore::ResourceError&);
</span><span class="cx"> #if ENABLE(SHAREABLE_RESOURCE)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in (210834 => 210835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in 2017-01-18 00:42:57 UTC (rev 210834)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in 2017-01-18 01:14:33 UTC (rev 210835)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> DidReceiveResponse(WebCore::ResourceResponse response, bool needsContinueDidReceiveResponseMessage)
</span><span class="cx"> DidReceiveData(IPC::DataReference data, int64_t encodedDataLength)
</span><span class="cx"> DidFinishResourceLoad(double finishTime)
</span><ins>+ DidRetrieveDerivedData(String type, IPC::DataReference data)
</ins><span class="cx"> DidFailResourceLoad(WebCore::ResourceError error)
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SHAREABLE_RESOURCE)
</span></span></pre>
</div>
</div>
</body>
</html>
More information about the webkit-changes
mailing list