Diff
Modified: trunk/Source/WebCore/ChangeLog (235689 => 235690)
--- trunk/Source/WebCore/ChangeLog 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebCore/ChangeLog 2018-09-05 21:25:06 UTC (rev 235690)
@@ -1,3 +1,15 @@
+2018-09-05 Woodrow Wang <[email protected]>
+
+ Add infrastructure to dump resource load statistics
+ https://bugs.webkit.org/show_bug.cgi?id=189213
+
+ Reviewed by Daniel Bates.
+
+ The dumping functionality is not currently used, but will be included in tests for
+ <https://bugs.webkit.org/show_bug.cgi?id=187773>.
+
+ * loader/ResourceLoadStatistics.h:
+
2018-09-05 Ryan Haddad <[email protected]>
Unreviewed, fix the build with recent SDKs.
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (235689 => 235690)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-09-05 21:25:06 UTC (rev 235690)
@@ -58,7 +58,7 @@
WEBCORE_EXPORT void encode(KeyedEncoder&) const;
WEBCORE_EXPORT bool decode(KeyedDecoder&, unsigned modelVersion);
- String toString() const;
+ WEBCORE_EXPORT String toString() const;
WEBCORE_EXPORT void merge(const ResourceLoadStatistics&);
Modified: trunk/Source/WebKit/ChangeLog (235689 => 235690)
--- trunk/Source/WebKit/ChangeLog 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebKit/ChangeLog 2018-09-05 21:25:06 UTC (rev 235690)
@@ -1,3 +1,23 @@
+2018-09-05 Woodrow Wang <[email protected]>
+
+ Add infrastructure to dump resource load statistics
+ https://bugs.webkit.org/show_bug.cgi?id=189213
+
+ Reviewed by Daniel Bates.
+
+ The dumping functionality is not currently used, but will be included in tests for
+ <https://bugs.webkit.org/show_bug.cgi?id=187773>.
+
+ * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+ (WKWebsiteDataStoreDumpResourceLoadStatistics):
+ * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+ * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
+ (WebKit::ResourceLoadStatisticsMemoryStore::dumpResourceLoadStatistics const):
+ * UIProcess/ResourceLoadStatisticsMemoryStore.h:
+ * UIProcess/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::dumpResourceLoadStatistics):
+ * UIProcess/WebResourceLoadStatisticsStore.h:
+
2018-09-05 David Kilzer <[email protected]>
REGRESSION (r235006): Let Xcode have its way with the WebKit project
Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (235689 => 235690)
--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp 2018-09-05 21:25:06 UTC (rev 235690)
@@ -30,6 +30,7 @@
#include "APIWebsiteDataStore.h"
#include "WKAPICast.h"
#include "WKSecurityOriginRef.h"
+#include "WKString.h"
#include "WebResourceLoadStatisticsStore.h"
#include "WebResourceLoadStatisticsTelemetry.h"
#include "WebsiteData.h"
@@ -143,6 +144,19 @@
});
}
+void WKWebsiteDataStoreDumpResourceLoadStatistics(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreDumpResourceLoadStatisticsFunction callback)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store) {
+ callback(WebKit::toAPI(emptyString().impl()), context);
+ return;
+ }
+
+ store->dumpResourceLoadStatistics([context, callback] (const String& resourceLoadStatistics) {
+ callback(WebKit::toAPI(resourceLoadStatistics.impl()), context);
+ });
+}
+
void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback)
{
auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h (235689 => 235690)
--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h 2018-09-05 21:25:06 UTC (rev 235690)
@@ -49,6 +49,8 @@
WK_EXPORT void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler);
typedef void (*WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction)(void* functionContext);
WK_EXPORT void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler);
+typedef void (*WKWebsiteDataStoreDumpResourceLoadStatisticsFunction)(WKStringRef resourceLoadStatisticsRepresentation, void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreDumpResourceLoadStatistics(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreDumpResourceLoadStatisticsFunction callback);
typedef void (*WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction)(bool isPrevalentResource, void* functionContext);
WK_EXPORT void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
WK_EXPORT void WKWebsiteDataStoreIsStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp (235689 => 235690)
--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2018-09-05 21:25:06 UTC (rev 235690)
@@ -671,7 +671,18 @@
mapEntry->value.isPrevalentResource = true;
}
}
+
+String ResourceLoadStatisticsMemoryStore::dumpResourceLoadStatistics() const
+{
+ ASSERT(!RunLoop::isMain());
+ StringBuilder result;
+ result.appendLiteral("Resource load statistics:\n\n");
+ for (auto& mapEntry : m_resourceStatisticsMap.values())
+ result.append(mapEntry.toString());
+ return result.toString();
+}
+
bool ResourceLoadStatisticsMemoryStore::isPrevalentResource(const String& primaryDomain) const
{
ASSERT(!RunLoop::isMain());
Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h (235689 => 235690)
--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h 2018-09-05 21:25:06 UTC (rev 235690)
@@ -83,6 +83,7 @@
bool isRegisteredAsRedirectingTo(const String& hostRedirectedFromPrimaryDomain, const String& hostRedirectedToPrimaryDomain) const;
void clearPrevalentResource(const String& primaryDomain);
+ String dumpResourceLoadStatistics() const;
bool isPrevalentResource(const String& primaryDomain) const;
bool isVeryPrevalentResource(const String& primaryDomain) const;
void setPrevalentResource(const String& primaryDomain);
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (235689 => 235690)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-09-05 21:25:06 UTC (rev 235690)
@@ -493,7 +493,19 @@
postTaskReply(WTFMove(completionHandler));
});
}
+
+void WebResourceLoadStatisticsStore::dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&& completionHandler)
+{
+ ASSERT(RunLoop::isMain());
+ postTask([this, completionHandler = WTFMove(completionHandler)] () mutable {
+ String result = m_memoryStore ? m_memoryStore->dumpResourceLoadStatistics() : emptyString();
+ postTaskReply([result = result.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
+ completionHandler(result);
+ });
+ });
+}
+
void WebResourceLoadStatisticsStore::isPrevalentResource(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
{
ASSERT(RunLoop::isMain());
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (235689 => 235690)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-09-05 21:25:06 UTC (rev 235690)
@@ -91,6 +91,7 @@
void setLastSeen(const WebCore::URL&, Seconds, CompletionHandler<void()>&&);
void setPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
void setVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
+ void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&);
void isPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
void isVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
void isRegisteredAsSubresourceUnder(const WebCore::URL& subresource, const WebCore::URL& topFrame, CompletionHandler<void(bool)>&&);
Modified: trunk/Tools/ChangeLog (235689 => 235690)
--- trunk/Tools/ChangeLog 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/ChangeLog 2018-09-05 21:25:06 UTC (rev 235690)
@@ -1,3 +1,27 @@
+2018-09-05 Woodrow Wang <[email protected]>
+
+ Add infrastructure to dump resource load statistics
+ https://bugs.webkit.org/show_bug.cgi?id=189213
+
+ Reviewed by Daniel Bates.
+
+ The dumping functionality is not currently used, but will be included in tests for
+ <https://bugs.webkit.org/show_bug.cgi?id=187773>.
+
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::setDumpResourceLoadStatistics):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::resourceStatisticsStringResultCallback):
+ (WTR::TestController::dumpResourceLoadStatistics):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::dumpResults):
+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+ (WTR::TestInvocation::setDumpResourceLoadStatistics):
+ * WebKitTestRunner/TestInvocation.h:
+
2018-09-05 Wenson Hsieh <[email protected]>
[macOS] DragAndDropTests.ExposeMultipleURLsInDataTransfer fails on macOS versions prior to Mojave
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (235689 => 235690)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-09-05 21:25:06 UTC (rev 235690)
@@ -56,6 +56,7 @@
void dumpDatabaseCallbacks();
void dumpDOMAsWebArchive();
void dumpPolicyDelegateCallbacks();
+ void dumpResourceLoadStatistics();
void clearDOMCaches();
void clearDOMCache(DOMString origin);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (235689 => 235690)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-09-05 21:25:06 UTC (rev 235690)
@@ -1462,6 +1462,12 @@
{
callTestRunnerCallback(SetStatisticsVeryPrevalentResourceCallbackID);
}
+
+void TestRunner::dumpResourceLoadStatistics()
+{
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("dumpResourceLoadStatistics"));
+ WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), nullptr, nullptr);
+}
bool TestRunner::isStatisticsPrevalentResource(JSStringRef hostName)
{
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (235689 => 235690)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-09-05 21:25:06 UTC (rev 235690)
@@ -91,6 +91,7 @@
void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
void dumpDOMAsWebArchive() { setWhatToDump(WhatToDump::DOMAsWebArchive); }
void dumpPolicyDelegateCallbacks() { m_dumpPolicyCallbacks = true; }
+ void dumpResourceLoadStatistics();
void setShouldDumpFrameLoadCallbacks(bool value);
void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (235689 => 235690)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2018-09-05 21:25:06 UTC (rev 235690)
@@ -2816,7 +2816,16 @@
TestController& testController;
bool done { false };
bool result { false };
+ WKRetainPtr<WKStringRef> resourceLoadStatisticsRepresentation;
};
+
+static void resourceStatisticsStringResultCallback(WKStringRef resourceLoadStatisticsRepresentation, void* userData)
+{
+ auto* context = static_cast<ResourceStatisticsCallbackContext*>(userData);
+ context->resourceLoadStatisticsRepresentation = resourceLoadStatisticsRepresentation;
+ context->done = true;
+ context->testController.notifyDone();
+}
static void resourceStatisticsVoidResultCallback(void* userData)
{
@@ -2877,6 +2886,15 @@
runUntil(context.done, noTimeout);
m_currentInvocation->didSetVeryPrevalentResource();
}
+
+String TestController::dumpResourceLoadStatistics()
+{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ ResourceStatisticsCallbackContext context(*this);
+ WKWebsiteDataStoreDumpResourceLoadStatistics(dataStore, &context, resourceStatisticsStringResultCallback);
+ runUntil(context.done, noTimeout);
+ return toWTFString(context.resourceLoadStatisticsRepresentation.get());
+}
bool TestController::isStatisticsPrevalentResource(WKStringRef host)
{
Modified: trunk/Tools/WebKitTestRunner/TestController.h (235689 => 235690)
--- trunk/Tools/WebKitTestRunner/TestController.h 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2018-09-05 21:25:06 UTC (rev 235690)
@@ -191,6 +191,7 @@
void setStatisticsLastSeen(WKStringRef hostName, double seconds);
void setStatisticsPrevalentResource(WKStringRef hostName, bool value);
void setStatisticsVeryPrevalentResource(WKStringRef hostName, bool value);
+ String dumpResourceLoadStatistics();
bool isStatisticsPrevalentResource(WKStringRef hostName);
bool isStatisticsVeryPrevalentResource(WKStringRef hostName);
bool isStatisticsRegisteredAsSubresourceUnder(WKStringRef subresourceHost, WKStringRef topFrameHost);
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (235689 => 235690)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-09-05 21:25:06 UTC (rev 235690)
@@ -250,6 +250,9 @@
void TestInvocation::dumpResults()
{
+ if (m_shouldDumpResourceLoadStatistics)
+ m_textOutput.append(m_savedResourceLoadStatistics.isNull() ? TestController::singleton().dumpResourceLoadStatistics() : m_savedResourceLoadStatistics);
+
if (m_textOutput.length() || !m_audioResult)
dump(m_textOutput.toString().utf8().data());
else
@@ -1069,6 +1072,11 @@
return nullptr;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "dumpResourceLoadStatistics")) {
+ dumpResourceLoadStatistics();
+ return nullptr;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "IsStatisticsPrevalentResource")) {
ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
@@ -1351,6 +1359,8 @@
}
if (WKStringIsEqualToUTF8CString(messageName, "StatisticsResetToConsistentState")) {
+ if (m_shouldDumpResourceLoadStatistics)
+ m_savedResourceLoadStatistics = TestController::singleton().dumpResourceLoadStatistics();
TestController::singleton().statisticsResetToConsistentState();
return nullptr;
}
@@ -1580,4 +1590,9 @@
WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
}
+void TestInvocation::dumpResourceLoadStatistics()
+{
+ m_shouldDumpResourceLoadStatistics = true;
+}
+
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (235689 => 235690)
--- trunk/Tools/WebKitTestRunner/TestInvocation.h 2018-09-05 21:15:53 UTC (rev 235689)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h 2018-09-05 21:25:06 UTC (rev 235690)
@@ -83,6 +83,8 @@
void didRemoveAllSessionCredentials();
+ void dumpResourceLoadStatistics();
+
private:
WKRetainPtr<WKMutableDictionaryRef> createTestSettingsDictionary();
@@ -129,9 +131,11 @@
bool m_dumpFrameLoadCallbacks { false };
bool m_dumpPixels { false };
bool m_pixelResultIsPending { false };
+ bool m_shouldDumpResourceLoadStatistics { false };
WhatToDump m_whatToDump { WhatToDump::RenderTree };
StringBuilder m_textOutput;
+ String m_savedResourceLoadStatistics;
WKRetainPtr<WKDataRef> m_audioResult;
WKRetainPtr<WKImageRef> m_pixelResult;
WKRetainPtr<WKArrayRef> m_repaintRects;