Ensure ITP state is relayed to Network Process on restart
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Jun 2019 17:41:39 +0000 (17:41 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Jun 2019 17:41:39 +0000 (17:41 +0000)
commitc00245d4c8f81afa7da3502229807d7b7a95b74f
treee72010ebe465b69eae8ebc3def2cb9b1600ab057
parentddca33de73c7a77fe6c4e140792a88b7bdb4c838
Ensure ITP state is relayed to Network Process on restart
https://bugs.webkit.org/show_bug.cgi?id=198797
<rdar://problem/51646944>

Reviewed by Youenn Fablet.

Source/WebKit:

Now that the ITP state is maintained in the Network Process, we have to make sure that we update
that process with current ITP state if the Network Process crashes and is relaunched. This wasn't a
problem in earlier releases because we tracked all ITP state in the UIProcess.

This patch does the following:
1. Add a new method to WKWebsiteDataStore to allow us to trigger statistics processing, which has the
   side effect of syncing ITP state persistently so that it will be available after bouncing the process.
2. Adds a new test that sets a tracking domain, bounces the process, and confirms the state is still
   consistent.

Tested by TestWebKitAPI.

* NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
(WebKit::ResourceLoadStatisticsStore::processStatisticsAndDataRecords):
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _clearPrevalentDomain:completionHandler:]):
(-[WKWebsiteDataStore _processStatisticsAndDataRecords:]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
(WebKit::WebProcessPool::setResourceLoadStatisticsEnabled):
* UIProcess/WebProcessPool.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
(cleanupITPDatabase): Added.
(TEST:EnableDisableITP): Update to use cleanup method.
(TEST:NetworkProcessRestart): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246500 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm