Resource Load Statistics: Enable basic functionality in experimental debug mode
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jul 2018 03:10:53 +0000 (03:10 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jul 2018 03:10:53 +0000 (03:10 +0000)
commit02f9497c8d134b6169ef4c95425159aaab57e5dc
treebede6b784d4a54d788e2129b4ecb5754f5b2a4f6
parent7fdd76edbe7e28766e67f908d8b3253de1af8069
Resource Load Statistics: Enable basic functionality in experimental debug mode
https://bugs.webkit.org/show_bug.cgi?id=187835
<rdar://problem/42408590>

Reviewed by Chris Dumez.

This patch makes the experimental ITP Debug Mode feature work, at least
Source/WebKit:

to a basic level. This means:
- Debug logging on the INFO level.
- Permanently treat 3rdpartytestwebkit.org as a prevalent resource.
- Support manual setting of a custom permanently prevalent resource through user
  defaults on Cocoa platforms.

* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler):
(WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode):
    Test infrastructure.
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm:
(WebKit::ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded):
    Used to pick up custom set prevalent resource on Cocoa platforms (for debug mode).
* UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentDueToDebugMode):
(WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords):
    Now skips processing of debug mode prevalent resources so that they
    stay prevalent.
(WebKit::ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode):
    Convenience function to make 3rdpartytestwebkit.org and any custom domain
    set through ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode()
    be prevalent resources.
(WebKit::ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode):
(WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode):
    Sets a custom domain to always be treated as prevalent in debug mode.
(WebKit::ResourceLoadStatisticsMemoryStore::clear):
    Now makes sure 3rdpartytestwebkit.org and any custom domain set through
    ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode()
    are prevalent resources even after a clear of the store.
(WebKit::debugLogDomainsInBatches):
    We may have too many domain names to fit in a single log statement.
    This function logs them in batches of 50, if we have more than 50.
(WebKit::ResourceLoadStatisticsMemoryStore::updateCookiePartitioning):
    Now makes use of debugLogDomainsInBatches() in debug mode.
* UIProcess/ResourceLoadStatisticsMemoryStore.h:
(WebKit::ResourceLoadStatisticsMemoryStore::isDebugModeEnabled const):
* UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
(WebKit::ResourceLoadStatisticsPersistentStorage::populateMemoryStoreFromDisk):
    Now accepts a non-empty memory store in debug mode. This is to support a
    pre-populated store with 3rdpartytestwebkit.org and any custom domain already
    set as prevalent.
(WebKit::ResourceLoadStatisticsPersistentStorage::setResourceLoadStatisticsDebugMode):
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
(WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode):
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode):
* UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

to a basic level. All of the changes to TestRunner are to support the
layout tests for the functionality.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsDebugMode):
(WTR::TestRunner::statisticsCallDidSetDebugModeCallback):
(WTR::TestRunner::setStatisticsPrevalentResourceForDebugMode):
(WTR::TestRunner::statisticsCallDidSetPrevalentResourceForDebugModeCallback):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setStatisticsDebugMode):
(WTR::TestController::setStatisticsPrevalentResourceForDebugMode):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
(WTR::TestInvocation::didSetStatisticsDebugMode):
(WTR::TestInvocation::didSetPrevalentResourceForDebugMode):
* WebKitTestRunner/TestInvocation.h:

LayoutTests:

to a basic level.

* http/tests/resourceLoadStatistics/enable-debug-mode-expected.txt: Added.
* http/tests/resourceLoadStatistics/enable-debug-mode.html: Added.
* http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode-expected.txt: Added.
* http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/resourceLoadStatistics/enable-debug-mode-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/enable-debug-mode.html [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode.html [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h
Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp
Tools/WebKitTestRunner/TestInvocation.h