Resource Load Statistics: Communicate to the network process which domains to partition
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Mar 2017 04:02:14 +0000 (04:02 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Mar 2017 04:02:14 +0000 (04:02 +0000)
commit15778ec59c26d914ffe98742bcafeeaef8c9c92e
treee898f2781ea812ddfd140f2e2a7e0c19b702e0a7
parent74b7fa5afdf91405e3a0bf07d05d1565752b1e68
Resource Load Statistics: Communicate to the network process which domains to partition
https://bugs.webkit.org/show_bug.cgi?id=169322
<rdar://problem/30768921>

Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
    Now calls ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
    to tell the network process the domain has got user interaction.
(WebCore::ResourceLoadObserver::logUserInteraction):
    Now calls ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
    to tell the network process the domain has got user interaction.
(WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler):
    To allow TestRunner to set a domain for which
    partitioning should be applied.
(WebCore::ResourceLoadObserver::primaryDomain):
    New overloaded convenience function.
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
    Now bootstraps the network process' set of known domains to
    partition cookies for.
(WebCore::ResourceLoadStatisticsStore::setShouldPartitionCookiesCallback):
(WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
(WebCore::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
    Now tells the network process to start partitioning again
    when user interaction ages out.
* loader/ResourceLoadStatisticsStore.h:
* platform/network/NetworkStorageSession.h:
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::shouldPartitionCookiesForHost):
(WebCore::NetworkStorageSession::setShouldPartitionCookiesForHosts):

Source/WebKit2:

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
    Now consults WebCore::NetworkStorageSession::shouldPartitionCookiesForHost()
    to decide whether partitioning should be applied or not.
* UIProcess/API/C/WKCookieManager.cpp:
(WKCookieManagerSetCookieStoragePartitioningEnabled):
    To allow TestRunner to configure cookie partitioning.
* UIProcess/API/C/WKCookieManager.h:
* UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
(WKResourceLoadStatisticsManagerFireShouldPartitionCookiesHandler):
    To allow TestRunner to set a domain for which
    partitioning should be applied.
* UIProcess/API/C/WKResourceLoadStatisticsManager.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::setCookieStoragePartitioningEnabled):
    To allow TestRunner to configure cookie partitioning.
* UIProcess/WebCookieManagerProxy.h:
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
    To allow TestRunner to set a domain for which
    partitioning should be applied.
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::classifyResource):
    Now tells the network process as soon as a domain
    has been classified as prevalent.
(WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
    Overloaded function to allow injection of handlers for communication with the
    network process.
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
(WebKit::WebsiteDataStore::registerSharedResourceLoadObserver):
    Now sets two callback handlers for communication with the network process.
* UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

These changes add support for two new TestRunner functions:
- setCookieStoragePartitioningEnabled()
- statisticsFireShouldPartitionCookiesHandler()

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setCookieStoragePartitioningEnabled):
(WTR::TestRunner::statisticsFireShouldPartitionCookiesHandler):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::statisticsFireShouldPartitionCookiesHandler):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html: Added.
* http/tests/loading/resourceLoadStatistics/resources: Added.
* http/tests/loading/resourceLoadStatistics/resources/get-cookies.php: Added.
* http/tests/loading/resourceLoadStatistics/resources/set-cookie.php: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213623 268f45cc-cd09-0410-ab3c-d52691b4dbfc
39 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/resources/get-cookies.php [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/resources/set-cookie.php [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadObserver.h
Source/WebCore/loader/ResourceLoadStatisticsStore.cpp
Source/WebCore/loader/ResourceLoadStatisticsStore.h
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/NetworkProcess/NetworkProcess.messages.in
Source/WebKit2/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm
Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
Source/WebKit2/UIProcess/API/C/WKCookieManager.h
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in
Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp
Source/WebKit2/UIProcess/WebCookieManagerProxy.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp