Title: [278717] trunk
Revision
278717
Author
[email protected]
Date
2021-06-10 12:02:51 -0700 (Thu, 10 Jun 2021)

Log Message

Only cache GET requests in the memory cache
https://bugs.webkit.org/show_bug.cgi?id=226359

Reviewed by Geoff Garen.

Source/WebCore:

Test: http/tests/cache/memory-cache-only-caches-get.html

We only cache GET requests at the disk cache level, but we don't have that same restriction
at the memory cache level. We should make the policies match. In particular, in long-running
webpages, we're accumulating POSTs from XMLHttpRequests in our memory cache and should stop
doing that, since POST response caching is generally not used or expected.

I also changed InspectorInstrumentation::willSendRequest to take an optional CachedResource
parameter because it currently uses InspectorPageAgent::cachedResource to find the resource,
which in turn expects to find the resource in the memory cache. That doesn't work anymore
for these non-GET requests, so we now pass down the CachedResource explicitly in the cases
where that's necessary.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willSendRequestImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willSendRequest):
* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::resourceTypeForCachedResource):
(WebCore::InspectorNetworkAgent::willSendRequest):
* inspector/agents/InspectorNetworkAgent.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::tryLoadingSubstituteData):
(WebCore::DocumentLoader::addSubresourceLoader):
(WebCore::DocumentLoader::loadMainResource):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::requestFromDelegate):
* loader/ResourceLoadNotifier.cpp:
(WebCore::ResourceLoadNotifier::willSendRequest):
(WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
* loader/ResourceLoadNotifier.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequestInternal):
* loader/ResourceLoader.h:
(WebCore::ResourceLoader::cachedResource const):
* loader/SubresourceLoader.cpp:
* loader/SubresourceLoader.h:
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::update):
(WebCore::ApplicationCacheGroup::startLoadingEntry):
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::add):

LayoutTests:

Added tests to make sure only GETs end up in the memory cache.

Also fixed a flaky test that was depending on a POST response in an iframe to be in the
memory cache when doing a history navigation.

* http/tests/cache/memory-cache-only-caches-get-expected.txt: Added.
* http/tests/cache/memory-cache-only-caches-get.html: Added.
* http/tests/cache/resources/echo-cacheable.cgi: Added.
* http/tests/navigation/post-frames-goback1.html:
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278716 => 278717)


--- trunk/LayoutTests/ChangeLog	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/LayoutTests/ChangeLog	2021-06-10 19:02:51 UTC (rev 278717)
@@ -1,3 +1,21 @@
+2021-06-10  Ben Nham  <[email protected]>
+
+        Only cache GET requests in the memory cache
+        https://bugs.webkit.org/show_bug.cgi?id=226359
+
+        Reviewed by Geoff Garen.
+
+        Added tests to make sure only GETs end up in the memory cache.
+
+        Also fixed a flaky test that was depending on a POST response in an iframe to be in the
+        memory cache when doing a history navigation.
+
+        * http/tests/cache/memory-cache-only-caches-get-expected.txt: Added.
+        * http/tests/cache/memory-cache-only-caches-get.html: Added.
+        * http/tests/cache/resources/echo-cacheable.cgi: Added.
+        * http/tests/navigation/post-frames-goback1.html:
+        * platform/mac/TestExpectations:
+
 2021-06-10  Truitt Savell  <[email protected]>
 
         REGRESSION: (r278650 - r278655) service-workers/service-worker/credentials.https.html and content-security-policy/reporting/report-only-in-meta.sub.html failing together constantly.

Added: trunk/LayoutTests/http/tests/cache/memory-cache-only-caches-get-expected.txt (0 => 278717)


--- trunk/LayoutTests/http/tests/cache/memory-cache-only-caches-get-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/memory-cache-only-caches-get-expected.txt	2021-06-10 19:02:51 UTC (rev 278717)
@@ -0,0 +1,10 @@
+This test makes sure that only GET requests end up in the memory cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS origSize === internals.memoryCacheSize() is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/cache/memory-cache-only-caches-get.html (0 => 278717)


--- trunk/LayoutTests/http/tests/cache/memory-cache-only-caches-get.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/memory-cache-only-caches-get.html	2021-06-10 19:02:51 UTC (rev 278717)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function runTest() {
+    origSize = internals.memoryCacheSize();
+
+    let postFetch = fetch('resources/echo-cacheable.cgi', { method: 'POST' });
+    let putFetch = fetch('resources/echo-cacheable.cgi', { method: 'PUT' });
+    let deleteFetch = fetch('resources/echo-cacheable.cgi', { method: 'DELETE' });
+
+    Promise.all([postFetch, putFetch, deleteFetch])
+        .then(vals => {
+            shouldBeTrue("origSize === internals.memoryCacheSize()");
+        })
+        .catch(reason => {
+            testFailed(String(reason));
+        })
+        .finally(finishJSTest);
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<script>
+description("This test makes sure that only GET requests end up in the memory cache.");
+jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/cache/resources/echo-cacheable.cgi (0 => 278717)


--- trunk/LayoutTests/http/tests/cache/resources/echo-cacheable.cgi	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/resources/echo-cacheable.cgi	2021-06-10 19:02:51 UTC (rev 278717)
@@ -0,0 +1,8 @@
+#!/usr/bin/perl -w
+
+print "Content-type: text/plain\n";
+print "Cache-control: max-age=3600\n";
+print "Age: 0\n";
+print "\n";
+read(STDIN, $data, $ENV{'CONTENT_LENGTH'});
+print $data
Property changes on: trunk/LayoutTests/http/tests/cache/resources/echo-cacheable.cgi
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/LayoutTests/http/tests/navigation/post-frames-goback1.html (278716 => 278717)


--- trunk/LayoutTests/http/tests/navigation/post-frames-goback1.html	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/LayoutTests/http/tests/navigation/post-frames-goback1.html	2021-06-10 19:02:51 UTC (rev 278717)
@@ -8,14 +8,25 @@
     testRunner.waitUntilDone();
     testRunner.dumpBackForwardList();
 }
-   
+    
 _onload_ = function()
 {
     if (sessionStorage.didNav) {
         delete sessionStorage.didNav;
         delete sessionStorage.topShouldNavAndGoBack;
-        if (window.testRunner)
-            testRunner.notifyDone();
+        if (window.testRunner) {
+            // Wait until the iframe is showing the POST response before ending the test.
+            let el = document.getElementById('target-frame');
+            if (el.src !== 'about:blank' && el.readyState === 'complete') {
+                testRunner.notifyDone();
+                return;
+            }
+
+            el._onload_ = function() {
+                if (el.src !== 'about:blank')
+                    testRunner.notifyDone();
+            };
+        }
     } else {
         sessionStorage.topShouldNavAndGoBack = true;
         document.getElementById('the-form').submit();
@@ -30,6 +41,6 @@
   <input name="the-input" value="input value goes here">
 </form>
 
-<iframe name="target-frame" src=""
+<iframe id="target-frame" name="target-frame" src=""
 </body>
 </html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac/TestExpectations (278716 => 278717)


--- trunk/LayoutTests/platform/mac/TestExpectations	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2021-06-10 19:02:51 UTC (rev 278717)
@@ -807,10 +807,6 @@
 # FIXME: Needs bugzilla (<rdar://problem/16040720>)
 fast/canvas/canvas-scale-strokePath-shadow.html [ Pass Failure ]
 
-# FIXME: Needs bugzilla (<rdar://problem/16663912>)
-# Seems like this should happen everywhere, but it only does on Yosemite.
-http/tests/navigation/post-frames-goback1.html [ Pass Failure ]
-
 # FIXME: Needs bugzilla (<rdar://problem/16802068>)
 fast/css/input-search-padding.html [ Failure ]
 

Modified: trunk/Source/WebCore/ChangeLog (278716 => 278717)


--- trunk/Source/WebCore/ChangeLog	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/ChangeLog	2021-06-10 19:02:51 UTC (rev 278717)
@@ -1,3 +1,53 @@
+2021-06-10  Ben Nham  <[email protected]>
+
+        Only cache GET requests in the memory cache
+        https://bugs.webkit.org/show_bug.cgi?id=226359
+
+        Reviewed by Geoff Garen.
+
+        Test: http/tests/cache/memory-cache-only-caches-get.html
+
+        We only cache GET requests at the disk cache level, but we don't have that same restriction
+        at the memory cache level. We should make the policies match. In particular, in long-running
+        webpages, we're accumulating POSTs from XMLHttpRequests in our memory cache and should stop
+        doing that, since POST response caching is generally not used or expected.
+
+        I also changed InspectorInstrumentation::willSendRequest to take an optional CachedResource
+        parameter because it currently uses InspectorPageAgent::cachedResource to find the resource,
+        which in turn expects to find the resource in the memory cache. That doesn't work anymore
+        for these non-GET requests, so we now pass down the CachedResource explicitly in the cases
+        where that's necessary.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::willSendRequestImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::willSendRequest):
+        * inspector/agents/InspectorNetworkAgent.cpp:
+        (WebCore::resourceTypeForCachedResource):
+        (WebCore::InspectorNetworkAgent::willSendRequest):
+        * inspector/agents/InspectorNetworkAgent.h:
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::tryLoadingSubstituteData):
+        (WebCore::DocumentLoader::addSubresourceLoader):
+        (WebCore::DocumentLoader::loadMainResource):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::requestFromDelegate):
+        * loader/ResourceLoadNotifier.cpp:
+        (WebCore::ResourceLoadNotifier::willSendRequest):
+        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
+        * loader/ResourceLoadNotifier.h:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::willSendRequestInternal):
+        * loader/ResourceLoader.h:
+        (WebCore::ResourceLoader::cachedResource const):
+        * loader/SubresourceLoader.cpp:
+        * loader/SubresourceLoader.h:
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::update):
+        (WebCore::ApplicationCacheGroup::startLoadingEntry):
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::add):
+
 2021-06-10  Chris Dumez  <[email protected]>
 
         Replace ReadableStreamChunk struct with a WTF::Span

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (278716 => 278717)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -572,10 +572,10 @@
         pageAgent->applyEmulatedMedia(media);
 }
 
-void InspectorInstrumentation::willSendRequestImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void InspectorInstrumentation::willSendRequestImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource)
 {
     if (auto* networkAgent = instrumentingAgents.enabledNetworkAgent())
-        networkAgent->willSendRequest(identifier, loader, request, redirectResponse);
+        networkAgent->willSendRequest(identifier, loader, request, redirectResponse, cachedResource);
 }
 
 void InspectorInstrumentation::willSendRequestOfTypeImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (278716 => 278717)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2021-06-10 19:02:51 UTC (rev 278717)
@@ -193,7 +193,7 @@
     static void applyUserAgentOverride(Frame&, String&);
     static void applyEmulatedMedia(Frame&, String&);
 
-    static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*);
     static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
     static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
     static void didReceiveThreadableLoaderResponse(DocumentThreadableLoader&, unsigned long identifier);
@@ -418,7 +418,7 @@
     static void applyUserAgentOverrideImpl(InstrumentingAgents&, String&);
     static void applyEmulatedMediaImpl(InstrumentingAgents&, String&);
 
-    static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*);
     static void willSendRequestOfTypeImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
     static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
     static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
@@ -1049,17 +1049,17 @@
         applyEmulatedMediaImpl(*agents, media);
 }
 
-inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
+inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
     if (auto* agents = instrumentingAgents(frame))
-        willSendRequestImpl(*agents, identifier, loader, request, redirectResponse);
+        willSendRequestImpl(*agents, identifier, loader, request, redirectResponse, cachedResource);
 }
 
 inline void InspectorInstrumentation::willSendRequest(WorkerOrWorkletGlobalScope& globalScope, unsigned long identifier, ResourceRequest& request)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
-    willSendRequestImpl(instrumentingAgents(globalScope), identifier, nullptr, request, ResourceResponse { });
+    willSendRequestImpl(instrumentingAgents(globalScope), identifier, nullptr, request, ResourceResponse { }, nullptr);
 }
 
 inline void InspectorInstrumentation::willSendRequestOfType(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)

Modified: trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp (278716 => 278717)


--- trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -465,7 +465,7 @@
     m_frontendDispatcher->requestWillBeSent(requestId, frameId, loaderId, url, buildObjectForResourceRequest(request), sendTimestamp, walltime.secondsSinceEpoch().seconds(), WTFMove(initiatorObject), buildObjectForResourceResponse(redirectResponse, nullptr), WTFMove(typePayload), targetId);
 }
 
-static InspectorPageAgent::ResourceType resourceTypeForCachedResource(CachedResource* resource)
+static InspectorPageAgent::ResourceType resourceTypeForCachedResource(const CachedResource* resource)
 {
     if (resource)
         return InspectorPageAgent::inspectorResourceType(*resource);
@@ -486,9 +486,10 @@
     return InspectorPageAgent::OtherResource;
 }
 
-void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void InspectorNetworkAgent::willSendRequest(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource)
 {
-    auto* cachedResource = loader ? InspectorPageAgent::cachedResource(loader->frame(), request.url()) : nullptr;
+    if (!cachedResource && loader)
+        cachedResource = InspectorPageAgent::cachedResource(loader->frame(), request.url());
     willSendRequest(identifier, loader, request, redirectResponse, resourceTypeForCachedResource(cachedResource));
 }
 

Modified: trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h (278716 => 278717)


--- trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/inspector/agents/InspectorNetworkAgent.h	2021-06-10 19:02:51 UTC (rev 278717)
@@ -98,7 +98,7 @@
     // InspectorInstrumentation
     void willRecalculateStyle();
     void didRecalculateStyle();
-    void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
+    void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*);
     void willSendRequestOfType(unsigned long identifier, DocumentLoader*, ResourceRequest&, InspectorInstrumentation::LoadType);
     void didReceiveResponse(unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
     void didReceiveData(unsigned long identifier, const uint8_t* data, int dataLength, int encodedDataLength);

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (278716 => 278717)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -747,7 +747,7 @@
     RELEASE_LOG_IF_ALLOWED("startLoadingMainResource: Returning substitute data");
     m_identifierForLoadWithoutResourceLoader = m_frame->page()->progress().createUniqueIdentifier();
     frameLoader()->notifier().assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, this, m_request);
-    frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, m_request, ResourceResponse());
+    frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, m_request, ResourceResponse(), nullptr);
 
     if (!m_deferMainResourceDataLoad || frameLoader()->loadsSynchronously())
         handleSubstituteDataLoadNow();
@@ -1845,7 +1845,7 @@
             break;
         case Document::AboutToEnterBackForwardCache: {
             // A page about to enter the BackForwardCache should only be able to start ping loads.
-            auto* cachedResource = MemoryCache::singleton().resourceForRequest(loader->request(), loader->frameLoader()->frame().page()->sessionID());
+            auto* cachedResource = downcast<SubresourceLoader>(loader)->cachedResource();
             ASSERT(cachedResource && (CachedResource::shouldUsePingLoad(cachedResource->type()) || cachedResource->options().keepAlive));
             break;
         }
@@ -2075,7 +2075,7 @@
     if (!mainResourceLoader()) {
         m_identifierForLoadWithoutResourceLoader = m_frame->page()->progress().createUniqueIdentifier();
         frameLoader()->notifier().assignIdentifierToInitialRequest(m_identifierForLoadWithoutResourceLoader, this, mainResourceRequest.resourceRequest());
-        frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, mainResourceRequest.resourceRequest(), ResourceResponse());
+        frameLoader()->notifier().dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, mainResourceRequest.resourceRequest(), ResourceResponse(), nullptr);
     }
 
     becomeMainResourceClient();

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (278716 => 278717)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -3564,7 +3564,7 @@
     }
 
     ResourceRequest newRequest(request);
-    notifier().dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse());
+    notifier().dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse(), nullptr);
 
     if (newRequest.isNull())
         error = cancelledError(request);

Modified: trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp (278716 => 278717)


--- trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -65,7 +65,7 @@
 {
     m_frame.loader().applyUserAgentIfNeeded(clientRequest);
 
-    dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse);
+    dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse, loader->cachedResource());
 }
 
 void ResourceLoadNotifier::didReceiveResponse(ResourceLoader* loader, const ResourceResponse& r)
@@ -119,7 +119,7 @@
     m_frame.loader().client().assignIdentifierToInitialRequest(identifier, loader, request);
 }
 
-void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse, const CachedResource* cachedResource)
 {
 #if USE(QUICK_LOOK)
     // Always allow QuickLook-generated URLs based on the protocol scheme.
@@ -149,7 +149,7 @@
     if (!request.isNull() && oldRequestURL != request.url().string() && m_frame.loader().documentLoader())
         m_frame.loader().documentLoader()->didTellClientAboutLoad(request.url().string());
 
-    InspectorInstrumentation::willSendRequest(&m_frame, identifier, loader, request, redirectResponse);
+    InspectorInstrumentation::willSendRequest(&m_frame, identifier, loader, request, redirectResponse, cachedResource);
 }
 
 void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader)

Modified: trunk/Source/WebCore/loader/ResourceLoadNotifier.h (278716 => 278717)


--- trunk/Source/WebCore/loader/ResourceLoadNotifier.h	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/ResourceLoadNotifier.h	2021-06-10 19:02:51 UTC (rev 278717)
@@ -35,6 +35,7 @@
 namespace WebCore {
 
 class AuthenticationChallenge;
+class CachedResource;
 class DocumentLoader;
 class Frame;
 class NetworkLoadMetrics;
@@ -58,7 +59,7 @@
     void didFailToLoad(ResourceLoader*, const ResourceError&);
 
     void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
-    void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
+    void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse, const CachedResource*);
     void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, ResourceLoader* = nullptr);
     void dispatchDidReceiveData(DocumentLoader*, unsigned long identifier, const uint8_t* data, int dataLength, int encodedDataLength);
     void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier, const NetworkLoadMetrics&, ResourceLoader*);

Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (278716 => 278717)


--- trunk/Source/WebCore/loader/ResourceLoader.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -408,7 +408,7 @@
         frameLoader()->notifier().willSendRequest(this, request, redirectResponse);
     }
     else
-        InspectorInstrumentation::willSendRequest(m_frame.get(), m_identifier, m_frame->loader().documentLoader(), request, redirectResponse);
+        InspectorInstrumentation::willSendRequest(m_frame.get(), m_identifier, m_frame->loader().documentLoader(), request, redirectResponse, cachedResource());
 
 #if USE(QUICK_LOOK)
     if (m_documentLoader) {

Modified: trunk/Source/WebCore/loader/ResourceLoader.h (278716 => 278717)


--- trunk/Source/WebCore/loader/ResourceLoader.h	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/ResourceLoader.h	2021-06-10 19:02:51 UTC (rev 278717)
@@ -48,6 +48,7 @@
 namespace WebCore {
 
 class AuthenticationChallenge;
+class CachedResource;
 class DocumentLoader;
 class Frame;
 class FrameLoader;
@@ -130,6 +131,8 @@
     bool shouldSniffContentEncoding() const { return m_options.sniffContentEncoding == ContentEncodingSniffingPolicy::Sniff; }
     WEBCORE_EXPORT bool isAllowedToAskUserForCredentials() const;
     WEBCORE_EXPORT bool shouldIncludeCertificateInfo() const;
+    
+    virtual CachedResource* cachedResource() const { return nullptr; }
 
     bool reachedTerminalState() const { return m_reachedTerminalState; }
 

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (278716 => 278717)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -152,11 +152,6 @@
 }
 #endif
 
-CachedResource* SubresourceLoader::cachedResource()
-{
-    return m_resource;
-}
-
 void SubresourceLoader::cancelIfNotFinishing()
 {
     if (m_state != Initialized)

Modified: trunk/Source/WebCore/loader/SubresourceLoader.h (278716 => 278717)


--- trunk/Source/WebCore/loader/SubresourceLoader.h	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/SubresourceLoader.h	2021-06-10 19:02:51 UTC (rev 278717)
@@ -49,7 +49,7 @@
 
     void cancelIfNotFinishing();
     bool isSubresourceLoader() const override;
-    CachedResource* cachedResource();
+    CachedResource* cachedResource() const override { return m_resource; };
     WEBCORE_EXPORT const HTTPHeaderMap* originalHeaders() const;
 
     SecurityOrigin* origin() { return m_origin.get(); }

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp (278716 => 278717)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -438,7 +438,7 @@
     auto request = createRequest(URL { m_manifestURL }, m_newestCache ? m_newestCache->manifestResource() : nullptr);
 
     m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier();
-    InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { });
+    InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { }, nullptr);
 
     m_manifestLoader = ApplicationCacheResourceLoader::create(ApplicationCacheResource::Type::Manifest, documentLoader.cachedResourceLoader(), WTFMove(request), [this] (auto&& resourceOrError) {
         // 'this' is only valid if returned value is not Error::Abort.
@@ -899,7 +899,7 @@
     auto request = createRequest(URL { { }, firstPendingEntryURL }, m_newestCache ? m_newestCache->resourceForURL(firstPendingEntryURL) : nullptr);
 
     m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier();
-    InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { });
+    InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { }, nullptr);
 
     auto& documentLoader = *m_frame->loader().documentLoader();
     auto requestURL = request.url();

Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (278716 => 278717)


--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2021-06-10 18:54:31 UTC (rev 278716)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2021-06-10 19:02:51 UTC (rev 278717)
@@ -114,6 +114,9 @@
     if (disabled())
         return false;
 
+    if (resource.resourceRequest().httpMethod() != "GET")
+        return false;
+
     ASSERT(WTF::isMainThread());
 
     auto key = std::make_pair(resource.url(), resource.cachePartition());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to