Resource Load Statistics: Grandfather domains for existing data records
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 May 2017 23:55:24 +0000 (23:55 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 May 2017 23:55:24 +0000 (23:55 +0000)
commitee1e7dadd3fe74715c99411359ebde17dba5a49e
tree78fb585791d4611b33aa442a38dc66dee23d8fe6
parent83433eab96df097105f4c3236f7ccea07d2b551d
Resource Load Statistics: Grandfather domains for existing data records
https://bugs.webkit.org/show_bug.cgi?id=172155
<rdar://problem/24913532>

Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/loading/resourceLoadStatistics/grandfathering.html

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::setGrandfathered):
(WebCore::ResourceLoadObserver::isGrandfathered):
(WebCore::ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval):
(WebCore::ResourceLoadObserver::setGrandfatheringTime):
    Functions for testing and configuration.
    ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval() changed as a result of moving
    WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval() here.
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::createEncoderFromData):
(WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
    Now contains endOfGrandfatheringTimestamp.
(WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
    Now makes a call to m_grandfatherExistingWebsiteDataHandler().
(WebCore::ResourceLoadStatisticsStore::setGrandfatherExistingWebsiteDataCallback):
(WebCore::ResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval):
    Changed as a result of moving
    WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval() here.
(WebCore::ResourceLoadStatisticsStore::setGrandfatheringTime):
(WebCore::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
    Renamed since it now also takes grandfathering into account.
(WebCore::ResourceLoadStatisticsStore::updateStatisticsForRemovedDataRecords):
    Fixed typo in local variable name.
(WebCore::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
(WebCore::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
    Convenience function added.
(WebCore::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
    Convenience function added.
(WebCore::ResourceLoadStatisticsStore::dataRecordsWereRemoved):
    Convenience function added.
(WebCore::ResourceLoadStatisticsStore::prevalentResourceDomainsWithoutUserInteraction): Deleted.
    Replaced by ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor().
* loader/ResourceLoadStatisticsStore.h:

Source/WebKit2:

When WebResourceLoadStatisticsStore starts fresh it needs
to scan existing website data records and 'grandfather' them to
allow ample time to capture user interaction.

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
(WKResourceLoadStatisticsManagerSetGrandfathered):
(WKResourceLoadStatisticsManagerIsGrandfathered):
(WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval):
(WKResourceLoadStatisticsManagerSetGrandfatheringTime):
    Functions for testing and configuration.
* UIProcess/API/C/WKResourceLoadStatisticsManager.h:
* UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm:
(WebKit::WebResourceLoadStatisticsManager::registerUserDefaultsIfNeeded):
    Added grandfathering configuration.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData):
    New function to get all top privately controlled domains that
    have website data.
* UIProcess/WebProcessProxy.h:
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::setGrandfathered):
(WebKit::WebResourceLoadStatisticsManager::isGrandfathered):
(WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
(WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
(WebKit::WebResourceLoadStatisticsManager::resetToConsistentState):
    Functions for testing and configuration.
    WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval() changed
    as a result of WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval()
    moving to WebCore::ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval().
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::initializeDataTypesToRemove):
(WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
    Moved handling of pending removal into WebCore::ResourceLoadStatisticsStore since
    that's where grandfathering happens.
(WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
    Moved registration of write persistent store callback and reading of Cocoa defaults to
    WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver without parameters
    so they are called for platforms without CFNETWORK_STORAGE_PARTITIONING.
    Now includes registering WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData()
    as handler for grandfathering since it involves reading of the website data store.
(WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
(WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
(WebKit::WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval): Deleted.
    Now happens in WebCore::ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval().
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataRecord.cpp:
(WebKit::WebsiteDataRecord::topPrivatelyControlledDomain):
    New function to ask a WebsiteDataRecord for its top privately controlled domain.
* UIProcess/WebsiteData/WebsiteDataRecord.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::topPrivatelyControlledDomainsWithWebsiteData):
    New function to get all top privately controlled domains that
    have website data.
* UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

Adds test infrastructure needed for the added functionality.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsGrandfathered):
(WTR::TestRunner::isStatisticsGrandfathered):
(WTR::TestRunner::installStatisticsDidScanDataRecordsCallback):
(WTR::TestRunner::statisticsDidScanDataRecordsCallback):
(WTR::TestRunner::setStatisticsGrandfatheringTime):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setStatisticsGrandfathered):
(WTR::TestController::isStatisticsGrandfathered):
(WTR::TestController::setStatisticsGrandfatheringTime):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/loading/resourceLoadStatistics/grandfathering-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/grandfathering.html: Added.
* platform/wk2/TestExpectations:
    Marked it Pass for WebKit2.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217014 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/resourceLoadStatistics/grandfathering-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/grandfathering.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadObserver.h
Source/WebCore/loader/ResourceLoadStatisticsStore.cpp
Source/WebCore/loader/ResourceLoadStatisticsStore.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.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/WebsiteDataRecord.cpp
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.h
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit2/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