Title: [239409] branches/safari-606-branch/Source
Revision
239409
Author
[email protected]
Date
2018-12-19 16:58:21 -0800 (Wed, 19 Dec 2018)

Log Message

Apply patch. rdar://problem/46848447

Modified Paths


Diff

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (239408 => 239409)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-12-20 00:58:21 UTC (rev 239409)
@@ -4,6 +4,33 @@
 
     2018-12-19  Brent Fulgham  <[email protected]>
 
+            Add ability to configure document.cookie lifetime cap through user defaults
+            https://bugs.webkit.org/show_bug.cgi?id=191480
+            <rdar://problem/45240871>
+
+            Reviewed by Chris Dumez.
+
+            No new tests. Existing test makes sure we don't regress.
+
+            This change makes the capped lifetime in seconds configurable through
+            user defaults.
+
+            * platform/network/NetworkStorageSession.cpp:
+            (WebCore::NetworkStorageSession::setAgeCapForClientSideCookies):
+            (WebCore::NetworkStorageSession::ageCapForClientSideCookies const):
+            (WebCore::NetworkStorageSession::setShouldCapLifetimeForClientSideCookies): Deleted.
+            (WebCore::NetworkStorageSession::shouldCapLifetimeForClientSideCookies const): Deleted.
+            * platform/network/NetworkStorageSession.h:
+            * platform/network/mac/CookieJarMac.mm:
+            (WebCore::filterCookies):
+            (WebCore::setCookiesFromDOM):
+
+2018-12-19  Alan Coon  <[email protected]>
+
+        Apply patch. rdar://problem/46848447
+
+    2018-12-19  Brent Fulgham  <[email protected]>
+
             Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled
             https://bugs.webkit.org/show_bug.cgi?id=190687
             <rdar://problem/45349024>

Modified: branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp (239408 => 239409)


--- branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp	2018-12-20 00:58:21 UTC (rev 239409)
@@ -74,14 +74,14 @@
         removeProcessPrivilege(ProcessPrivilege::CanAccessRawCookies);
 }
 
-void NetworkStorageSession::setShouldCapLifetimeForClientSideCookies(bool value)
+void NetworkStorageSession::setAgeCapForClientSideCookies(std::optional<Seconds> seconds)
 {
-    m_shouldCapLifetimeForClientSideCookies = value;
+    m_ageCapForClientSideCookies = seconds;
 }
 
-bool NetworkStorageSession::shouldCapLifetimeForClientSideCookies() const
+std::optional<Seconds> NetworkStorageSession::ageCapForClientSideCookies() const
 {
-    return m_shouldCapLifetimeForClientSideCookies;
+    return m_ageCapForClientSideCookies;
 }
 
 }

Modified: branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h (239408 => 239409)


--- branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h	2018-12-20 00:58:21 UTC (rev 239409)
@@ -101,8 +101,8 @@
     WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource) const;
     WEBCORE_EXPORT String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
     WEBCORE_EXPORT void setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst);
-    WEBCORE_EXPORT void setShouldCapLifetimeForClientSideCookies(bool);
-    WEBCORE_EXPORT bool shouldCapLifetimeForClientSideCookies() const;
+    WEBCORE_EXPORT void setAgeCapForClientSideCookies(std::optional<Seconds>);
+    WEBCORE_EXPORT std::optional<Seconds> ageCapForClientSideCookies() const;
     WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains);
     WEBCORE_EXPORT bool hasStorageAccess(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID) const;
     WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const;
@@ -177,7 +177,7 @@
     HashSet<String> m_topPrivatelyControlledDomainsToBlock;
     HashMap<uint64_t, HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_framesGrantedStorageAccess;
     HashMap<uint64_t, HashMap<String, String>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_pagesGrantedStorageAccess;
-    bool m_shouldCapLifetimeForClientSideCookies { false };
+    std::optional<Seconds> m_ageCapForClientSideCookies { };
 #endif
 
 #if PLATFORM(COCOA)

Modified: branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm (239408 => 239409)


--- branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm	2018-12-20 00:58:21 UTC (rev 239409)
@@ -145,13 +145,12 @@
     return cookiesForURL(nsCookieStorage.get(), url, firstParty, sameSiteInfo);
 }
 
-static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies, bool shouldCapLifetime)
+static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies, std::optional<Seconds> cappedLifetime)
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
     NSUInteger count = [unfilteredCookies count];
     RetainPtr<NSMutableArray> filteredCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:count]);
 
-    const NSTimeInterval secondsPerWeek = 7 * 24 * 60 * 60;
     for (NSUInteger i = 0; i < count; ++i) {
         NSHTTPCookie *cookie = (NSHTTPCookie *)[unfilteredCookies objectAtIndex:i];
 
@@ -166,10 +165,10 @@
             continue;
 
         // Cap lifetime of persistent, client-side cookies to a week.
-        if (shouldCapLifetime && ![cookie isSessionOnly]) {
-            if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > secondsPerWeek) {
+        if (cappedLifetime && ![cookie isSessionOnly]) {
+            if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > cappedLifetime->seconds()) {
                 RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> properties = adoptNS([[cookie properties] mutableCopy]);
-                RetainPtr<NSDate> dateInAWeek = adoptNS([[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerWeek]);
+                RetainPtr<NSDate> dateInAWeek = adoptNS([[NSDate alloc] initWithTimeIntervalSinceNow:cappedLifetime->seconds()]);
                 [properties setObject:dateInAWeek.get() forKey:NSHTTPCookieExpires];
                 cookie = [NSHTTPCookie cookieWithProperties:properties.get()];
             }
@@ -336,9 +335,9 @@
 #endif
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, session.shouldCapLifetimeForClientSideCookies());
+    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, session.ageCapForClientSideCookies());
 #else
-    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);
+    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, std::optional<Seconds>());
 #endif
     ASSERT([filteredCookies.get() count] <= 1);
 

Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-12-20 00:58:21 UTC (rev 239409)
@@ -4,6 +4,51 @@
 
     2018-12-19  Brent Fulgham  <[email protected]>
 
+            Add ability to configure document.cookie lifetime cap through user defaults
+            https://bugs.webkit.org/show_bug.cgi?id=191480
+            <rdar://problem/45240871>
+
+            Reviewed by Chris Dumez.
+
+            This change makes the capped lifetime in seconds configurable through
+            user defaults.
+
+            * NetworkProcess/NetworkProcess.cpp:
+            (WebKit::NetworkProcess::setAgeCapForClientSideCookies):
+            (WebKit::NetworkProcess::setShouldCapLifetimeForClientSideCookies): Deleted.
+                Renamed setAgeCapForClientSideCookies().
+            * NetworkProcess/NetworkProcess.h:
+            * NetworkProcess/NetworkProcess.messages.in:
+            * UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm:
+            (WebKit::ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded):
+            * UIProcess/Network/NetworkProcessProxy.cpp:
+            (WebKit::NetworkProcessProxy::setAgeCapForClientSideCookies):
+            (WebKit::NetworkProcessProxy::didSetAgeCapForClientSideCookies):
+                Renamed setAgeCapForClientSideCookies().
+            (WebKit::NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies): Deleted.
+            (WebKit::NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies): Deleted.
+            * UIProcess/Network/NetworkProcessProxy.h:
+            * UIProcess/Network/NetworkProcessProxy.messages.in:
+            * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
+            (WebKit::ResourceLoadStatisticsMemoryStore::setAgeCapForClientSideCookies):
+            (WebKit::ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap):
+            (WebKit::ResourceLoadStatisticsMemoryStore::didCreateNetworkProcess):
+            * UIProcess/ResourceLoadStatisticsMemoryStore.h:
+            * UIProcess/WebResourceLoadStatisticsStore.cpp:
+            (WebKit::WebResourceLoadStatisticsStore::didCreateNetworkProcess):
+            * UIProcess/WebResourceLoadStatisticsStore.h:
+            * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+            (WebKit::WebsiteDataStore::setAgeCapForClientSideCookies):
+            (WebKit::WebsiteDataStore::setShouldCapLifetimeForClientSideCookies): Deleted.
+                Renamed setAgeCapForClientSideCookies().
+            * UIProcess/WebsiteData/WebsiteDataStore.h:
+
+2018-12-19  Alan Coon  <[email protected]>
+
+        Apply patch. rdar://problem/46848447
+
+    2018-12-19  Brent Fulgham  <[email protected]>
+
             Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled
             https://bugs.webkit.org/show_bug.cgi?id=190687
             <rdar://problem/45349024>

Modified: branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-12-20 00:58:21 UTC (rev 239409)
@@ -426,11 +426,11 @@
     parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdatePartitionOrBlockCookies(callbackId), 0);
 }
 
-void NetworkProcess::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId)
+void NetworkProcess::setAgeCapForClientSideCookies(PAL::SessionID sessionID, std::optional<Seconds> seconds, uint64_t contextId)
 {
     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
-        networkStorageSession->setShouldCapLifetimeForClientSideCookies(value);
-    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetShouldCapLifetimeForClientSideCookies(contextId), 0);
+        networkStorageSession->setAgeCapForClientSideCookies(seconds);
+    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetAgeCapForClientSideCookies(contextId), 0);
 }
 
 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)

Modified: branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h	2018-12-20 00:58:21 UTC (rev 239409)
@@ -132,7 +132,7 @@
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId);
-    void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, bool value, uint64_t contextId);
+    void setAgeCapForClientSideCookies(PAL::SessionID, std::optional<Seconds>, uint64_t contextId);
     void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
     void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId);
     void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId);

Modified: branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-12-20 00:58:21 UTC (rev 239409)
@@ -85,7 +85,7 @@
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId)
-    SetShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId)
+SetAgeCapForClientSideCookies(PAL::SessionID sessionID, std::optional<Seconds> seconds, uint64_t contextId)
     HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
     GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
     GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId)

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm	2018-12-20 00:58:21 UTC (rev 239409)
@@ -49,6 +49,10 @@
         if (grandfatheringTime > 0_s && grandfatheringTime <= 24_h * 7)
             setGrandfatheringTime(grandfatheringTime);
 
+        Seconds clientSideCookiesAgeCap([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsClientSideCookiesAgeCap"]);
+        if (clientSideCookiesAgeCap > 0_s && clientSideCookiesAgeCap <= 24_h * 365)
+            setAgeCapForClientSideCookies(clientSideCookiesAgeCap);
+
         setDebugLogggingEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"ResourceLoadStatisticsDebugLoggingEnabled"]);
         setResourceLoadStatisticsDebugMode([[NSUserDefaults standardUserDefaults] boolForKey:@"ExperimentalResourceLoadStatisticsDebugMode"]);
         setStorageAccessPromptsEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"ExperimentalStorageAccessPromptsEnabled"]);

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2018-12-20 00:58:21 UTC (rev 239409)
@@ -444,7 +444,7 @@
     m_updatePartitionOrBlockCookiesCallbackMap.take(callbackId)();
 }
 
-void NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
+    void NetworkProcessProxy::setAgeCapForClientSideCookies(PAL::SessionID sessionID, std::optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler)
 {
     if (!canSendMessage()) {
         completionHandler();
@@ -456,10 +456,10 @@
         completionHandler();
     });
     ASSERT_UNUSED(addResult, addResult.isNewEntry);
-    send(Messages::NetworkProcess::SetShouldCapLifetimeForClientSideCookies(sessionID, shouldCapLifetime == ShouldCapLifetimeForClientSideCookies::Yes, callbackId), 0);
+    send(Messages::NetworkProcess::SetAgeCapForClientSideCookies(sessionID, seconds, callbackId), 0);
 }
     
-void NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
+void NetworkProcessProxy::didSetAgeCapForClientSideCookies(uint64_t callbackId)
 {
     m_updatePartitionOrBlockCookiesCallbackMap.take(callbackId)();
 }

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2018-12-20 00:58:21 UTC (rev 239409)
@@ -79,7 +79,7 @@
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&);
-    void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&);
+    void setAgeCapForClientSideCookies(PAL::SessionID, std::optional<Seconds>, CompletionHandler<void()>&&);
     void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
     void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&);
     void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
@@ -149,7 +149,7 @@
 #endif
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void didUpdatePartitionOrBlockCookies(uint64_t callbackId);
-    void didSetShouldCapLifetimeForClientSideCookies(uint64_t contextId);
+    void didSetAgeCapForClientSideCookies(uint64_t contextId);
     void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
     void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
 #endif

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2018-12-20 00:58:21 UTC (rev 239409)
@@ -48,7 +48,7 @@
 #endif
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     DidUpdatePartitionOrBlockCookies(uint64_t callbackId)
-    DidSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
+    DidSetAgeCapForClientSideCookies(uint64_t callbackId)
     StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
     AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
 #endif

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp	2018-12-20 00:58:21 UTC (rev 239409)
@@ -783,6 +783,27 @@
     m_parameters.grandfatheringTime = seconds;
 }
 
+void ResourceLoadStatisticsMemoryStore::setAgeCapForClientSideCookies(Seconds seconds)
+{
+    ASSERT(!RunLoop::isMain());
+    ASSERT(seconds >= 0_s);
+
+    m_parameters.clientSideCookiesAgeCapTime = seconds;
+    updateClientSideCookiesAgeCap();
+}
+
+void ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap()
+{
+    ASSERT(!RunLoop::isMain());
+
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    RunLoop::main().dispatch([store = makeRef(m_store), seconds = m_parameters.clientSideCookiesAgeCapTime] () {
+        if (auto* websiteDataStore = store->websiteDataStore())
+            websiteDataStore->setAgeCapForClientSideCookies(seconds, [] { });
+    });
+#endif
+}
+
 bool ResourceLoadStatisticsMemoryStore::shouldRemoveDataRecords() const
 {
     ASSERT(!RunLoop::isMain());
@@ -1219,4 +1240,12 @@
     });
 }
 
+void ResourceLoadStatisticsMemoryStore::didCreateNetworkProcess()
+{
+    ASSERT(!RunLoop::isMain());
+
+    updateCookiePartitioning([]() { });
+    updateClientSideCookiesAgeCap();
+}
+
 } // namespace WebKit

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h	2018-12-20 00:58:21 UTC (rev 239409)
@@ -127,6 +127,8 @@
 
     void setLastSeen(const String& primaryDomain, Seconds);
 
+    void didCreateNetworkProcess();
+
 private:
     static bool shouldPartitionCookies(const WebCore::ResourceLoadStatistics&);
     static bool shouldBlockCookies(const WebCore::ResourceLoadStatistics&);
@@ -148,6 +150,9 @@
     WebCore::ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
     Vector<String> topPrivatelyControlledDomainsToRemoveWebsiteDataFor();
 
+    void setAgeCapForClientSideCookies(Seconds);
+    void updateClientSideCookiesAgeCap();
+
 #if PLATFORM(COCOA)
     void registerUserDefaultsIfNeeded();
 #endif
@@ -159,6 +164,7 @@
         Seconds timeToLiveCookiePartitionFree { 24_h };
         Seconds minimumTimeBetweenDataRecordsRemoval { 1_h };
         Seconds grandfatheringTime { 24_h * 7 };
+        Seconds clientSideCookiesAgeCapTime { 24_h * 7 };
         bool shouldNotifyPagesWhenDataRecordsWereScanned { false };
         bool shouldClassifyResourcesBeforeDataRecordsRemoval { true };
         bool shouldSubmitTelemetry { true };

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-12-20 00:58:21 UTC (rev 239409)
@@ -325,13 +325,8 @@
     postTask([this] {
         if (!m_memoryStore)
             return;
-        m_memoryStore->updateCookiePartitioning([]() { });
+        m_memoryStore->didCreateNetworkProcess();
     });
-
-#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    if (m_websiteDataStore)
-        m_websiteDataStore->setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies::Yes, []() { });
-#endif
 }
 
 void WebResourceLoadStatisticsStore::removeAllStorageAccess()

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-12-20 00:58:21 UTC (rev 239409)
@@ -142,6 +142,8 @@
 
      void didCreateNetworkProcess();
 
+    WebsiteDataStore* websiteDataStore() { return m_websiteDataStore.get(); }
+
 private:
     explicit WebResourceLoadStatisticsStore(WebsiteDataStore&);
 

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2018-12-20 00:58:21 UTC (rev 239409)
@@ -1244,13 +1244,13 @@
     }
 }
 
-void WebsiteDataStore::setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
+void WebsiteDataStore::setAgeCapForClientSideCookies(std::optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
     for (auto& processPool : processPools()) {
         if (auto* process = processPool->networkProcess())
-            process->setShouldCapLifetimeForClientSideCookies(m_sessionID, shouldCapLifetime, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
+            process->setAgeCapForClientSideCookies(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     }
 }
 

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (239408 => 239409)


--- branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2018-12-20 00:55:10 UTC (rev 239408)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2018-12-20 00:58:21 UTC (rev 239409)
@@ -132,7 +132,7 @@
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&);
-    void setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&);
+    void setAgeCapForClientSideCookies(std::optional<Seconds>, CompletionHandler<void()>&&);
     void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&&);
     void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&);
     void grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to