Make storing cross-origin top-level prefetches in HTTP cache optional
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 07:29:55 +0000 (07:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 07:29:55 +0000 (07:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199499

Patch by Rob Buis <rbuis@igalia.com> on 2019-07-26
Reviewed by Youenn Fablet.

Source/WebCore:

Add Internals API for adding an event listener to prefetch load.

Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html

* bindings/js/JSEventListener.h:
* dom/EventTarget.h:
(WebCore::EventTarget::addEventListener):
* dom/Node.h:
* html/HTMLLinkElement.h:
* testing/Internals.cpp:
(WebCore::Internals::addPrefetchLoadEventListener):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Currently when we navigate we check if there is a cross-origin top-level
prefetch we can use for the navigation. The current solution uses the
HTTP cache as a way to store the prefetch and to immediately use it for
the navigation load. However this solution fails in case the prefetch is
not cacheable.

Instead of this, simulate a HTTP Cache entry to process the load and
afterwards try to store the navigation load into the HTTP cache, where
normal store decisions will be applied.

Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::retrieveCacheEntry):
(WebKit::NetworkResourceLoader::retrieveCacheEntryInternal):
* NetworkProcess/NetworkResourceLoader.h:

LayoutTests:

Remove unneeded Cache-Control headers and verify that Cache-Control
effects whether the navigation gets stored in the disk cache or not.

* http/tests/cache/resources/prefetched-main-resource-iframe.php:
* http/tests/cache/resources/prefetched-main-resource.php:
* http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt: Added.
* http/wpt/prefetch/link-prefetch-skip-disk-cache.html: Added.
* http/wpt/prefetch/resources/main-resource-skip-disk-cache.py: Added.
(main):
* http/wpt/prefetch/resources/navigate-skip-disk-cache.html: Added.
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247860 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/cache/resources/prefetched-main-resource-iframe.php
LayoutTests/http/tests/cache/resources/prefetched-main-resource.php
LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache.html [new file with mode: 0644]
LayoutTests/http/wpt/prefetch/resources/main-resource-skip-disk-cache.py [new file with mode: 0644]
LayoutTests/http/wpt/prefetch/resources/navigate-skip-disk-cache.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSEventListener.h
Source/WebCore/dom/EventTarget.h
Source/WebCore/dom/Node.h
Source/WebCore/html/HTMLLinkElement.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoader.h

index 0835b26..4ea8d70 100644 (file)
@@ -1,3 +1,23 @@
+2019-07-26  Rob Buis  <rbuis@igalia.com>
+
+        Make storing cross-origin top-level prefetches in HTTP cache optional
+        https://bugs.webkit.org/show_bug.cgi?id=199499
+
+        Reviewed by Youenn Fablet.
+
+        Remove unneeded Cache-Control headers and verify that Cache-Control
+        effects whether the navigation gets stored in the disk cache or not.
+
+        * http/tests/cache/resources/prefetched-main-resource-iframe.php:
+        * http/tests/cache/resources/prefetched-main-resource.php:
+        * http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt: Added.
+        * http/wpt/prefetch/link-prefetch-skip-disk-cache.html: Added.
+        * http/wpt/prefetch/resources/main-resource-skip-disk-cache.py: Added.
+        (main):
+        * http/wpt/prefetch/resources/navigate-skip-disk-cache.html: Added.
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+
 2019-07-25  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r247806.
index a7ad2e9..65da64c 100644 (file)
@@ -1,8 +1,5 @@
 <?php
 if ($_SERVER["HTTP_PURPOSE"] == "prefetch") {
-    header('Cache-Control: max-age=3600');
-    header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
-
     echo "<script>";
     echo "parent.window.postMessage('FAIL', '*');";
     echo "</script>";
@@ -10,8 +7,6 @@ if ($_SERVER["HTTP_PURPOSE"] == "prefetch") {
     exit();
 }
 
-header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
-
 echo "<script>";
 echo "parent.window.postMessage('PASS', '*');";
 echo "</script>";
index 7a3ceb4..f6aac10 100644 (file)
@@ -6,16 +6,16 @@ header('Cache-Control: max-age=3600');
 <body>
 <script>
 
-if (window.testRunner)
-   testRunner.notifyDone();
+if (window.testRunner) {
+  fetch('http://localhost:8000/cache/resources/prefetched-main-resource.php').then(function(response) {
+    if (internals.fetchResponseSource(response) != "Disk cache") {
+      document.getElementById('log').innerText = 'FAIL: resource is not in the disk cache.';
+    }
+    testRunner.notifyDone();
+  });
+}
 
 </script>
-<?php
-if ($_SERVER["HTTP_PURPOSE"] == "prefetch") {
-    print('PASS');
-} else {
-    print('FAIL');
-}
-?>
+<div id="log"><?php if ($_SERVER["HTTP_PURPOSE"] == "prefetch") echo 'PASS'; else echo 'FAIL'; ?></div>
 </body>
 </html>
diff --git a/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt b/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache-expected.txt
new file mode 100644 (file)
index 0000000..9b6c11a
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Verify that navigating to a main resource can skip disk cache. 
+
diff --git a/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache.html b/LayoutTests/http/wpt/prefetch/link-prefetch-skip-disk-cache.html
new file mode 100644 (file)
index 0000000..8509b92
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+
+const wait_for_message = () => {
+  return new Promise((resolve, reject) => {
+    window.addEventListener('message', e => {
+      resolve(e);
+    }, { once: true });
+  });
+};
+
+promise_test(async function(t) {
+  let url_from = "resources/navigate-skip-disk-cache.html";
+  var w = window.open(url_from);
+  let message = await wait_for_message();
+  assert_equals(message.data, 'prefetch');
+  w.close();
+}, 'Verify that navigating to a main resource can skip disk cache.');
+</script>
diff --git a/LayoutTests/http/wpt/prefetch/resources/main-resource-skip-disk-cache.py b/LayoutTests/http/wpt/prefetch/resources/main-resource-skip-disk-cache.py
new file mode 100644 (file)
index 0000000..a037fef
--- /dev/null
@@ -0,0 +1,21 @@
+def main(request, response):
+    headers = [("Content-Type", "text/html")]
+
+    document = """
+<!DOCTYPE html>
+<script>
+  async function test() {
+  var result = '%(prefetch)s';
+  if (window.testRunner) {
+    var response = await fetch('%(url)s');
+    if (internals.fetchResponseSource(response) == "Disk cache") {
+      result = 'FAIL.';
+    }
+  }
+  window.opener.postMessage(result, '*');
+  }
+</script>
+<body onload="test()">
+"""
+
+    return headers, document % {'prefetch': request.headers.get("Purpose", ""), 'url': request.url }
diff --git a/LayoutTests/http/wpt/prefetch/resources/navigate-skip-disk-cache.html b/LayoutTests/http/wpt/prefetch/resources/navigate-skip-disk-cache.html
new file mode 100644 (file)
index 0000000..e607630
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+<script>
+  var link = document.createElement("link");
+  link.rel = "prefetch";
+  link.href = get_host_info().HTTP_REMOTE_ORIGIN + "/WebKit/prefetch/resources/main-resource-skip-disk-cache.py";
+  document.body.appendChild(link);
+  internals.addPrefetchLoadEventListener(link, () => { window.location = get_host_info().HTTP_REMOTE_ORIGIN + "/WebKit/prefetch/resources/main-resource-skip-disk-cache.py" });
+</script>
+</body>
index eafb29b..5940c9c 100644 (file)
@@ -736,6 +736,7 @@ webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource.html [ Skip ]
 webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource-iframe.html [ Skip ]
 
 webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ]
+webkit.org/b/199499 http/wpt/prefetch/link-prefetch-skip-disk-cache.html [ Skip ]
 
 webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ]
 webkit.org/b/199632 http/wpt/prefetch/beforeload-dynamic.html [ Skip ]
index d50ab73..c6543cf 100644 (file)
@@ -4424,6 +4424,7 @@ webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource.html [ Skip ]
 webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource-iframe.html [ Skip ]
 
 webkit.org/b/197371 http/wpt/prefetch/link-prefetch-main-resource-redirect.html [ Skip ]
+webkit.org/b/199499 http/wpt/prefetch/link-prefetch-skip-disk-cache.html [ Skip ]
 
 webkit.org/b/199632 http/wpt/prefetch/beforeload.html [ Skip ]
 webkit.org/b/199632 http/wpt/prefetch/beforeload-dynamic.html [ Skip ]
index b441b5a..b531bee 100644 (file)
@@ -1,3 +1,24 @@
+2019-07-26  Rob Buis  <rbuis@igalia.com>
+
+        Make storing cross-origin top-level prefetches in HTTP cache optional
+        https://bugs.webkit.org/show_bug.cgi?id=199499
+
+        Reviewed by Youenn Fablet.
+
+        Add Internals API for adding an event listener to prefetch load.
+
+        Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html
+
+        * bindings/js/JSEventListener.h:
+        * dom/EventTarget.h:
+        (WebCore::EventTarget::addEventListener):
+        * dom/Node.h:
+        * html/HTMLLinkElement.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::addPrefetchLoadEventListener):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-07-25  Tim Horton  <timothy_horton@apple.com>
 
         Subpixel fringes around TextIndicator snapshots at non-integral scale factors
index c4668bf..8263b8d 100644 (file)
@@ -38,8 +38,8 @@ class HTMLElement;
 
 class JSEventListener : public EventListener {
 public:
-    static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
-    static RefPtr<JSEventListener> create(JSC::JSValue listener, JSC::JSObject& wrapper, bool isAttribute, DOMWrapperWorld&);
+    WEBCORE_EXPORT static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
+    WEBCORE_EXPORT static RefPtr<JSEventListener> create(JSC::JSValue listener, JSC::JSObject& wrapper, bool isAttribute, DOMWrapperWorld&);
 
     virtual ~JSEventListener();
 
index f82ae52..720a33b 100644 (file)
@@ -88,7 +88,7 @@ public:
     WEBCORE_EXPORT void removeEventListenerForBindings(const AtomString& eventType, RefPtr<EventListener>&&, ListenerOptionsOrBoolean&&);
     WEBCORE_EXPORT ExceptionOr<bool> dispatchEventForBindings(Event&);
 
-    virtual bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions& = { });
+    WEBCORE_EXPORT virtual bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions& = { });
     virtual bool removeEventListener(const AtomString& eventType, EventListener&, const ListenerOptions&);
 
     virtual void removeAllEventListeners();
index 5f85223..63e3c42 100644 (file)
@@ -472,7 +472,7 @@ public:
     EventTargetInterface eventTargetInterface() const override;
     ScriptExecutionContext* scriptExecutionContext() const final; // Implemented in Document.h
 
-    bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
+    WEBCORE_EXPORT bool addEventListener(const AtomString& eventType, Ref<EventListener>&&, const AddEventListenerOptions&) override;
     bool removeEventListener(const AtomString& eventType, EventListener&, const ListenerOptions&) override;
 
     using EventTarget::dispatchEvent;
index c83ea39..f4bc72b 100644 (file)
@@ -48,7 +48,7 @@ public:
     virtual ~HTMLLinkElement();
 
     URL href() const;
-    const AtomString& rel() const;
+    WEBCORE_EXPORT const AtomString& rel() const;
 
     String target() const final;
 
index 1c881a9..14c20e9 100644 (file)
@@ -68,6 +68,8 @@
 #include "Editor.h"
 #include "Element.h"
 #include "EventHandler.h"
+#include "EventListener.h"
+#include "EventNames.h"
 #include "ExtendableEvent.h"
 #include "ExtensionStyleSheets.h"
 #include "FetchResponse.h"
@@ -5144,4 +5146,10 @@ Internals::TextIndicatorInfo Internals::textIndicatorForRange(const Range& range
     return indicator->data();
 }
 
+void Internals::addPrefetchLoadEventListener(HTMLLinkElement& link, RefPtr<EventListener>&& listener)
+{
+    if (RuntimeEnabledFeatures::sharedFeatures().linkPrefetchEnabled() && equalLettersIgnoringASCIICase(link.rel(), "prefetch"))
+        link.addEventListener(eventNames().loadEvent, listener.releaseNonNull(), false);
+}
+
 } // namespace WebCore
index e7d34f6..468fb83 100644 (file)
@@ -59,6 +59,7 @@ class DOMURL;
 class DOMWindow;
 class Document;
 class Element;
+class EventListener;
 class ExtendableEvent;
 class FetchResponse;
 class File;
@@ -866,6 +867,8 @@ public:
 
     TextIndicatorInfo textIndicatorForRange(const Range&, TextIndicatorOptions);
 
+    void addPrefetchLoadEventListener(HTMLLinkElement&, RefPtr<EventListener>&&);
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;
index 99787e3..aa50bcc 100644 (file)
@@ -781,4 +781,6 @@ enum CompositingPolicy {
     void setIsPlayingToAutomotiveHeadUnit(boolean value);
 
     TextIndicatorInfo textIndicatorForRange(Range range, TextIndicatorOptions options);
+
+    void addPrefetchLoadEventListener(HTMLLinkElement link, EventListener? callback);
 };
index 9296b95..f837f24 100644 (file)
@@ -1,3 +1,27 @@
+2019-07-26  Rob Buis  <rbuis@igalia.com>
+
+        Make storing cross-origin top-level prefetches in HTTP cache optional
+        https://bugs.webkit.org/show_bug.cgi?id=199499
+
+        Reviewed by Youenn Fablet.
+
+        Currently when we navigate we check if there is a cross-origin top-level
+        prefetch we can use for the navigation. The current solution uses the
+        HTTP cache as a way to store the prefetch and to immediately use it for
+        the navigation load. However this solution fails in case the prefetch is
+        not cacheable.
+
+        Instead of this, simulate a HTTP Cache entry to process the load and
+        afterwards try to store the navigation load into the HTTP cache, where
+        normal store decisions will be applied.
+
+        Test: http/wpt/prefetch/link-prefetch-skip-disk-cache.html
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::retrieveCacheEntry):
+        (WebKit::NetworkResourceLoader::retrieveCacheEntryInternal):
+        * NetworkProcess/NetworkResourceLoader.h:
+
 2019-07-25  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed build fix in NetworkDataTaskSoup.
index 5ca46df..2ea75d6 100644 (file)
@@ -218,11 +218,19 @@ void NetworkResourceLoader::retrieveCacheEntry(const ResourceRequest& request)
         ASSERT(m_parameters.options.mode == FetchOptions::Mode::Navigate);
         if (auto* session = m_connection->networkProcess().networkSession(sessionID())) {
             if (auto entry = session->prefetchCache().take(request.url())) {
+                // FIXME: Deal with credentials (https://bugs.webkit.org/show_bug.cgi?id=200000)
                 if (!entry->redirectRequest.isNull()) {
+                    auto cacheEntry = m_cache->makeRedirectEntry(request, entry->response, entry->redirectRequest);
+                    loader->retrieveCacheEntryInternal(WTFMove(cacheEntry), ResourceRequest { request });
                     auto maxAgeCap = validateCacheEntryForMaxAgeCapValidation(request, entry->redirectRequest, entry->response);
                     m_cache->storeRedirect(request, entry->response, entry->redirectRequest, maxAgeCap);
-                } else
-                    m_cache->store(request, entry->response, entry->releaseBuffer(), nullptr);
+                    return;
+                }
+                auto buffer = entry->releaseBuffer();
+                auto cacheEntry = m_cache->makeEntry(request, entry->response, buffer.copyRef());
+                loader->retrieveCacheEntryInternal(WTFMove(cacheEntry), ResourceRequest { request });
+                m_cache->store(request, entry->response, WTFMove(buffer), nullptr);
+                return;
             }
         }
     }
@@ -239,33 +247,38 @@ void NetworkResourceLoader::retrieveCacheEntry(const ResourceRequest& request)
             loader->startNetworkLoad(WTFMove(request), FirstLoad::Yes);
             return;
         }
+        loader->retrieveCacheEntryInternal(WTFMove(entry), WTFMove(request));
+    });
+}
+
+void NetworkResourceLoader::retrieveCacheEntryInternal(std::unique_ptr<NetworkCache::Entry>&& entry, WebCore::ResourceRequest&& request)
+{
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-        if (entry->hasReachedPrevalentResourceAgeCap()) {
-            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource has reached prevalent resource age cap (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-            m_cacheEntryForMaxAgeCapValidation = WTFMove(entry);
-            ResourceRequest revalidationRequest = originalRequest();
-            loader->startNetworkLoad(WTFMove(revalidationRequest), FirstLoad::Yes);
-            return;
-        }
+    if (entry->hasReachedPrevalentResourceAgeCap()) {
+        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource has reached prevalent resource age cap (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+        m_cacheEntryForMaxAgeCapValidation = WTFMove(entry);
+        ResourceRequest revalidationRequest = originalRequest();
+        startNetworkLoad(WTFMove(revalidationRequest), FirstLoad::Yes);
+        return;
+    }
 #endif
-        if (entry->redirectRequest()) {
-            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Handling redirect (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-            loader->dispatchWillSendRequestForCacheEntry(WTFMove(request), WTFMove(entry));
-            return;
-        }
-        if (loader->m_parameters.needsCertificateInfo && !entry->response().certificateInfo()) {
-            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource does not have required certificate (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-            loader->startNetworkLoad(WTFMove(request), FirstLoad::Yes);
-            return;
-        }
-        if (entry->needsValidation() || request.cachePolicy() == WebCore::ResourceRequestCachePolicy::RefreshAnyCacheData) {
-            RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Validating cache entry (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-            loader->validateCacheEntry(WTFMove(entry));
-            return;
-        }
-        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Retrieved resource from cache (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
-        loader->didRetrieveCacheEntry(WTFMove(entry));
-    });
+    if (entry->redirectRequest()) {
+        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Handling redirect (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+        dispatchWillSendRequestForCacheEntry(WTFMove(request), WTFMove(entry));
+        return;
+    }
+    if (m_parameters.needsCertificateInfo && !entry->response().certificateInfo()) {
+        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Resource does not have required certificate (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+        startNetworkLoad(WTFMove(request), FirstLoad::Yes);
+        return;
+    }
+    if (entry->needsValidation() || request.cachePolicy() == WebCore::ResourceRequestCachePolicy::RefreshAnyCacheData) {
+        RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Validating cache entry (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+        validateCacheEntry(WTFMove(entry));
+        return;
+    }
+    RELEASE_LOG_IF_ALLOWED("retrieveCacheEntry: Retrieved resource from cache (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ", isMainResource = %d, isSynchronous = %d)", m_parameters.webPageID.toUInt64(), m_parameters.webFrameID, m_parameters.identifier, isMainResource(), isSynchronous());
+    didRetrieveCacheEntry(WTFMove(entry));
 }
 
 void NetworkResourceLoader::startNetworkLoad(ResourceRequest&& request, FirstLoad load)
index 4b4ce4f..1514e39 100644 (file)
@@ -129,6 +129,7 @@ private:
 
     void tryStoreAsCacheEntry();
     void retrieveCacheEntry(const WebCore::ResourceRequest&);
+    void retrieveCacheEntryInternal(std::unique_ptr<NetworkCache::Entry>&&, WebCore::ResourceRequest&&);
     void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>);
     void sendResultForCacheEntry(std::unique_ptr<NetworkCache::Entry>);
     void validateCacheEntry(std::unique_ptr<NetworkCache::Entry>);