Resource Load Statistics: Clear network process cache when clearing store
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Apr 2017 17:05:04 +0000 (17:05 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Apr 2017 17:05:04 +0000 (17:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171256
<rdar://problem/31802347>

Reviewed by Brent Fulgham.

Source/WebCore:

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

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::clearInMemoryStore):
    Better name.
(WebCore::ResourceLoadObserver::logUserInteraction):
    Now passes on the boolean parameter clearFirst to
    ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
(WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler):
    Now takes and passes on the boolean parameter clearFirst to
    ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
(WebCore::ResourceLoadObserver::statisticsStore): Deleted.
    This getter violated abstraction. The way it was used
    is now solved through dedicated functions.
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
    Now passes on the boolean parameter clearFirst to
    ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
(WebCore::ResourceLoadStatisticsStore::clearInMemory):
    Better name.
    Now triggers clearing of the associated network process cache.
(WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
    Now calls clearInMemory().
(WebCore::ResourceLoadStatisticsStore::setShouldPartitionCookiesCallback):
    Now expects a handler with the boolean parameter clearFirst.
(WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
    Now takes and passes on the boolean parameter clearFirst to
    m_shouldPartitionCookiesForDomainsHandler().
* loader/ResourceLoadStatisticsStore.h:
(WebCore::ResourceLoadStatisticsStore::clear): Deleted.
* platform/network/NetworkStorageSession.h:
    NetworkStorageSession::setShouldPartitionCookiesForHosts() now
    takes the boolean parameter clearFirst.
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::setShouldPartitionCookiesForHosts):
    Now clears m_topPrivatelyControlledDomainsForCookiePartitioning
    if the boolean parameter clearFirst is true.

Source/WebKit2:

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
    Now takes and passes on the boolean parameter clearFirst to
    WebCore::NetworkStorageSession::setShouldPartitionCookiesForHosts().
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
    The message ShouldPartitionCookiesForTopPrivatelyOwnedDomains now
    takes the boolean parameter clearFirst.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
    Now takes and passes on the boolean parameter clearFirst to
    Messages::NetworkProcess::ShouldPartitionCookiesForTopPrivatelyOwnedDomains.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
    The message ShouldPartitionCookiesForTopPrivatelyOwnedDomains now
    takes the boolean parameter clearFirst.
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
    Now uses the boolean parameter clearFirst when calling
    WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler().
(WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
    No longer uses the deleted store getter.
(WebKit::WebResourceLoadStatisticsManager::resetToConsistentState):
    No longer uses the deleted store getter.
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
    No sends the boolean parameter clearFirst to
    ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
(WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
    Now expects a handler with the boolean parameter clearFirst.
(WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
* UIProcess/WebResourceLoadStatisticsStore.h:
    Now uses the new WebCore::ResourceLoadObserver::clearInMemoryStore().
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
    Now takes and passes on the boolean parameter clearFirst in its
    message to the network process.
(WebKit::WebsiteDataStore::registerSharedResourceLoadObserver):
    Now expects a handler with the boolean parameter clearFirst.
* UIProcess/WebsiteData/WebsiteDataStore.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215741 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
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/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h

index 1e12a7f..0a8ba25 100644 (file)
@@ -1,3 +1,51 @@
+2017-04-25  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Clear network process cache when clearing store
+        https://bugs.webkit.org/show_bug.cgi?id=171256
+        <rdar://problem/31802347>
+
+        Reviewed by Brent Fulgham.
+
+        Test that covers this code:
+        http/tests/loading/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::clearInMemoryStore):
+            Better name.
+        (WebCore::ResourceLoadObserver::logUserInteraction):
+            Now passes on the boolean parameter clearFirst to
+            ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
+        (WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler):
+            Now takes and passes on the boolean parameter clearFirst to
+            ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
+        (WebCore::ResourceLoadObserver::statisticsStore): Deleted.
+            This getter violated abstraction. The way it was used
+            is now solved through dedicated functions.
+        * loader/ResourceLoadObserver.h:
+        * loader/ResourceLoadStatisticsStore.cpp:
+        (WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
+            Now passes on the boolean parameter clearFirst to
+            ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
+        (WebCore::ResourceLoadStatisticsStore::clearInMemory):
+            Better name.
+            Now triggers clearing of the associated network process cache.
+        (WebCore::ResourceLoadStatisticsStore::clearInMemoryAndPersistent):
+            Now calls clearInMemory().
+        (WebCore::ResourceLoadStatisticsStore::setShouldPartitionCookiesCallback):
+            Now expects a handler with the boolean parameter clearFirst.
+        (WebCore::ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler):
+            Now takes and passes on the boolean parameter clearFirst to
+            m_shouldPartitionCookiesForDomainsHandler().
+        * loader/ResourceLoadStatisticsStore.h:
+        (WebCore::ResourceLoadStatisticsStore::clear): Deleted.
+        * platform/network/NetworkStorageSession.h:
+            NetworkStorageSession::setShouldPartitionCookiesForHosts() now
+            takes the boolean parameter clearFirst.
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+        (WebCore::NetworkStorageSession::setShouldPartitionCookiesForHosts):
+            Now clears m_topPrivatelyControlledDomainsForCookiePartitioning
+            if the boolean parameter clearFirst is true.
+
 2017-04-25  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Add performance test for FontCache::systemFallbackForCharacters()
index c82767a..9d2eece 100644 (file)
@@ -57,17 +57,17 @@ ResourceLoadObserver& ResourceLoadObserver::sharedObserver()
     return resourceLoadObserver;
 }
 
-RefPtr<ResourceLoadStatisticsStore> ResourceLoadObserver::statisticsStore()
-{
-    ASSERT(m_store);
-    return m_store;
-}
-
 void ResourceLoadObserver::setStatisticsStore(Ref<ResourceLoadStatisticsStore>&& store)
 {
     m_store = WTFMove(store);
 }
 
+void ResourceLoadObserver::clearInMemoryStore()
+{
+    if (m_store)
+        m_store->clearInMemory();
+}
+    
 void ResourceLoadObserver::clearInMemoryAndPersistentStore()
 {
     if (m_store)
@@ -341,7 +341,7 @@ void ResourceLoadObserver::logUserInteraction(const URL& url)
     statistics.hadUserInteraction = true;
     statistics.mostRecentUserInteraction = WTF::currentTime();
 
-    m_store->fireShouldPartitionCookiesHandler({primaryDomainStr}, { });
+    m_store->fireShouldPartitionCookiesHandler({primaryDomainStr}, { }, false);
 }
 
 void ResourceLoadObserver::clearUserInteraction(const URL& url)
@@ -432,9 +432,9 @@ void ResourceLoadObserver::fireDataModificationHandler()
     m_store->fireDataModificationHandler();
 }
 
-void ResourceLoadObserver::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)
+void ResourceLoadObserver::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
 {
-    m_store->fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd);
+    m_store->fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd, clearFirst);
 }
 
 String ResourceLoadObserver::primaryDomain(const URL& url)
index 9af49ae..c27e907 100644 (file)
@@ -66,10 +66,10 @@ public:
     WEBCORE_EXPORT void setReducedTimestampResolution(double seconds);
 
     WEBCORE_EXPORT void fireDataModificationHandler();
-    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd);
+    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 
-    WEBCORE_EXPORT RefPtr<ResourceLoadStatisticsStore> statisticsStore();
     WEBCORE_EXPORT void setStatisticsStore(Ref<ResourceLoadStatisticsStore>&&);
+    WEBCORE_EXPORT void clearInMemoryStore();
     WEBCORE_EXPORT void clearInMemoryAndPersistentStore();
     WEBCORE_EXPORT void clearInMemoryAndPersistentStore(std::chrono::system_clock::time_point modifiedSince);
 
index fdd8e9c..182ec4b 100644 (file)
@@ -110,12 +110,18 @@ void ResourceLoadStatisticsStore::readDataFromDecoder(KeyedDecoder& decoder)
         m_resourceStatisticsMap.set(statistics.highLevelDomain, statistics);
     }
 
-    fireShouldPartitionCookiesHandler({ }, prevalentResourceDomainsWithoutUserInteraction);
+    fireShouldPartitionCookiesHandler({ }, prevalentResourceDomainsWithoutUserInteraction, true);
+}
+
+void ResourceLoadStatisticsStore::clearInMemory()
+{
+    m_resourceStatisticsMap.clear();
+    fireShouldPartitionCookiesHandler({ }, { }, true);
 }
 
 void ResourceLoadStatisticsStore::clearInMemoryAndPersistent()
 {
-    clear();
+    clearInMemory();
     if (m_writePersistentStoreHandler)
         m_writePersistentStoreHandler();
 }
@@ -157,7 +163,7 @@ void ResourceLoadStatisticsStore::setNotificationCallback(std::function<void()>
     m_dataAddedHandler = WTFMove(handler);
 }
 
-void ResourceLoadStatisticsStore::setShouldPartitionCookiesCallback(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)>&& handler)
+void ResourceLoadStatisticsStore::setShouldPartitionCookiesCallback(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&& handler)
 {
     m_shouldPartitionCookiesForDomainsHandler = WTFMove(handler);
 }
@@ -173,7 +179,7 @@ void ResourceLoadStatisticsStore::fireDataModificationHandler()
         m_dataAddedHandler();
 }
 
-void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
+void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(bool clearFirst)
 {
     Vector<String> domainsToRemove;
     Vector<String> domainsToAdd;
@@ -189,16 +195,16 @@ void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
         }
     }
     
-    fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd);
+    fireShouldPartitionCookiesHandler(domainsToRemove, domainsToAdd, clearFirst);
 }
 
-void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)
+void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
 {
     if (domainsToRemove.isEmpty() && domainsToAdd.isEmpty())
         return;
 
     if (m_shouldPartitionCookiesForDomainsHandler)
-        m_shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd);
+        m_shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd, clearFirst);
 }
 
 void ResourceLoadStatisticsStore::setTimeToLiveUserInteraction(double seconds)
index acf495b..08eb5c9 100644 (file)
@@ -46,7 +46,7 @@ public:
 
     bool isEmpty() const { return m_resourceStatisticsMap.isEmpty(); }
     size_t size() const { return m_resourceStatisticsMap.size(); }
-    void clear() { m_resourceStatisticsMap.clear(); }
+    WEBCORE_EXPORT void clearInMemory();
     WEBCORE_EXPORT void clearInMemoryAndPersistent();
 
     ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
@@ -58,13 +58,13 @@ public:
     WEBCORE_EXPORT Vector<ResourceLoadStatistics> takeStatistics();
 
     WEBCORE_EXPORT void setNotificationCallback(std::function<void()>);
-    WEBCORE_EXPORT void setShouldPartitionCookiesCallback(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)>&&);
+    WEBCORE_EXPORT void setShouldPartitionCookiesCallback(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&&);
     WEBCORE_EXPORT void setWritePersistentStoreCallback(std::function<void()>&&);
 
     void fireDataModificationHandler();
     void setTimeToLiveUserInteraction(double seconds);
-    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler();
-    void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd);
+    WEBCORE_EXPORT void fireShouldPartitionCookiesHandler(bool clearFirst);
+    void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 
     WEBCORE_EXPORT void processStatistics(std::function<void(ResourceLoadStatistics&)>&&);
 
@@ -76,7 +76,7 @@ private:
 
     HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap;
     std::function<void()> m_dataAddedHandler;
-    std::function<void(const Vector<String>&, const Vector<String>&)> m_shouldPartitionCookiesForDomainsHandler;
+    std::function<void(const Vector<String>&, const Vector<String>&, bool clearFirst)> m_shouldPartitionCookiesForDomainsHandler;
     std::function<void()> m_writePersistentStoreHandler;
 };
     
index 3f3eff1..3b0c423 100644 (file)
@@ -81,7 +81,7 @@ public:
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     WEBCORE_EXPORT String cookieStoragePartition(const ResourceRequest&) const;
     String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource) const;
-    WEBCORE_EXPORT void setShouldPartitionCookiesForHosts(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd);
+    WEBCORE_EXPORT void setShouldPartitionCookiesForHosts(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 #endif
 #elif USE(SOUP)
     NetworkStorageSession(SessionID, std::unique_ptr<SoupNetworkSession>&&);
index 22424ff..9a8ab9a 100644 (file)
@@ -151,8 +151,11 @@ bool NetworkStorageSession::shouldPartitionCookies(const String& topPrivatelyCon
     return m_topPrivatelyControlledDomainsForCookiePartitioning.contains(topPrivatelyControlledDomain);
 }
 
-void NetworkStorageSession::setShouldPartitionCookiesForHosts(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)
+void NetworkStorageSession::setShouldPartitionCookiesForHosts(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
 {
+    if (clearFirst)
+        m_topPrivatelyControlledDomainsForCookiePartitioning.clear();
+
     if (!domainsToRemove.isEmpty()) {
         for (auto& domain : domainsToRemove)
             m_topPrivatelyControlledDomainsForCookiePartitioning.remove(domain);
index 876d5ca..0c4356c 100644 (file)
@@ -1,3 +1,52 @@
+2017-04-25  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Clear network process cache when clearing store
+        https://bugs.webkit.org/show_bug.cgi?id=171256
+        <rdar://problem/31802347>
+
+        Reviewed by Brent Fulgham.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
+            Now takes and passes on the boolean parameter clearFirst to
+            WebCore::NetworkStorageSession::setShouldPartitionCookiesForHosts().
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+            The message ShouldPartitionCookiesForTopPrivatelyOwnedDomains now
+            takes the boolean parameter clearFirst.
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
+            Now takes and passes on the boolean parameter clearFirst to
+            Messages::NetworkProcess::ShouldPartitionCookiesForTopPrivatelyOwnedDomains.
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+            The message ShouldPartitionCookiesForTopPrivatelyOwnedDomains now
+            takes the boolean parameter clearFirst.
+        * UIProcess/WebResourceLoadStatisticsManager.cpp:
+        (WebKit::WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler):
+            Now uses the boolean parameter clearFirst when calling
+            WebCore::ResourceLoadObserver::fireShouldPartitionCookiesHandler().
+        (WebKit::WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore):
+            No longer uses the deleted store getter.
+        (WebKit::WebResourceLoadStatisticsManager::resetToConsistentState):
+            No longer uses the deleted store getter.
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
+            No sends the boolean parameter clearFirst to
+            ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler().
+        (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
+            Now expects a handler with the boolean parameter clearFirst.
+        (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+            Now uses the new WebCore::ResourceLoadObserver::clearInMemoryStore().
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::shouldPartitionCookiesForTopPrivatelyOwnedDomains):
+            Now takes and passes on the boolean parameter clearFirst in its
+            message to the network process.
+        (WebKit::WebsiteDataStore::registerSharedResourceLoadObserver):
+            Now expects a handler with the boolean parameter clearFirst.
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+
 2017-04-25  Chris Dumez  <cdumez@apple.com>
 
         Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
index 04d807a..a97239e 100644 (file)
@@ -312,9 +312,9 @@ void NetworkProcess::didGrantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t
 }
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-void NetworkProcess::shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)
+void NetworkProcess::shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd,  bool clearFirst)
 {
-    NetworkStorageSession::defaultStorageSession().setShouldPartitionCookiesForHosts(domainsToRemove, domainsToAdd);
+    NetworkStorageSession::defaultStorageSession().setShouldPartitionCookiesForHosts(domainsToRemove, domainsToAdd, clearFirst);
 }
 #endif
 
index 8f06b67..30052ca 100644 (file)
@@ -117,7 +117,7 @@ public:
     void grantSandboxExtensionsToDatabaseProcessForBlobs(const Vector<String>& filenames, Function<void ()>&& completionHandler);
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    void shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd);
+    void shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 #endif
 
     Seconds loadThrottleLatency() const { return m_loadThrottleLatency; }
index 22814b9..9fa3051 100644 (file)
@@ -80,6 +80,6 @@ messages -> NetworkProcess LegacyReceiver {
     DidGrantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID)
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    ShouldPartitionCookiesForTopPrivatelyOwnedDomains(Vector<String> domainsToRemove, Vector<String> domainsToAdd)
+    ShouldPartitionCookiesForTopPrivatelyOwnedDomains(Vector<String> domainsToRemove, Vector<String> domainsToAdd, bool clearFirst)
 #endif
 }
index 7f416e3..a8ea8c7 100644 (file)
@@ -293,9 +293,9 @@ void NetworkProcessProxy::grantSandboxExtensionsToDatabaseProcessForBlobs(uint64
 }
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-void NetworkProcessProxy::shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)
+void NetworkProcessProxy::shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
 {
-    connection()->send(Messages::NetworkProcess::ShouldPartitionCookiesForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd), 0);
+    connection()->send(Messages::NetworkProcess::ShouldPartitionCookiesForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd, clearFirst), 0);
 }
 #endif
 
index cfc5beb..c5eb1c6 100644 (file)
@@ -110,7 +110,7 @@ private:
     void didDeleteWebsiteDataForOrigins(uint64_t callbackID);
     void grantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID, const Vector<String>& paths);
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    void shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd);
+    void shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 #endif
     void logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, WebCore::ShouldSample);
     void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample);
index f1dea36..3abbc10 100644 (file)
@@ -32,7 +32,7 @@ messages -> NetworkProcessProxy LegacyReceiver {
     GrantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID, Vector<String> paths)
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    ShouldPartitionCookiesForTopPrivatelyOwnedDomains(Vector<String> domainsToRemove, Vector<String> domainsToAdd)
+    ShouldPartitionCookiesForTopPrivatelyOwnedDomains(Vector<String> domainsToRemove, Vector<String> domainsToAdd, bool clearFirst)
 #endif
 
     ProcessReadyToSuspend()
index 2eb98dc..7e25926 100644 (file)
@@ -89,9 +89,9 @@ void WebResourceLoadStatisticsManager::fireDataModificationHandler()
 void WebResourceLoadStatisticsManager::fireShouldPartitionCookiesHandler(const String& hostName, bool value)
 {
     if (value)
-        WebCore::ResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler({ }, {hostName});
+        WebCore::ResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler({ }, {hostName}, false);
     else
-        WebCore::ResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler({hostName}, { });
+        WebCore::ResourceLoadObserver::sharedObserver().fireShouldPartitionCookiesHandler({hostName}, { }, false);
 }
 
 void WebResourceLoadStatisticsManager::setNotifyPagesWhenDataRecordsWereScanned(bool value)
@@ -111,9 +111,7 @@ void WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(
 
 void WebResourceLoadStatisticsManager::clearInMemoryAndPersistentStore()
 {
-    auto store = WebCore::ResourceLoadObserver::sharedObserver().statisticsStore();
-    if (store)
-        store->clearInMemoryAndPersistent();
+    WebCore::ResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore();
 }
 
 void WebResourceLoadStatisticsManager::resetToConsistentState()
@@ -122,9 +120,7 @@ void WebResourceLoadStatisticsManager::resetToConsistentState()
     WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(false);
     WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(true);
     WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval(60);
-    auto store = WebCore::ResourceLoadObserver::sharedObserver().statisticsStore();
-    if (store)
-        store->clear();
+    WebCore::ResourceLoadObserver::sharedObserver().clearInMemoryStore();
 }
     
 } // namespace WebKit
index 9c4d39b..a30e7b3 100644 (file)
@@ -150,7 +150,9 @@ void WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
 void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(const Vector<WebCore::ResourceLoadStatistics>& origins)
 {
     coreStore().mergeStatistics(origins);
-    coreStore().fireShouldPartitionCookiesHandler();
+    // Fire before processing statistics to propagate user
+    // interaction as fast as possible to the network process.
+    coreStore().fireShouldPartitionCookiesHandler(false);
     processStatisticsAndDataRecords();
 }
 
@@ -179,11 +181,11 @@ void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver()
     });
 }
     
-void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)>&& shouldPartitionCookiesForDomainsHandler)
+void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&& shouldPartitionCookiesForDomainsHandler)
 {
     registerSharedResourceLoadObserver();
-    m_resourceLoadStatisticsStore->setShouldPartitionCookiesCallback([this, shouldPartitionCookiesForDomainsHandler = WTFMove(shouldPartitionCookiesForDomainsHandler)] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd) {
-        shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd);
+    m_resourceLoadStatisticsStore->setShouldPartitionCookiesCallback([this, shouldPartitionCookiesForDomainsHandler = WTFMove(shouldPartitionCookiesForDomainsHandler)] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst) {
+        shouldPartitionCookiesForDomainsHandler(domainsToRemove, domainsToAdd, clearFirst);
     });
     m_resourceLoadStatisticsStore->setWritePersistentStoreCallback([this]() {
         writeStoreToDisk();
@@ -196,7 +198,7 @@ void WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded()
         return;
 
     m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
-        coreStore().clear();
+        coreStore().clearInMemory();
 
         auto decoder = createDecoderFromDisk("full_browsing_session");
         if (!decoder)
index c0fc061..f0820d0 100644 (file)
@@ -63,7 +63,7 @@ public:
     void setResourceLoadStatisticsEnabled(bool);
     bool resourceLoadStatisticsEnabled() const;
     void registerSharedResourceLoadObserver();
-    void registerSharedResourceLoadObserver(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)>&& shouldPartitionCookiesForDomainsHandler);
+    void registerSharedResourceLoadObserver(std::function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&& shouldPartitionCookiesForDomainsHandler);
     
     void resourceLoadStatisticsUpdated(const Vector<WebCore::ResourceLoadStatistics>& origins);
 
index e70ccc2..ca9d611 100644 (file)
@@ -1055,10 +1055,10 @@ void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<Webs
 }
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-void WebsiteDataStore::shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd)
+void WebsiteDataStore::shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)
 {
     for (auto& processPool : processPools())
-        processPool->sendToNetworkingProcess(Messages::NetworkProcess::ShouldPartitionCookiesForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd));
+        processPool->sendToNetworkingProcess(Messages::NetworkProcess::ShouldPartitionCookiesForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd, clearFirst));
 }
 #endif
 
@@ -1235,8 +1235,8 @@ void WebsiteDataStore::registerSharedResourceLoadObserver()
     
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     m_resourceLoadStatistics->registerSharedResourceLoadObserver(
-        [this] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd) {
-            this->shouldPartitionCookiesForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd);
+        [this] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst) {
+            this->shouldPartitionCookiesForTopPrivatelyOwnedDomains(domainsToRemove, domainsToAdd, clearFirst);
         });
 #else
     m_resourceLoadStatistics->registerSharedResourceLoadObserver();
index 229979a..348174d 100644 (file)
@@ -92,7 +92,7 @@ public:
     void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<String>&& topPrivatelyControlledDomains, std::function<void(Vector<String>)> completionHandler);
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    void shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd);
+    void shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 #endif
     void resolveDirectoriesIfNecessary();
     const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration.applicationCacheDirectory; }