Title: [213688] trunk
Revision
213688
Author
[email protected]
Date
2017-03-09 16:46:25 -0800 (Thu, 09 Mar 2017)

Log Message

Resource Load Statistics: Remove statistics data as part of full website data removal
https://bugs.webkit.org/show_bug.cgi?id=169448

Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::clearInMemoryAndPersistentStore):
    The version of this function that takes a modifiedSince parameter
    checks if it is equal to or less than the start of the Unix epoch.
    If so, it clears the store. This is to support clear all website
    data.
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
(WebCore::ResourceLoadStatisticsStore::setWritePersistentStoreCallback):
* loader/ResourceLoadStatisticsStore.h:
    Added m_writePersistentStoreHandler, a setter for it, and
    ResourceLoadStatisticsStore::clearInMemoryAndPersistent().

Source/WebKit2:

* UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
(WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore):
    Infrastructure for test.
* UIProcess/API/C/WKResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
    Infrastructure for test.
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
    Change due to the break-out of
    WebResourceLoadStatisticsStore::writeStoreToDisk().
(WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
    Now sets m_writePersistentStoreHandler in
    WebCore::ResourceLoadStatisticsStore.
(WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
    Separated out this function to make it available for the function set as
    m_writePersistentStoreHandler in WebCore::ResourceLoadStatisticsStore.
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::removeData):
    Both WebsiteDataStore::removeData() functions now cover resource load
    statistics.

Tools:

This patch adds infrastructure for the new TestRunner function
statisticsClearInMemoryAndPersistentStore().

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

LayoutTests:

* http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html: Added.
* platform/wk2/TestExpectations:
    Marked as [ Pass ] for WebKit2.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (213687 => 213688)


--- trunk/LayoutTests/ChangeLog	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/LayoutTests/ChangeLog	2017-03-10 00:46:25 UTC (rev 213688)
@@ -1,3 +1,15 @@
+2017-03-09  John Wilander  <[email protected]>
+
+        Resource Load Statistics: Remove statistics data as part of full website data removal
+        https://bugs.webkit.org/show_bug.cgi?id=169448
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html: Added.
+        * platform/wk2/TestExpectations:
+            Marked as [ Pass ] for WebKit2.
+
 2017-03-09  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Show HTTP protocol version and other Network Load Metrics (IP Address, Priority, Connection ID)

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-expected.txt (0 => 213688)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store-expected.txt	2017-03-10 00:46:25 UTC (rev 213688)
@@ -0,0 +1,9 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Test Cleared Store
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+PASS Host is no longer a prevalent resource after the store was cleared.
+

Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html (0 => 213688)


--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html	2017-03-10 00:46:25 UTC (rev 213688)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Test Cleared Store</title>
+    <script src=""
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testPassed("Host classified as prevalent resource.");
+        else
+            testFailed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsClearInMemoryAndPersistentStore();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host is still a prevalent resource after the store was cleared.");
+        else
+            testPassed("Host is no longer a prevalent resource after the store was cleared.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (213687 => 213688)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2017-03-10 00:46:25 UTC (rev 213688)
@@ -713,6 +713,7 @@
 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ]
 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
 http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Pass ]
 
 ### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
 ########################################

Modified: trunk/Source/WebCore/ChangeLog (213687 => 213688)


--- trunk/Source/WebCore/ChangeLog	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebCore/ChangeLog	2017-03-10 00:46:25 UTC (rev 213688)
@@ -1,3 +1,26 @@
+2017-03-09  John Wilander  <[email protected]>
+
+        Resource Load Statistics: Remove statistics data as part of full website data removal
+        https://bugs.webkit.org/show_bug.cgi?id=169448
+
+        Reviewed by Alex Christensen.
+
+        Test: http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::clearInMemoryAndPersistentStore):
+            The version of this function that takes a modifiedSince parameter
+            checks if it is equal to or less than the start of the Unix epoch.
+            If so, it clears the store. This is to support clear all website
+            data.
+        * loader/ResourceLoadObserver.h:
+        * loader/ResourceLoadStatisticsStore.cpp:
+        (WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
+        (WebCore::ResourceLoadStatisticsStore::setWritePersistentStoreCallback):
+        * loader/ResourceLoadStatisticsStore.h:
+            Added m_writePersistentStoreHandler, a setter for it, and
+            ResourceLoadStatisticsStore::clearInMemoryAndPersistent().
+
 2017-03-09  Matt Rajca  <[email protected]>
 
         Only consider autoplay interference in the first 10 seconds of playback.

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (213687 => 213688)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -68,6 +68,18 @@
     m_store = WTFMove(store);
 }
 
+void ResourceLoadObserver::clearInMemoryAndPersistentStore()
+{
+    m_store->clearInMemoryAndPersistent();
+}
+
+void ResourceLoadObserver::clearInMemoryAndPersistentStore(std::chrono::system_clock::time_point modifiedSince)
+{
+    auto then = std::chrono::system_clock::to_time_t(modifiedSince);
+    if (then <= 0)
+        clearInMemoryAndPersistentStore();
+}
+
 static inline bool is3xxRedirect(const ResourceResponse& response)
 {
     return response.httpStatusCode() >= 300 && response.httpStatusCode() <= 399;

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (213687 => 213688)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.h	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h	2017-03-10 00:46:25 UTC (rev 213688)
@@ -70,6 +70,8 @@
 
     WEBCORE_EXPORT RefPtr<ResourceLoadStatisticsStore> statisticsStore();
     WEBCORE_EXPORT void setStatisticsStore(Ref<ResourceLoadStatisticsStore>&&);
+    WEBCORE_EXPORT void clearInMemoryAndPersistentStore();
+    WEBCORE_EXPORT void clearInMemoryAndPersistentStore(std::chrono::system_clock::time_point modifiedSince);
 
     WEBCORE_EXPORT String statisticsForOrigin(const String&);
 

Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp (213687 => 213688)


--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -111,6 +111,13 @@
     fireShouldPartitionCookiesHandler(prevalentResourceDomainsWithoutUserInteraction, true);
 }
 
+void ResourceLoadStatisticsStore::clearInMemoryAndPersistent()
+{
+    clear();
+    if (m_writePersistentStoreHandler)
+        m_writePersistentStoreHandler();
+}
+
 String ResourceLoadStatisticsStore::statisticsForOrigin(const String& origin)
 {
     auto iter = m_resourceStatisticsMap.find(origin);
@@ -153,6 +160,11 @@
     m_shouldPartitionCookiesForDomainsHandler = WTFMove(handler);
 }
     
+void ResourceLoadStatisticsStore::setWritePersistentStoreCallback(std::function<void()>&& handler)
+{
+    m_writePersistentStoreHandler = WTFMove(handler);
+}
+
 void ResourceLoadStatisticsStore::fireDataModificationHandler()
 {
     if (m_dataAddedHandler)

Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h (213687 => 213688)


--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h	2017-03-10 00:46:25 UTC (rev 213688)
@@ -47,6 +47,7 @@
     bool isEmpty() const { return m_resourceStatisticsMap.isEmpty(); }
     size_t size() const { return m_resourceStatisticsMap.size(); }
     void clear() { m_resourceStatisticsMap.clear(); }
+    WEBCORE_EXPORT void clearInMemoryAndPersistent();
 
     ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
     void setResourceStatisticsForPrimaryDomain(const String&, ResourceLoadStatistics&&);
@@ -58,7 +59,9 @@
 
     WEBCORE_EXPORT void setNotificationCallback(std::function<void()>);
     WEBCORE_EXPORT void setShouldPartitionCookiesCallback(std::function<void(const Vector<String>& primaryDomains, bool value)>&&);
+    WEBCORE_EXPORT void setWritePersistentStoreCallback(std::function<void()>&&);
 
+
     void fireDataModificationHandler();
     void setTimeToLiveUserInteraction(double seconds);
     WEBCORE_EXPORT void fireShouldPartitionCookiesHandler(const String& primaryDomain, bool value);
@@ -75,6 +78,7 @@
     HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap;
     std::function<void()> m_dataAddedHandler;
     std::function<void(const Vector<String>& primaryDomains, bool value)> m_shouldPartitionCookiesForDomainsHandler;
+    std::function<void()> m_writePersistentStoreHandler;
 };
     
 } // namespace WebCore

Modified: trunk/Source/WebKit2/ChangeLog (213687 => 213688)


--- trunk/Source/WebKit2/ChangeLog	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/ChangeLog	2017-03-10 00:46:25 UTC (rev 213688)
@@ -1,3 +1,34 @@
+2017-03-09  John Wilander  <[email protected]>
+
+        Resource Load Statistics: Remove statistics data as part of full website data removal
+        https://bugs.webkit.org/show_bug.cgi?id=169448
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
+        (WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore):
+            Infrastructure for test.
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsManager.cpp:
+        (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
+            Infrastructure for test.
+        * UIProcess/WebResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
+            Change due to the break-out of
+            WebResourceLoadStatisticsStore::writeStoreToDisk().
+        (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
+            Now sets m_writePersistentStoreHandler in
+            WebCore::ResourceLoadStatisticsStore.
+        (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
+            Separated out this function to make it available for the function set as
+            m_writePersistentStoreHandler in WebCore::ResourceLoadStatisticsStore.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::removeData):
+            Both WebsiteDataStore::removeData() functions now cover resource load
+            statistics.
+
 2017-03-09  Brady Eidson  <[email protected]>
 
         Add WKURLSchemeHandler API for handling custom protocols.

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp (213687 => 213688)


--- trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -101,6 +101,11 @@
     WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(seconds);
 }
 
+void WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore()
+{
+    WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore();
+}
+
 void WKResourceLoadStatisticsManagerResetToConsistentState()
 {
     WebResourceLoadStatisticsManager::resetToConsistentState();

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h (213687 => 213688)


--- trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h	2017-03-10 00:46:25 UTC (rev 213688)
@@ -46,6 +46,7 @@
     WK_EXPORT void WKResourceLoadStatisticsManagerSetNotifyPagesWhenDataRecordsWereScanned(bool value);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval(double seconds);
+    WK_EXPORT void WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore();
     WK_EXPORT void WKResourceLoadStatisticsManagerResetToConsistentState();
 
 #ifdef __cplusplus

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp (213687 => 213688)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -106,6 +106,13 @@
     WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval(seconds);
 }
 
+void WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore()
+{
+    auto store = WebCore::ResourceLoadObserver::sharedObserver().statisticsStore();
+    if (store)
+        store->clearInMemoryAndPersistent();
+}
+
 void WebResourceLoadStatisticsManager::resetToConsistentState()
 {
     WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(2592000);

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h (213687 => 213688)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h	2017-03-10 00:46:25 UTC (rev 213688)
@@ -52,6 +52,7 @@
     static void setNotifyPagesWhenDataRecordsWereScanned(bool);
     static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value);
     static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
+    static void clearInMemoryAndPersistentStore();
     static void resetToConsistentState();
 
 private:

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp (213687 => 213688)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -146,10 +146,8 @@
         });
     }
     removeDataRecords();
-    
-    auto encoder = coreStore().createEncoderFromData();
-    
-    writeEncoderToDisk(*encoder.get(), "full_browsing_session");
+
+    writeStoreToDisk();
 }
 
 void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(const Vector<WebCore::ResourceLoadStatistics>& origins)
@@ -189,6 +187,9 @@
     m_resourceLoadStatisticsStore->setShouldPartitionCookiesCallback([this, shouldPartitionCookiesForDomainsHandler = WTFMove(shouldPartitionCookiesForDomainsHandler)] (const Vector<String>& primaryDomains, bool value) {
         shouldPartitionCookiesForDomainsHandler(primaryDomains, value);
     });
+    m_resourceLoadStatisticsStore->setWritePersistentStoreCallback([this]() {
+        writeStoreToDisk();
+    });
 }
 
 void WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded()
@@ -236,6 +237,12 @@
     return pathByAppendingComponent(m_statisticsStoragePath, label + "_resourceLog.plist");
 }
 
+void WebResourceLoadStatisticsStore::writeStoreToDisk()
+{
+    auto encoder = coreStore().createEncoderFromData();
+    writeEncoderToDisk(*encoder.get(), "full_browsing_session");
+}
+
 void WebResourceLoadStatisticsStore::writeEncoderToDisk(KeyedEncoder& encoder, const String& label) const
 {
     RefPtr<SharedBuffer> rawData = encoder.finishEncoding();

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h (213687 => 213688)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h	2017-03-10 00:46:25 UTC (rev 213688)
@@ -89,6 +89,7 @@
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
+    void writeStoreToDisk();
     void writeEncoderToDisk(WebCore::KeyedEncoder&, const String& label) const;
     std::unique_ptr<WebCore::KeyedDecoder> createDecoderFromDisk(const String& label) const;
 

Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (213687 => 213688)


--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -39,6 +39,7 @@
 #include <WebCore/DatabaseTracker.h>
 #include <WebCore/HTMLMediaElement.h>
 #include <WebCore/OriginLock.h>
+#include <WebCore/ResourceLoadObserver.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/SecurityOriginData.h>
 #include <wtf/RunLoop.h>
@@ -769,6 +770,9 @@
     }
 #endif
 
+    if (dataTypes.contains(WebsiteDataType::WebsiteDataTypeResourceLoadStatistics))
+        WebCore::ResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore(modifiedSince);
+
     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
     callbackAggregator->callIfNeeded();
 }
@@ -1035,6 +1039,9 @@
     }
 #endif
 
+    if (dataTypes.contains(WebsiteDataType::WebsiteDataTypeResourceLoadStatistics))
+        WebCore::ResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore();
+
     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
     callbackAggregator->callIfNeeded();
 }

Modified: trunk/Tools/ChangeLog (213687 => 213688)


--- trunk/Tools/ChangeLog	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Tools/ChangeLog	2017-03-10 00:46:25 UTC (rev 213688)
@@ -1,3 +1,23 @@
+2017-03-09  John Wilander  <[email protected]>
+
+        Resource Load Statistics: Remove statistics data as part of full website data removal
+        https://bugs.webkit.org/show_bug.cgi?id=169448
+
+        Reviewed by Alex Christensen.
+
+        This patch adds infrastructure for the new TestRunner function
+        statisticsClearInMemoryAndPersistentStore().
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::statisticsClearInMemoryAndPersistentStore):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::statisticsClearInMemoryAndPersistentStore):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2017-03-09  Dean Jackson  <[email protected]>
 
         WebGPU: Backend - Buffers

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (213687 => 213688)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2017-03-10 00:46:25 UTC (rev 213688)
@@ -263,6 +263,7 @@
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(boolean value);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(boolean value);
     void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double seconds);
+    void statisticsClearInMemoryAndPersistentStore();
     void statisticsResetToConsistentState();
 
     // Open panel

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (213687 => 213688)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -1382,6 +1382,12 @@
     WKRetainPtr<WKDoubleRef> messageBody(AdoptWK, WKDoubleCreate(seconds));
     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
 }
+
+void TestRunner::statisticsClearInMemoryAndPersistentStore()
+{
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsClearInMemoryAndPersistentStore"));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+}
     
 void TestRunner::statisticsResetToConsistentState()
 {

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (213687 => 213688)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2017-03-10 00:46:25 UTC (rev 213688)
@@ -364,6 +364,7 @@
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
     void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double);
+    void statisticsClearInMemoryAndPersistentStore();
     void statisticsResetToConsistentState();
 
     // Open panel

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (213687 => 213688)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -2292,6 +2292,12 @@
 {
     WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval(seconds);
 }
+
+void TestController::statisticsClearInMemoryAndPersistentStore()
+{
+    WKResourceLoadStatisticsManagerClearInMemoryAndPersistentStore();
+}
+
 void TestController::statisticsResetToConsistentState()
 {
     WKResourceLoadStatisticsManagerResetToConsistentState();

Modified: trunk/Tools/WebKitTestRunner/TestController.h (213687 => 213688)


--- trunk/Tools/WebKitTestRunner/TestController.h	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2017-03-10 00:46:25 UTC (rev 213688)
@@ -161,6 +161,7 @@
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
     void setStatisticsMinimumTimeBetweeenDataRecordsRemoval(double);
+    void statisticsClearInMemoryAndPersistentStore();
     void statisticsResetToConsistentState();
 
     WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (213687 => 213688)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2017-03-10 00:44:42 UTC (rev 213687)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2017-03-10 00:46:25 UTC (rev 213688)
@@ -1032,6 +1032,11 @@
         return nullptr;
     }
     
+    if (WKStringIsEqualToUTF8CString(messageName, "StatisticsClearInMemoryAndPersistentStore")) {
+        TestController::singleton().statisticsClearInMemoryAndPersistentStore();
+        return nullptr;
+    }
+    
     if (WKStringIsEqualToUTF8CString(messageName, "StatisticsResetToConsistentState")) {
         TestController::singleton().statisticsResetToConsistentState();
         return nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to