Diff
Modified: trunk/LayoutTests/ChangeLog (200886 => 200887)
--- trunk/LayoutTests/ChangeLog 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/LayoutTests/ChangeLog 2016-05-13 22:34:29 UTC (rev 200887)
@@ -1,3 +1,16 @@
+2016-05-13 Yoav Weiss <y...@yoav.ws>
+
+ ResourceTiming entries for cached resources and XHR
+ https://bugs.webkit.org/show_bug.cgi?id=157669
+
+ Reviewed by Alex Christensen.
+
+ These tests make sure that cacheable resources as well as XHR based resources
+ have ResourceTiming entries.
+
+ * http/tests/performance/performance-resource-timing-cached-entries-expected.txt: Added.
+ * http/tests/performance/performance-resource-timing-cached-entries.html: Added.
+
2016-05-13 Mark Lam <mark....@apple.com>
We should have one calleeSaveRegistersBuffer per VMEntryFrame, not one per VM.
Added: trunk/LayoutTests/http/tests/performance/performance-resource-timing-cached-entries-expected.txt (0 => 200887)
--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-cached-entries-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-cached-entries-expected.txt 2016-05-13 22:34:29 UTC (rev 200887)
@@ -0,0 +1,2 @@
+PASS foundResource is 2
+
Added: trunk/LayoutTests/http/tests/performance/performance-resource-timing-cached-entries.html (0 => 200887)
--- trunk/LayoutTests/http/tests/performance/performance-resource-timing-cached-entries.html (rev 0)
+++ trunk/LayoutTests/http/tests/performance/performance-resource-timing-cached-entries.html 2016-05-13 22:34:29 UTC (rev 200887)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<script>
+ if (window.internals)
+ internals.setResourceTimingSupport(true);
+ if (window.testRunner) {
+ testRunner.dumpAsText()
+ testRunner.waitUntilDone();
+ }
+</script>
+<script src=""
+<img src=""
+<script>
+ var foundResource = 0;
+ var runTest = function() {
+ var resources = performance.getEntriesByType('resource');
+ for (var i = 0; i < resources.length; ++i) {
+ if (resources[i].name.indexOf("square") != -1)
+ ++foundResource;
+ };
+ shouldBe("foundResource", "2");
+ if (window.internals)
+ window.internals.setResourceTimingSupport(false);
+ if (window.testRunner)
+ testRunner.notifyDone();
+ };
+ var windowLoaded = false;
+ var xhrLoaded = false;
+ var xhr = new XMLHttpRequest();
+ xhr.addEventListener("load", function() {
+ if (windowLoaded)
+ runTest();
+ xhrLoaded = true;
+ });
+ xhr.open("GET", "../../resources/square100.png");
+ xhr.send();
+ window.addEventListener("load", function() {
+ if (xhrLoaded)
+ runTest();
+ windowLoaded = true;
+ });
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/CMakeLists.txt (200886 => 200887)
--- trunk/Source/WebCore/CMakeLists.txt 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-05-13 22:34:29 UTC (rev 200887)
@@ -1931,6 +1931,7 @@
loader/ResourceLoadStatistics.cpp
loader/ResourceLoadStatisticsStore.cpp
loader/ResourceLoader.cpp
+ loader/ResourceTimingInformation.cpp
loader/SinkDocument.cpp
loader/SubframeLoader.cpp
loader/SubresourceLoader.cpp
Modified: trunk/Source/WebCore/ChangeLog (200886 => 200887)
--- trunk/Source/WebCore/ChangeLog 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/Source/WebCore/ChangeLog 2016-05-13 22:34:29 UTC (rev 200887)
@@ -1,3 +1,38 @@
+2016-05-13 Yoav Weiss <y...@yoav.ws>
+
+ ResourceTiming entries for cached resources and XHR
+ https://bugs.webkit.org/show_bug.cgi?id=157669
+
+ Reviewed by Alex Christensen.
+
+ - Moves the ResourceTiming storage and addition logic into its own class, so that it
+ can be accessed by both CachedResourceLoader and DocumentThreadableLoader.
+ - Using the above, adds ResourceTiming collection into DocumentThreadableLoader,
+ in order to support ResourceTiming entries for XHR based requests.
+ - Adds ResourceTiming entries for resources that are reused from the memory cache.
+
+ Test: http/tests/performance/performance-resource-timing-cached-entries.html
+
+ * CMakeLists.txt: Add ResourceTimingInformation.
+ * WebCore.xcodeproj/project.pbxproj: Add ResourceTimingInformation.
+ * loader/DocumentThreadableLoader.cpp:
+ (WebCore::DocumentThreadableLoader::didFinishLoading): Add a call to addResourceTiming.
+ (WebCore::DocumentThreadableLoader::loadRequest): Store the initiator information.
+ * loader/DocumentThreadableLoader.h:
+ * loader/ResourceTimingInformation.cpp: Added.
+ (WebCore::ResourceTimingInformation::addResourceTiming): Moved addResourceTiming logic from CachedResourceLoader.
+ (WebCore::ResourceTimingInformation::storeResourceTimingInitiatorInformation): Moved addResourceTiming logic from
+ CachedResourceLoader. Removed reliance on the committingFirstRealLoad bool when storing initiator info, as I don't
+ see why it is required, and it made no sense in the context of DocumentThreadableLoader.
+ * loader/ResourceTimingInformation.h: Added.
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::requestResource): Add a ResourceTiming entry when a resource is reused from MemoryCache.
+ (WebCore::CachedResourceLoader::revalidateResource): Use ResourceTimingInformation::storeResourceTimingInitiatorInformation.
+ (WebCore::CachedResourceLoader::loadResource): Use ResourceTimingInformation::storeResourceTimingInitiatorInformation.
+ (WebCore::CachedResourceLoader::loadDone): Use ResourceTimingInformation::addResourceTiming.
+ (WebCore::CachedResourceLoader::storeResourceTimingInitiatorInformation): Deleted.
+ * loader/cache/CachedResourceLoader.h:
+
2016-05-13 Doug Russell <d_russ...@apple.com>
AX: Regressions in undo/redo accessibility from Bug 153361
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (200886 => 200887)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-05-13 22:34:29 UTC (rev 200887)
@@ -6007,6 +6007,8 @@
CB38FD5A1CD2325800592A3F /* JSPerformanceResourceTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB38FD581CD2314500592A3F /* JSPerformanceResourceTiming.cpp */; };
CB38FD5B1CD2325B00592A3F /* JSPerformanceResourceTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = CB38FD591CD2314500592A3F /* JSPerformanceResourceTiming.h */; };
CB8CF0181A9358D4000D510B /* Microtasks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF0151A934B43000D510B /* Microtasks.cpp */; };
+ CBC2D22F1CE5B89D00D1880B /* ResourceTimingInformation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC2D22D1CE5B77400D1880B /* ResourceTimingInformation.cpp */; };
+ CBC2D2301CE5B8A100D1880B /* ResourceTimingInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC2D22E1CE5B77D00D1880B /* ResourceTimingInformation.h */; settings = {ATTRIBUTES = (Private, ); }; };
CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51015F613060048CDD6 /* DeviceClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCC2B51115F613060048CDD6 /* DeviceController.cpp */; };
CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51215F613060048CDD6 /* DeviceController.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13988,6 +13990,8 @@
CB38FD581CD2314500592A3F /* JSPerformanceResourceTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformanceResourceTiming.cpp; sourceTree = "<group>"; };
CB38FD591CD2314500592A3F /* JSPerformanceResourceTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPerformanceResourceTiming.h; sourceTree = "<group>"; };
CB8CF0151A934B43000D510B /* Microtasks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Microtasks.cpp; sourceTree = "<group>"; };
+ CBC2D22D1CE5B77400D1880B /* ResourceTimingInformation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceTimingInformation.cpp; sourceTree = "<group>"; };
+ CBC2D22E1CE5B77D00D1880B /* ResourceTimingInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceTimingInformation.h; sourceTree = "<group>"; };
CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = "<group>"; };
CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = "<group>"; };
CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; };
@@ -22819,6 +22823,8 @@
7A929CA21C598378004DF226 /* ResourceLoadStatistics.h */,
7A7CC8361C87506800366243 /* ResourceLoadStatisticsStore.cpp */,
7A7CC8371C87506800366243 /* ResourceLoadStatisticsStore.h */,
+ CBC2D22D1CE5B77400D1880B /* ResourceTimingInformation.cpp */,
+ CBC2D22E1CE5B77D00D1880B /* ResourceTimingInformation.h */,
51327D5F11A33A2B004F9D65 /* SinkDocument.cpp */,
51327D5E11A33A2B004F9D65 /* SinkDocument.h */,
D000ED2511C1B9CD00C47726 /* SubframeLoader.cpp */,
@@ -28244,6 +28250,7 @@
83C1D432178D5AB500141E68 /* SVGPathSegLinetoRel.h in Headers */,
B2227A7D0D00BF220071B782 /* SVGPathSegLinetoVertical.h in Headers */,
83C1D433178D5AB500141E68 /* SVGPathSegLinetoVerticalAbs.h in Headers */,
+ CBC2D2301CE5B8A100D1880B /* ResourceTimingInformation.h in Headers */,
83C1D434178D5AB500141E68 /* SVGPathSegLinetoVerticalRel.h in Headers */,
B2227A810D00BF220071B782 /* SVGPathSegList.h in Headers */,
8476C9E611DF6A0B00555B02 /* SVGPathSegListBuilder.h in Headers */,
@@ -32105,6 +32112,7 @@
1A1414B513A0F0500019996C /* WebKitFontFamilyNames.cpp in Sources */,
D7613A501474F13F00DB8606 /* WebKitNamedFlow.cpp in Sources */,
7C48A6D0191C9D6500026674 /* WebKitNamespace.cpp in Sources */,
+ CBC2D22F1CE5B89D00D1880B /* ResourceTimingInformation.cpp in Sources */,
A5DEBDA316FB908700836FE0 /* WebKitPlaybackTargetAvailabilityEvent.cpp in Sources */,
31C0FF240E4CEB6E007D6FE5 /* WebKitTransitionEvent.cpp in Sources */,
0FCF332E0F2B9A25004B6795 /* WebLayer.mm in Sources */,
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (200886 => 200887)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2016-05-13 22:34:29 UTC (rev 200887)
@@ -325,6 +325,9 @@
void DocumentThreadableLoader::didFinishLoading(unsigned long identifier, double finishTime)
{
+ if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
+ m_resourceTimingInfo.addResourceTiming(m_resource.get(), &m_document);
+
if (m_actualRequest) {
InspectorInstrumentation::didFinishLoading(m_document.frame(), m_document.frame()->loader().documentLoader(), identifier, finishTime);
@@ -390,9 +393,13 @@
newRequest.setInitiator(m_options.initiator);
ASSERT(!m_resource);
m_resource = m_document.cachedResourceLoader().requestRawResource(newRequest);
- if (m_resource)
+ if (m_resource) {
m_resource->addClient(this);
+ if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
+ m_resourceTimingInfo.storeResourceTimingInitiatorInformation(m_resource, newRequest, m_document.frame());
+ }
+
return;
}
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.h (200886 => 200887)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.h 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.h 2016-05-13 22:34:29 UTC (rev 200887)
@@ -33,6 +33,7 @@
#include "CachedRawResourceClient.h"
#include "CachedResourceHandle.h"
+#include "ResourceTimingInformation.h"
#include "ThreadableLoader.h"
namespace WebCore {
@@ -105,6 +106,7 @@
ThreadableLoaderClient* m_client;
Document& m_document;
ThreadableLoaderOptions m_options;
+ ResourceTimingInformation m_resourceTimingInfo;
bool m_sameOriginRequest;
bool m_simpleRequest;
bool m_async;
Added: trunk/Source/WebCore/loader/ResourceTimingInformation.cpp (0 => 200887)
--- trunk/Source/WebCore/loader/ResourceTimingInformation.cpp (rev 0)
+++ trunk/Source/WebCore/loader/ResourceTimingInformation.cpp 2016-05-13 22:34:29 UTC (rev 200887)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2016 Akamai Technologies Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if ENABLE(WEB_TIMING)
+#include "ResourceTimingInformation.h"
+
+#include "CachedResource.h"
+#include "CachedResourceRequest.h"
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Frame.h"
+#include "HTMLFrameOwnerElement.h"
+#include "Performance.h"
+#include "RuntimeEnabledFeatures.h"
+
+namespace WebCore {
+
+void ResourceTimingInformation::addResourceTiming(CachedResource* resource, Document* document)
+{
+ ASSERT(RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled());
+ if (resource && resource->response().isHTTP()
+ && ((!resource->errorOccurred() && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
+ HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initiatorMap.find(resource);
+ if (initiatorIt != m_initiatorMap.end()) {
+ ASSERT(document);
+ Document* initiatorDocument = document;
+ if (resource->type() == CachedResource::MainResource)
+ initiatorDocument = document->parentDocument();
+ ASSERT(initiatorDocument);
+ ASSERT(initiatorDocument->domWindow());
+ ASSERT(initiatorDocument->domWindow()->performance());
+ const InitiatorInfo& info = initiatorIt->value;
+ initiatorDocument->domWindow()->performance()->addResourceTiming(info.name, initiatorDocument, resource->resourceRequest(), resource->response(), info.startTime, resource->loadFinishTime());
+ m_initiatorMap.remove(initiatorIt);
+ }
+ }
+}
+
+void ResourceTimingInformation::storeResourceTimingInitiatorInformation(const CachedResourceHandle<CachedResource>& resource, const CachedResourceRequest& request, Frame* frame)
+{
+ ASSERT(RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled());
+ ASSERT(resource.get());
+ if (resource->type() == CachedResource::MainResource) {
+ // <iframe>s should report the initial navigation requested by the parent document, but not subsequent navigations.
+ ASSERT(frame);
+ if (frame->ownerElement()) {
+ InitiatorInfo info = { frame->ownerElement()->localName(), monotonicallyIncreasingTime() };
+ m_initiatorMap.add(resource.get(), info);
+ }
+ } else {
+ InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime() };
+ m_initiatorMap.add(resource.get(), info);
+ }
+}
+
+}
+
+#endif // ENABLE(WEB_TIMING)
Added: trunk/Source/WebCore/loader/ResourceTimingInformation.h (0 => 200887)
--- trunk/Source/WebCore/loader/ResourceTimingInformation.h (rev 0)
+++ trunk/Source/WebCore/loader/ResourceTimingInformation.h 2016-05-13 22:34:29 UTC (rev 200887)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 Akamai Technologies Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_TIMING)
+
+#include "CachedResourceHandle.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class CachedResource;
+class CachedResourceRequest;
+class Document;
+class Frame;
+
+class ResourceTimingInformation {
+public:
+
+ void addResourceTiming(CachedResource*, Document*);
+ void storeResourceTimingInitiatorInformation(const CachedResourceHandle<CachedResource>&, const CachedResourceRequest&, Frame*);
+
+private:
+ struct InitiatorInfo {
+ AtomicString name;
+ double startTime;
+ };
+ HashMap<CachedResource*, InitiatorInfo> m_initiatorMap;
+};
+
+}
+
+#endif // ENABLE(WEB_TIMING)
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (200886 => 200887)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2016-05-13 22:34:29 UTC (rev 200887)
@@ -618,6 +618,10 @@
return nullptr;
logMemoryCacheResourceRequest(frame(), DiagnosticLoggingKeys::inMemoryCacheKey(), DiagnosticLoggingKeys::usedKey());
memoryCache.resourceAccessed(*resource);
+ if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled()) {
+ m_resourceTimingInfo.storeResourceTimingInitiatorInformation(resource, request, frame());
+ m_resourceTimingInfo.addResourceTiming(resource.get(), document());
+ }
break;
}
@@ -670,7 +674,7 @@
memoryCache.remove(*resource);
memoryCache.add(*newResource);
if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
- storeResourceTimingInitiatorInformation(resource, request);
+ m_resourceTimingInfo.storeResourceTimingInitiatorInformation(resource, request, frame());
return newResource;
}
@@ -686,25 +690,10 @@
if (request.allowsCaching() && !memoryCache.add(*resource))
resource->setOwningCachedResourceLoader(this);
if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
- storeResourceTimingInitiatorInformation(resource, request);
+ m_resourceTimingInfo.storeResourceTimingInitiatorInformation(resource, request, frame());
return resource;
}
-void CachedResourceLoader::storeResourceTimingInitiatorInformation(const CachedResourceHandle<CachedResource>& resource, const CachedResourceRequest& request)
-{
- ASSERT(RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled());
- if (resource->type() == CachedResource::MainResource) {
- // <iframe>s should report the initial navigation requested by the parent document, but not subsequent navigations.
- if (frame()->ownerElement() && m_documentLoader->frameLoader()->stateMachine().committingFirstRealLoad()) {
- InitiatorInfo info = { frame()->ownerElement()->localName(), monotonicallyIncreasingTime() };
- m_initiatorMap.add(resource.get(), info);
- }
- } else {
- InitiatorInfo info = { request.initiatorName(), monotonicallyIncreasingTime() };
- m_initiatorMap.add(resource.get(), info);
- }
-}
-
static void logRevalidation(const String& reason, DiagnosticLoggingClient& logClient)
{
logClient.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::cachedResourceRevalidationKey(), DiagnosticLoggingKeys::reasonKey(), reason, ShouldSample::Yes);
@@ -970,21 +959,8 @@
RefPtr<Document> protectDocument(m_document);
#if ENABLE(WEB_TIMING)
- if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled()
- && resource && resource->response().isHTTP()
- && ((!resource->errorOccurred() && !resource->wasCanceled()) || resource->response().httpStatusCode() == 304)) {
- HashMap<CachedResource*, InitiatorInfo>::iterator initiatorIt = m_initiatorMap.find(resource);
- if (initiatorIt != m_initiatorMap.end()) {
- ASSERT(document());
- Document* initiatorDocument = document();
- if (resource->type() == CachedResource::MainResource)
- initiatorDocument = document()->parentDocument();
- ASSERT(initiatorDocument);
- const InitiatorInfo& info = initiatorIt->value;
- initiatorDocument->domWindow()->performance()->addResourceTiming(info.name, initiatorDocument, resource->resourceRequest(), resource->response(), info.startTime, resource->loadFinishTime());
- m_initiatorMap.remove(initiatorIt);
- }
- }
+ if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
+ m_resourceTimingInfo.addResourceTiming(resource, document());
#else
UNUSED_PARAM(resource);
#endif
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (200886 => 200887)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2016-05-13 22:22:45 UTC (rev 200886)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2016-05-13 22:34:29 UTC (rev 200887)
@@ -31,6 +31,7 @@
#include "CachedResourceHandle.h"
#include "CachedResourceRequest.h"
#include "ResourceLoadPriority.h"
+#include "ResourceTimingInformation.h"
#include "Timer.h"
#include <wtf/Deque.h>
#include <wtf/HashMap.h>
@@ -144,7 +145,6 @@
CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&);
CachedResourceHandle<CachedResource> revalidateResource(const CachedResourceRequest&, CachedResource*);
CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, CachedResourceRequest&);
- void storeResourceTimingInitiatorInformation(const CachedResourceHandle<CachedResource>&, const CachedResourceRequest&);
void requestPreload(CachedResource::Type, CachedResourceRequest&, const String& charset);
enum RevalidationPolicy { Use, Revalidate, Reload, Load };
@@ -177,11 +177,7 @@
Timer m_garbageCollectDocumentResourcesTimer;
- struct InitiatorInfo {
- AtomicString name;
- double startTime;
- };
- HashMap<CachedResource*, InitiatorInfo> m_initiatorMap;
+ ResourceTimingInformation m_resourceTimingInfo;
// 29 bits left
bool m_autoLoadImages : 1;