haikuwebkit/Source/WebCore/loader/cache
Alex Christensen b13eb19c90 Resource Timing: Duration is 0 in many cases
https://bugs.webkit.org/show_bug.cgi?id=225737

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/resource-timing/cors-preflight.any-expected.txt:
* web-platform-tests/resource-timing/crossorigin-sandwich-no-TAO.sub-expected.txt:
* web-platform-tests/resource-timing/crossorigin-sandwich-partial-TAO.sub-expected.txt:
* web-platform-tests/resource-timing/resource_timing_cross_origin_redirect_chain-expected.txt:
* web-platform-tests/resource-timing/status-codes-create-entry-expected.txt:

Source/WebCore:

This fixes two problems with our PerformanceResourceTiming implementation:
1. ResourceTimingInformation::shouldAddResourceTiming wasn't adding timing data if CachedResource::errorOccurred returned true,
which includes when the server responds with an HTTP 404.  We want loadFailedOrCanceled instead, which only returns true if
there's a network error or if the load is cancelled.  This matches the behavior of other browsers.
2. ResourceTiming::fromMemoryCache was assuming that it never had network information to report because we pulled from the cache,
not the network.  However, a common case is that HTMLPreloadScanner::scan calls HTMLResourcePreloader::preload which loads the resource
while the HTML parser is blocked on loading scripts or other things, then CachedResourceLoader::requestResource pulls it out of the
memory cache.  In this case, use the network metrics that we are already storing if it's the first time we are pulling this resource
out of the memory cache.  After that, 0 load time is quite accurate.

Covered by newly passing Web Platform Tests, which Chrome and Firefox already passed.

* loader/ResourceTiming.cpp:
(WebCore::ResourceTiming::fromMemoryCache):
(WebCore::ResourceTiming::ResourceTiming):
(WebCore::ResourceTiming::initServerTiming): Deleted.
* loader/ResourceTiming.h:
(WebCore::ResourceTiming::ResourceTiming):
* loader/ResourceTimingInformation.cpp:
(WebCore::ResourceTimingInformation::shouldAddResourceTiming):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::takeNetworkLoadMetrics):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
* platform/network/ResourceResponseBase.h:
(WebCore::ResourceResponseBase::deprecatedNetworkLoadMetricsOrNull const):
(WebCore::ResourceResponseBase::takeNetworkLoadMetrics):



Canonical link: https://commits.webkit.org/240569@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 21:43:02 +00:00
..
CachePolicy.h
CachedApplicationManifest.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedApplicationManifest.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedCSSStyleSheet.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedCSSStyleSheet.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedFont.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedFont.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedFontClient.h
CachedFontLoadRequest.h Implement FontFace in Workers for OffscreenCanvas 2021-04-22 18:44:49 +00:00
CachedImage.cpp SVGImageForContainer reports true for is<SVGImage>() but it doesn't inherit from SVGImage 2021-07-09 20:05:39 +00:00
CachedImage.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedImageClient.h
CachedRawResource.cpp Protect m_data when iterating in CachedRawResource::didAddClient 2021-07-20 16:54:58 +00:00
CachedRawResource.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedRawResourceClient.h Use Vector<uint8_t> instead of Vector<char> to store bytes in SharedBuffer 2021-06-05 01:16:43 +00:00
CachedResource.cpp [WinCairo] Turn ENABLE_SHAREABLE_RESOURCE on 2021-06-21 21:42:01 +00:00
CachedResource.h Resource Timing: Duration is 0 in many cases 2021-08-16 21:43:02 +00:00
CachedResourceClient.h
CachedResourceClientWalker.h
CachedResourceHandle.cpp
CachedResourceHandle.h
CachedResourceLoader.cpp Resource Timing: Duration is 0 in many cases 2021-08-16 21:43:02 +00:00
CachedResourceLoader.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedResourceRequest.cpp Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
CachedResourceRequest.h Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
CachedResourceRequestInitiators.cpp
CachedResourceRequestInitiators.h
CachedSVGDocument.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedSVGDocument.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedSVGDocumentClient.h
CachedSVGDocumentReference.cpp
CachedSVGDocumentReference.h
CachedSVGFont.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedSVGFont.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedScript.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedScript.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedStyleSheetClient.h
CachedTextTrack.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedTextTrack.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedXSLStyleSheet.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
CachedXSLStyleSheet.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
KeepaliveRequestTracker.cpp
KeepaliveRequestTracker.h
MemoryCache.cpp Only cache GET requests in the memory cache 2021-06-10 19:02:51 +00:00
MemoryCache.h