Only cap lifetime of persistent cookies created client-side through document.cookie...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 21:37:54 +0000 (21:37 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 21:37:54 +0000 (21:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190687
<rdar://problem/45349024>

Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html

NetworkStorageSession::setCookiesFromDOM() now consults the new
m_shouldCapLifetimeForClientSideCookies member variable before
capping the lifetime of cookies.

* loader/ResourceLoadStatistics.cpp:
(WebCore::ResourceLoadStatistics::toString const):
(WebCore::ResourceLoadStatistics::merge):
    Removal of the isMarkedForCookieBlocking member.
* loader/ResourceLoadStatistics.h:
    Removal of the isMarkedForCookieBlocking member.
* platform/network/NetworkStorageSession.h:
* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::setShouldCapLifetimeForClientSideCookies):
(WebCore::NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor):
    No longer takes the boolean clearFirst parameter and now always clears first.
* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::filterCookies):
(WebCore::NetworkStorageSession::setCookiesFromDOM const):

Source/WebKit:

This patch adds the following:
- The WebProcessPool now tells the WebsiteDataStore when a network process has
    been created.
- The WebsiteDataStore in turn tells the WebResourceLoadStatisticsStore when
    a network process has been created.
- The WebResourceLoadStatisticsStore makes sure to update the network processes
    with its cookie policy when it's notified that a network process has been
    created.

In addition, this patch changes the following:
- The ResourceLoadStatisticsMemoryStore no longer keeps track of which domains
    it has told the network process to block cookies for. The reason is that
    we cannot assume that there is only one network process so we should
    always send complete blocking data.
- The ResourceLoadStatisticsMemoryStore's functions for communicating cookie
    blocking state to the network process no longer take and forward the
    "clear first" parameter. This is because complete data is sent every time
    and thus the network process' set is always cleared on an update.
- Removes WebsiteDataStore::networkProcessDidCrash() and
    WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset() since
    the call site---WebProcessPool::ensureNetworkProcess()---now calls
    WebsiteDataStore::didCreateNetworkProcess() after a network process
    crash and the state sync for cookie blocking is triggered.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::NetworkProcess::setShouldCapLifetimeForClientSideCookies):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies):
(WebKit::NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::clear):
(WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking):
(WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains):
(WebKit::ResourceLoadStatisticsMemoryStore::clearBlockingStateForDomains):
(WebKit::ResourceLoadStatisticsMemoryStore::resetCookieBlockingState): Deleted.
* UIProcess/ResourceLoadStatisticsMemoryStore.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::didCreateNetworkProcess):
(WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains):
(WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
(WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
(WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset): Deleted.
* UIProcess/WebResourceLoadStatisticsStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor):
(WebKit::WebsiteDataStore::setShouldCapLifetimeForClientSideCookies):
(WebKit::WebsiteDataStore::didCreateNetworkProcess):
(WebKit::WebsiteDataStore::networkProcessDidCrash): Deleted.
* UIProcess/WebsiteData/WebsiteDataStore.h:

LayoutTests:

The test case now makes use of internals.setResourceLoadStatisticsEnabled()
and was thus moved to http/tests/resourceLoadStatistics/.

* TestExpectations:
    Removed skip of previous test location.
* http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt: Renamed from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt.
* http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html: Renamed from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html.
* http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* http/tests/webAPIStatistics/font-load-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt:
    Removed line containing "isMarkedForCookieBlocking: No."
* platform/ios/TestExpectations:
    Removed pass of previous test location. The whole http/tests/resourceLoadStatistics/ is marked pass for relevant platforms.
* platform/mac-wk2/TestExpectations:
    Removed pass of previous test location. The whole http/tests/resourceLoadStatistics/ is marked pass for relevant platforms.

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

30 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt [moved from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt with 100% similarity]
LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html [moved from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html with 93% similarity]
LayoutTests/http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt
LayoutTests/http/tests/webAPIStatistics/font-load-data-collection-expected.txt
LayoutTests/http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt
LayoutTests/http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadStatistics.cpp
Source/WebCore/loader/ResourceLoadStatistics.h
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp
Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

index 8b7b346..9608469 100644 (file)
@@ -1,3 +1,31 @@
+2018-10-19  John Wilander  <wilander@apple.com>
+
+        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>
+
+        Reviewed by Alex Christensen.
+
+        The test case now makes use of internals.setResourceLoadStatisticsEnabled()
+        and was thus moved to http/tests/resourceLoadStatistics/.
+
+        * TestExpectations:
+            Removed skip of previous test location.
+        * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt: Renamed from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt.
+        * http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html: Renamed from LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html.
+        * http/tests/webAPIStatistics/canvas-read-and-write-data-collection-expected.txt:
+            Removed line containing "isMarkedForCookieBlocking: No."
+        * http/tests/webAPIStatistics/font-load-data-collection-expected.txt:
+            Removed line containing "isMarkedForCookieBlocking: No."
+        * http/tests/webAPIStatistics/navigator-functions-accessed-data-collection-expected.txt:
+            Removed line containing "isMarkedForCookieBlocking: No."
+        * http/tests/webAPIStatistics/screen-functions-accessed-data-collection-expected.txt:
+            Removed line containing "isMarkedForCookieBlocking: No."
+        * platform/ios/TestExpectations:
+            Removed pass of previous test location. The whole http/tests/resourceLoadStatistics/ is marked pass for relevant platforms.
+        * platform/mac-wk2/TestExpectations:
+            Removed pass of previous test location. The whole http/tests/resourceLoadStatistics/ is marked pass for relevant platforms.
+
 2018-10-19  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r237254.
 2018-10-19  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r237254.
index ad461d8..785aef5 100644 (file)
@@ -153,7 +153,6 @@ fast/media/mq-prefers-reduced-motion-live-update.html [ Skip ]
 http/tests/loading/basic-auth-remove-credentials.html [ Skip ]
 http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Skip ]
 http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Skip ]
 http/tests/loading/basic-auth-remove-credentials.html [ Skip ]
 http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Skip ]
 http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Skip ]
-http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Skip ]
 
 # ApplePay is only available on iOS (greater than iOS 10) and macOS (greater than macOS 10.12) and only for WebKit2.
 http/tests/ssl/applepay/ [ Skip ]
 
 # ApplePay is only available on iOS (greater than iOS 10) and macOS (greater than macOS 10.12) and only for WebKit2.
 http/tests/ssl/applepay/ [ Skip ]
@@ -2,13 +2,16 @@
 <html>
 <head>
     <script src="/js-test-resources/js-test.js"></script>
 <html>
 <head>
     <script src="/js-test-resources/js-test.js"></script>
-    <script src="resources/cookie-utilities.js"></script>
+    <script src="/cookies/resources/cookie-utilities.js"></script>
 </head>
 <body>
 <script>
     description("Check that cookies created by JavaScript with max-age or expiry longer than a week get capped to a week.");
     jsTestIsAsync = true;
 
 </head>
 <body>
 <script>
     description("Check that cookies created by JavaScript with max-age or expiry longer than a week get capped to a week.");
     jsTestIsAsync = true;
 
+    if (internals)
+        internals.setResourceLoadStatisticsEnabled(true);
+
     let passedTests = 0;
     function checkThatCookieDoesNotExpireAfter(cookieData, maxAgeInSeconds) {
         let now = new Date();
     let passedTests = 0;
     function checkThatCookieDoesNotExpireAfter(cookieData, maxAgeInSeconds) {
         let now = new Date();
@@ -67,6 +70,9 @@
     } else
         testFailed("No internals object.");
 
     } else
         testFailed("No internals object.");
 
+    if (internals)
+        internals.setResourceLoadStatisticsEnabled(false);
+
     finishJSTest();
 </script>
 </body>
     finishJSTest();
 </script>
 </body>
index a2c2708..7464fd0 100644 (file)
@@ -9,7 +9,6 @@ High level domain: 127.0.0.1
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
-    isMarkedForCookieBlocking: No
     fontsSuccessfullyLoaded:
         Helvetica
         Times
     fontsSuccessfullyLoaded:
         Helvetica
         Times
index 9d136be..11de7ad 100644 (file)
@@ -11,7 +11,6 @@ High level domain: 127.0.0.1
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
-    isMarkedForCookieBlocking: No
     fontsFailedToLoad:
         Fransiscan
         Andale
     fontsFailedToLoad:
         Fransiscan
         Andale
index b565c59..dbc1222 100644 (file)
@@ -9,7 +9,6 @@ High level domain: 127.0.0.1
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
-    isMarkedForCookieBlocking: No
     fontsSuccessfullyLoaded:
         Times
     topFrameRegistrableDomainsWhichAccessedWebAPIs:
     fontsSuccessfullyLoaded:
         Times
     topFrameRegistrableDomainsWhichAccessedWebAPIs:
index e428db5..51d4f49 100644 (file)
@@ -9,7 +9,6 @@ High level domain: 127.0.0.1
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
     isPrevalentResource: No
     isVeryPrevalentResource: No
     dataRecordsRemoved: 0
-    isMarkedForCookieBlocking: No
     fontsSuccessfullyLoaded:
         Times
     topFrameRegistrableDomainsWhichAccessedWebAPIs:
     fontsSuccessfullyLoaded:
         Times
     topFrameRegistrableDomainsWhichAccessedWebAPIs:
index 6e72146..c80a49a 100644 (file)
@@ -2817,7 +2817,6 @@ http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subreso
 http/tests/storageAccess/deny-storage-access-under-opener.html [ Pass ]
 http/tests/storageAccess/deny-storage-access-under-opener-if-auto-dismiss.html [ Pass ]
 http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html [ Pass ]
 http/tests/storageAccess/deny-storage-access-under-opener.html [ Pass ]
 http/tests/storageAccess/deny-storage-access-under-opener-if-auto-dismiss.html [ Pass ]
 http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html [ Pass ]
-http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ]
 
 # Skipped in general expectations since they only work on iOS and Mac, WK2.
 http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
 
 # Skipped in general expectations since they only work on iOS and Mac, WK2.
 http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
index a916309..38e215f 100644 (file)
@@ -772,7 +772,6 @@ webkit.org/b/185994 [ Debug ] fast/text/user-installed-fonts/shadow-postscript-f
 [ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html [ Pass ]
-http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ]
 
 # Skipped in general expectations since they only work on iOS and Mac, WK2.
 http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
 
 # Skipped in general expectations since they only work on iOS and Mac, WK2.
 http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
index ed83d2f..0481867 100644 (file)
@@ -1,3 +1,32 @@
+2018-10-19  John Wilander  <wilander@apple.com>
+
+        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>
+
+        Reviewed by Alex Christensen.
+
+        Test: http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html
+
+        NetworkStorageSession::setCookiesFromDOM() now consults the new
+        m_shouldCapLifetimeForClientSideCookies member variable before
+        capping the lifetime of cookies.
+
+        * loader/ResourceLoadStatistics.cpp:
+        (WebCore::ResourceLoadStatistics::toString const):
+        (WebCore::ResourceLoadStatistics::merge):
+            Removal of the isMarkedForCookieBlocking member.
+        * loader/ResourceLoadStatistics.h:
+            Removal of the isMarkedForCookieBlocking member.
+        * platform/network/NetworkStorageSession.h:
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
+        (WebCore::NetworkStorageSession::setShouldCapLifetimeForClientSideCookies):
+        (WebCore::NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor):
+            No longer takes the boolean clearFirst parameter and now always clears first.
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+        (WebCore::filterCookies):
+        (WebCore::NetworkStorageSession::setCookiesFromDOM const):
+
 2018-10-19  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] RenderReplaced renderer should create InlineBox
 2018-10-19  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] RenderReplaced renderer should create InlineBox
index 27a45a7..c5ad746 100644 (file)
@@ -425,10 +425,6 @@ String ResourceLoadStatistics::toString() const
     builder.appendNumber(dataRecordsRemoved);
     builder.append('\n');
 
     builder.appendNumber(dataRecordsRemoved);
     builder.append('\n');
 
-    // In-memory only
-    appendBoolean(builder, "isMarkedForCookieBlocking", isMarkedForCookieBlocking);
-    builder.append('\n');
-
     appendHashSet(builder, "fontsFailedToLoad", fontsFailedToLoad);
     appendHashSet(builder, "fontsSuccessfullyLoaded", fontsSuccessfullyLoaded);
     appendHashCountedSet(builder, "topFrameRegistrableDomainsWhichAccessedWebAPIs", topFrameRegistrableDomainsWhichAccessedWebAPIs);
     appendHashSet(builder, "fontsFailedToLoad", fontsFailedToLoad);
     appendHashSet(builder, "fontsSuccessfullyLoaded", fontsSuccessfullyLoaded);
     appendHashCountedSet(builder, "topFrameRegistrableDomainsWhichAccessedWebAPIs", topFrameRegistrableDomainsWhichAccessedWebAPIs);
@@ -497,9 +493,6 @@ void ResourceLoadStatistics::merge(const ResourceLoadStatistics& other)
     isVeryPrevalentResource |= other.isVeryPrevalentResource;
     dataRecordsRemoved = std::max(dataRecordsRemoved, other.dataRecordsRemoved);
     
     isVeryPrevalentResource |= other.isVeryPrevalentResource;
     dataRecordsRemoved = std::max(dataRecordsRemoved, other.dataRecordsRemoved);
     
-    // In-memory only
-    isMarkedForCookieBlocking |= other.isMarkedForCookieBlocking;
-
     mergeHashSet(fontsFailedToLoad, other.fontsFailedToLoad);
     mergeHashSet(fontsSuccessfullyLoaded, other.fontsSuccessfullyLoaded);
     mergeHashCountedSet(topFrameRegistrableDomainsWhichAccessedWebAPIs, other.topFrameRegistrableDomainsWhichAccessedWebAPIs);
     mergeHashSet(fontsFailedToLoad, other.fontsFailedToLoad);
     mergeHashSet(fontsSuccessfullyLoaded, other.fontsSuccessfullyLoaded);
     mergeHashCountedSet(topFrameRegistrableDomainsWhichAccessedWebAPIs, other.topFrameRegistrableDomainsWhichAccessedWebAPIs);
index f94d6fd..f2f0962 100644 (file)
@@ -96,9 +96,6 @@ struct ResourceLoadStatistics {
     unsigned timesAccessedAsFirstPartyDueToUserInteraction { 0 };
     unsigned timesAccessedAsFirstPartyDueToStorageAccessAPI { 0 };
 
     unsigned timesAccessedAsFirstPartyDueToUserInteraction { 0 };
     unsigned timesAccessedAsFirstPartyDueToStorageAccessAPI { 0 };
 
-    // In-memory only
-    bool isMarkedForCookieBlocking { false };
-    
     // This set represents the registrable domain of the top frame where web API
     // were used in the top frame or one of its subframes.
     HashCountedSet<String> topFrameRegistrableDomainsWhichAccessedWebAPIs;
     // This set represents the registrable domain of the top frame where web API
     // were used in the top frame or one of its subframes.
     HashCountedSet<String> topFrameRegistrableDomainsWhichAccessedWebAPIs;
index 253b6a2..aa9e428 100644 (file)
@@ -102,7 +102,8 @@ public:
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
     WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
     WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const;
-    WEBCORE_EXPORT void setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, bool clearFirst);
+    WEBCORE_EXPORT void setPrevalentDomainsToBlockCookiesFor(const Vector<String>&);
+    WEBCORE_EXPORT void setShouldCapLifetimeForClientSideCookies(bool value);
     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;
     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;
@@ -191,6 +192,7 @@ private:
     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;
     std::optional<Seconds> m_cacheMaxAgeCapForPrevalentResources { };
     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;
     std::optional<Seconds> m_cacheMaxAgeCapForPrevalentResources { };
+    bool m_shouldCapLifetimeForClientSideCookies { false };
 #endif
 
 #if PLATFORM(COCOA)
 #endif
 
 #if PLATFORM(COCOA)
index fa04c8b..ffd6a61 100644 (file)
@@ -273,13 +273,14 @@ std::optional<Seconds> NetworkStorageSession::maxAgeCacheCap(const ResourceReque
     return std::nullopt;
 }
 
     return std::nullopt;
 }
 
-void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domains, bool clearFirst)
+void NetworkStorageSession::setShouldCapLifetimeForClientSideCookies(bool value)
 {
 {
-    if (clearFirst) {
-        m_topPrivatelyControlledDomainsToBlock.clear();
-        m_framesGrantedStorageAccess.clear();
-    }
+    m_shouldCapLifetimeForClientSideCookies = value;
+}
 
 
+void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domains)
+{
+    m_topPrivatelyControlledDomainsToBlock.clear();
     m_topPrivatelyControlledDomainsToBlock.add(domains.begin(), domains.end());
 }
 
     m_topPrivatelyControlledDomainsToBlock.add(domains.begin(), domains.end());
 }
 
index d1c47bf..a9f2585 100644 (file)
@@ -260,7 +260,7 @@ static NSArray *httpCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSURL *f
     return cookiesForURL(nsCookieStorage.get(), url, firstParty, sameSiteInfo);
 }
 
     return cookiesForURL(nsCookieStorage.get(), url, firstParty, sameSiteInfo);
 }
 
-static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies)
+static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies, bool shouldCapLifetime)
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
     NSUInteger count = [unfilteredCookies count];
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
     NSUInteger count = [unfilteredCookies count];
@@ -281,7 +281,7 @@ static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies)
             continue;
 
         // Cap lifetime of persistent, client-side cookies to a week.
             continue;
 
         // Cap lifetime of persistent, client-side cookies to a week.
-        if (![cookie isSessionOnly]) {
+        if (shouldCapLifetime && ![cookie isSessionOnly]) {
             if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > secondsPerWeek) {
                 RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> properties = adoptNS([[cookie properties] mutableCopy]);
                 RetainPtr<NSDate> dateInAWeek = adoptNS([[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerWeek]);
             if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > secondsPerWeek) {
                 RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> properties = adoptNS([[cookie properties] mutableCopy]);
                 RetainPtr<NSDate> dateInAWeek = adoptNS([[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerWeek]);
@@ -404,7 +404,11 @@ void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameS
     NSArray *unfilteredCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:cookieURL];
 #endif
 
     NSArray *unfilteredCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:cookieURL];
 #endif
 
-    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies);
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, m_shouldCapLifetimeForClientSideCookies);
+#else
+    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);
+#endif
     ASSERT([filteredCookies.get() count] <= 1);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     ASSERT([filteredCookies.get() count] <= 1);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
index 033e4bc..c5fb710 100644 (file)
@@ -1,3 +1,69 @@
+2018-10-19  John Wilander  <wilander@apple.com>
+
+        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>
+
+        Reviewed by Alex Christensen.
+
+        This patch adds the following:
+        - The WebProcessPool now tells the WebsiteDataStore when a network process has
+            been created.
+        - The WebsiteDataStore in turn tells the WebResourceLoadStatisticsStore when
+            a network process has been created.
+        - The WebResourceLoadStatisticsStore makes sure to update the network processes
+            with its cookie policy when it's notified that a network process has been
+            created.
+
+        In addition, this patch changes the following:
+        - The ResourceLoadStatisticsMemoryStore no longer keeps track of which domains
+            it has told the network process to block cookies for. The reason is that
+            we cannot assume that there is only one network process so we should
+            always send complete blocking data.
+        - The ResourceLoadStatisticsMemoryStore's functions for communicating cookie
+            blocking state to the network process no longer take and forward the
+            "clear first" parameter. This is because complete data is sent every time
+            and thus the network process' set is always cleared on an update.
+        - Removes WebsiteDataStore::networkProcessDidCrash() and
+            WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset() since
+            the call site---WebProcessPool::ensureNetworkProcess()---now calls
+            WebsiteDataStore::didCreateNetworkProcess() after a network process
+            crash and the state sync for cookie blocking is triggered.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::updatePrevalentDomainsToBlockCookiesFor):
+        (WebKit::NetworkProcess::setShouldCapLifetimeForClientSideCookies):
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor):
+        (WebKit::NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies):
+        (WebKit::NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+        * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::clear):
+        (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking):
+        (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains):
+        (WebKit::ResourceLoadStatisticsMemoryStore::clearBlockingStateForDomains):
+        (WebKit::ResourceLoadStatisticsMemoryStore::resetCookieBlockingState): Deleted.
+        * UIProcess/ResourceLoadStatisticsMemoryStore.h:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::ensureNetworkProcess):
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::didCreateNetworkProcess):
+        (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains):
+        (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
+        (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
+        (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset): Deleted.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor):
+        (WebKit::WebsiteDataStore::setShouldCapLifetimeForClientSideCookies):
+        (WebKit::WebsiteDataStore::didCreateNetworkProcess):
+        (WebKit::WebsiteDataStore::networkProcessDidCrash): Deleted.
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+
 2018-10-19  Alex Christensen  <achristensen@webkit.org>
 
         Rebase python tests.
 2018-10-19  Alex Christensen  <achristensen@webkit.org>
 
         Rebase python tests.
index d3fa714..859b3f7 100644 (file)
@@ -500,13 +500,20 @@ void NetworkProcess::writeBlobToFilePath(const WebCore::URL& url, const String&
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, bool shouldClearFirst, uint64_t contextId)
+void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, uint64_t contextId)
 {
     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
 {
     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
-        networkStorageSession->setPrevalentDomainsToBlockCookiesFor(domainsToBlock, shouldClearFirst);
+        networkStorageSession->setPrevalentDomainsToBlockCookiesFor(domainsToBlock);
     parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateBlockCookies(contextId), 0);
 }
 
     parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateBlockCookies(contextId), 0);
 }
 
+void NetworkProcess::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId)
+{
+    if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
+        networkStorageSession->setShouldCapLifetimeForClientSideCookies(value);
+    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetShouldCapLifetimeForClientSideCookies(contextId), 0);
+}
+
 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
 {
     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
 {
     if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
@@ -568,7 +575,7 @@ void NetworkProcess::resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID ses
         ASSERT_NOT_REACHED();
     parentProcessConnection()->send(Messages::NetworkProcessProxy::DidResetCacheMaxAgeCapForPrevalentResources(contextId), 0);
 }
         ASSERT_NOT_REACHED();
     parentProcessConnection()->send(Messages::NetworkProcessProxy::DidResetCacheMaxAgeCapForPrevalentResources(contextId), 0);
 }
-#endif
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
 bool NetworkProcess::sessionIsControlledByAutomation(PAL::SessionID sessionID) const
 {
 
 bool NetworkProcess::sessionIsControlledByAutomation(PAL::SessionID sessionID) const
 {
index ec8e57a..3a28d5c 100644 (file)
@@ -157,7 +157,8 @@ public:
     void addWebsiteDataStore(WebsiteDataStoreParameters&&);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void addWebsiteDataStore(WebsiteDataStoreParameters&&);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, bool shouldClearFirst, uint64_t contextId);
+    void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, uint64_t contextId);
+    void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, bool value, 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);
     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);
index 27b1e9d..2c797e0 100644 (file)
@@ -78,7 +78,8 @@ messages -> NetworkProcess LegacyReceiver {
     PreconnectTo(WebCore::URL url, enum:bool WebCore::StoredCredentialsPolicy storedCredentialsPolicy);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     PreconnectTo(WebCore::URL url, enum:bool WebCore::StoredCredentialsPolicy storedCredentialsPolicy);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<String> domainsToBlock, bool shouldClearFirst, uint64_t contextId)
+    UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<String> domainsToBlock, uint64_t contextId)
+    SetShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, 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)
     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)
index f14a2fb..3780f22 100644 (file)
@@ -395,7 +395,7 @@ void NetworkProcessProxy::logDiagnosticMessageWithValue(uint64_t pageID, const S
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
 {
     if (!canSendMessage()) {
         completionHandler();
 {
     if (!canSendMessage()) {
         completionHandler();
@@ -407,7 +407,7 @@ void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID
         completionHandler();
     });
     ASSERT_UNUSED(addResult, addResult.isNewEntry);
         completionHandler();
     });
     ASSERT_UNUSED(addResult, addResult.isNewEntry);
-    send(Messages::NetworkProcess::UpdatePrevalentDomainsToBlockCookiesFor(sessionID, domainsToBlock, shouldClearFirst == ShouldClearFirst::Yes, callbackId), 0);
+    send(Messages::NetworkProcess::UpdatePrevalentDomainsToBlockCookiesFor(sessionID, domainsToBlock, callbackId), 0);
 }
 
 void NetworkProcessProxy::didUpdateBlockCookies(uint64_t callbackId)
 }
 
 void NetworkProcessProxy::didUpdateBlockCookies(uint64_t callbackId)
@@ -415,6 +415,26 @@ void NetworkProcessProxy::didUpdateBlockCookies(uint64_t callbackId)
     m_updateBlockCookiesCallbackMap.take(callbackId)();
 }
 
     m_updateBlockCookiesCallbackMap.take(callbackId)();
 }
 
+void NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler)
+{
+    if (!canSendMessage()) {
+        completionHandler();
+        return;
+    }
+    
+    auto callbackId = generateCallbackID();
+    auto addResult = m_updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {
+        completionHandler();
+    });
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
+    send(Messages::NetworkProcess::SetShouldCapLifetimeForClientSideCookies(sessionID, shouldCapLifetime == ShouldCapLifetimeForClientSideCookies::Yes, callbackId), 0);
+}
+
+void NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
+{
+    m_updateBlockCookiesCallbackMap.take(callbackId)();
+}
+
 void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback)
 {
     auto contextId = generateCallbackID();
 void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback)
 {
     auto contextId = generateCallbackID();
@@ -507,7 +527,7 @@ void NetworkProcessProxy::didResetCacheMaxAgeCapForPrevalentResources(uint64_t c
     auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId);
     completionHandler();
 }
     auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId);
     completionHandler();
 }
-#endif
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
 void NetworkProcessProxy::sendProcessWillSuspendImminently()
 {
 
 void NetworkProcessProxy::sendProcessWillSuspendImminently()
 {
index 4f684be..dc9add1 100644 (file)
@@ -78,7 +78,8 @@ public:
     void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&&);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&&);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+    void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
+    void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, ShouldCapLifetimeForClientSideCookies, 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);
     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);
@@ -144,6 +145,7 @@ private:
     void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void didUpdateBlockCookies(uint64_t contextId);
     void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void didUpdateBlockCookies(uint64_t contextId);
+    void didSetShouldCapLifetimeForClientSideCookies(uint64_t contextId);
     void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
     void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
     void didRemoveAllStorageAccess(uint64_t contextId);
     void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
     void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
     void didRemoveAllStorageAccess(uint64_t contextId);
index 3d6c1a2..05d442f 100644 (file)
@@ -43,6 +43,7 @@ messages -> NetworkProcessProxy LegacyReceiver {
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     DidUpdateBlockCookies(uint64_t callbackId)
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     DidUpdateBlockCookies(uint64_t callbackId)
+    DidSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId)
     StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
     AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
     DidRemoveAllStorageAccess(uint64_t contextId)
     StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
     AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
     DidRemoveAllStorageAccess(uint64_t contextId)
index 7d17afe..7c9796c 100644 (file)
@@ -952,7 +952,7 @@ void ResourceLoadStatisticsMemoryStore::clear(CompletionHandler<void()>&& comple
     removeAllStorageAccess([callbackAggregator = callbackAggregator.copyRef()] { });
 
     auto primaryDomainsToBlock = ensurePrevalentResourcesForDebugMode();
     removeAllStorageAccess([callbackAggregator = callbackAggregator.copyRef()] { });
 
     auto primaryDomainsToBlock = ensurePrevalentResourcesForDebugMode();
-    updateCookieBlockingForDomains(primaryDomainsToBlock, ShouldClearFirst::Yes, [callbackAggregator = callbackAggregator.copyRef()] { });
+    updateCookieBlockingForDomains(primaryDomainsToBlock, [callbackAggregator = callbackAggregator.copyRef()] { });
 }
 
 bool ResourceLoadStatisticsMemoryStore::wasAccessedAsFirstPartyDueToUserInteraction(const ResourceLoadStatistics& current, const ResourceLoadStatistics& updated) const
 }
 
 bool ResourceLoadStatisticsMemoryStore::wasAccessedAsFirstPartyDueToUserInteraction(const ResourceLoadStatistics& current, const ResourceLoadStatistics& updated) const
@@ -1035,10 +1035,8 @@ void ResourceLoadStatisticsMemoryStore::updateCookieBlocking(CompletionHandler<v
 
     Vector<String> domainsToBlock;
     for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
 
     Vector<String> domainsToBlock;
     for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
-        if (resourceStatistic.isPrevalentResource && !resourceStatistic.isMarkedForCookieBlocking) {
+        if (resourceStatistic.isPrevalentResource)
             domainsToBlock.append(resourceStatistic.highLevelDomain);
             domainsToBlock.append(resourceStatistic.highLevelDomain);
-            resourceStatistic.isMarkedForCookieBlocking = true;
-        }
     }
 
     if (domainsToBlock.isEmpty()) {
     }
 
     if (domainsToBlock.isEmpty()) {
@@ -1050,7 +1048,7 @@ void ResourceLoadStatisticsMemoryStore::updateCookieBlocking(CompletionHandler<v
             debugLogDomainsInBatches("block", domainsToBlock);
 
     RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), store = makeRef(m_store), domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
             debugLogDomainsInBatches("block", domainsToBlock);
 
     RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), store = makeRef(m_store), domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
-        store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, ShouldClearFirst::No, [weakThis = WTFMove(weakThis), store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
+        store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, [weakThis = WTFMove(weakThis), store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
             store->statisticsQueue().dispatch([weakThis = WTFMove(weakThis), completionHandler = WTFMove(completionHandler)]() mutable {
                 completionHandler();
                 if (!weakThis)
             store->statisticsQueue().dispatch([weakThis = WTFMove(weakThis), completionHandler = WTFMove(completionHandler)]() mutable {
                 completionHandler();
                 if (!weakThis)
@@ -1063,23 +1061,12 @@ void ResourceLoadStatisticsMemoryStore::updateCookieBlocking(CompletionHandler<v
     });
 }
 
     });
 }
 
-void ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(!RunLoop::isMain());
 
 {
     ASSERT(!RunLoop::isMain());
 
-    if (domainsToBlock.isEmpty() && shouldClearFirst == ShouldClearFirst::No) {
-        completionHandler();
-        return;
-    }
-
-    if (shouldClearFirst == ShouldClearFirst::Yes)
-        resetCookieBlockingState();
-
-    for (auto& domain : domainsToBlock)
-        ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookieBlocking = true;
-
-    RunLoop::main().dispatch([store = makeRef(m_store), shouldClearFirst, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
-        store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, shouldClearFirst, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
+    RunLoop::main().dispatch([store = makeRef(m_store), domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
+        store->callUpdatePrevalentDomainsToBlockCookiesForHandler(domainsToBlock, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)]() mutable {
             store->statisticsQueue().dispatch([completionHandler = WTFMove(completionHandler)]() mutable {
                 completionHandler();
             });
             store->statisticsQueue().dispatch([completionHandler = WTFMove(completionHandler)]() mutable {
                 completionHandler();
             });
@@ -1100,22 +1087,9 @@ void ResourceLoadStatisticsMemoryStore::clearBlockingStateForDomains(const Vecto
         store->callRemoveDomainsHandler(domains);
     });
 
         store->callRemoveDomainsHandler(domains);
     });
 
-    for (auto& domain : domains) {
-        auto& statistic = ensureResourceStatisticsForPrimaryDomain(domain);
-        statistic.isMarkedForCookieBlocking = false;
-    }
-
     completionHandler();
 }
 
     completionHandler();
 }
 
-void ResourceLoadStatisticsMemoryStore::resetCookieBlockingState()
-{
-    ASSERT(!RunLoop::isMain());
-
-    for (auto& resourceStatistic : m_resourceStatisticsMap.values())
-        resourceStatistic.isMarkedForCookieBlocking = false;
-}
-
 void ResourceLoadStatisticsMemoryStore::processStatistics(const Function<void(const ResourceLoadStatistics&)>& processFunction) const
 {
     ASSERT(!RunLoop::isMain());
 void ResourceLoadStatisticsMemoryStore::processStatistics(const Function<void(const ResourceLoadStatistics&)>& processFunction) const
 {
     ASSERT(!RunLoop::isMain());
index e5495ab..365ec0e 100644 (file)
@@ -64,9 +64,8 @@ public:
     void mergeStatistics(Vector<WebCore::ResourceLoadStatistics>&&);
     void processStatistics(const Function<void(const WebCore::ResourceLoadStatistics&)>&) const;
 
     void mergeStatistics(Vector<WebCore::ResourceLoadStatistics>&&);
     void processStatistics(const Function<void(const WebCore::ResourceLoadStatistics&)>&) const;
 
-    void resetCookieBlockingState();
     void updateCookieBlocking(CompletionHandler<void()>&&);
     void updateCookieBlocking(CompletionHandler<void()>&&);
-    void updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+    void updateCookieBlockingForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
     void clearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
 
     void includeTodayAsOperatingDateIfNecessary();
     void clearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
 
     void includeTodayAsOperatingDateIfNecessary();
index 731ef4b..9c8487e 100644 (file)
@@ -560,8 +560,6 @@ NetworkProcessProxy& WebProcessPool::ensureNetworkProcess(WebsiteDataStore* with
     if (m_didNetworkProcessCrash) {
         m_didNetworkProcessCrash = false;
         reinstateNetworkProcessAssertionState(*m_networkProcess);
     if (m_didNetworkProcessCrash) {
         m_didNetworkProcessCrash = false;
         reinstateNetworkProcessAssertionState(*m_networkProcess);
-        if (m_websiteDataStore)
-            m_websiteDataStore->websiteDataStore().networkProcessDidCrash();
     }
 
     if (withWebsiteDataStore) {
     }
 
     if (withWebsiteDataStore) {
@@ -569,6 +567,9 @@ NetworkProcessProxy& WebProcessPool::ensureNetworkProcess(WebsiteDataStore* with
         withWebsiteDataStore->clearPendingCookies();
     }
 
         withWebsiteDataStore->clearPendingCookies();
     }
 
+    if (m_websiteDataStore)
+        m_websiteDataStore->websiteDataStore().didCreateNetworkProcess();
+
     return *m_networkProcess;
 }
 
     return *m_networkProcess;
 }
 
index d581486..70e0b99 100644 (file)
@@ -38,6 +38,7 @@
 #include "WebsiteDataFetchOption.h"
 #include "WebsiteDataStore.h"
 #include <WebCore/ResourceLoadStatistics.h>
 #include "WebsiteDataFetchOption.h"
 #include "WebsiteDataStore.h"
 #include <WebCore/ResourceLoadStatistics.h>
+#include <wtf/CallbackAggregator.h>
 #include <wtf/CrossThreadCopier.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/threads/BinarySemaphore.h>
 #include <wtf/CrossThreadCopier.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/threads/BinarySemaphore.h>
@@ -321,6 +322,22 @@ void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const String&
     callback(false);
 }
 
     callback(false);
 }
 
+void WebResourceLoadStatisticsStore::didCreateNetworkProcess()
+{
+    ASSERT(RunLoop::isMain());
+
+    postTask([this] {
+        if (!m_memoryStore)
+            return;
+        m_memoryStore->updateCookieBlocking([]() { });
+    });
+
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    if (m_websiteDataStore)
+        m_websiteDataStore->setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies::Yes, []() { });
+#endif
+}
+
 void WebResourceLoadStatisticsStore::removeAllStorageAccess(CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 void WebResourceLoadStatisticsStore::removeAllStorageAccess(CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
@@ -716,17 +733,17 @@ void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdate(CompletionHand
     });
 }
 
     });
 }
 
-void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
 {
     // Helper function used by testing system. Should only be called from the main thread.
     ASSERT(RunLoop::isMain());
 {
     // Helper function used by testing system. Should only be called from the main thread.
     ASSERT(RunLoop::isMain());
-    postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), shouldClearFirst, completionHandler = WTFMove(completionHandler)] () mutable {
+    postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
         if (!m_memoryStore) {
             postTaskReply(WTFMove(completionHandler));
             return;
         }
 
         if (!m_memoryStore) {
             postTaskReply(WTFMove(completionHandler));
             return;
         }
 
-        m_memoryStore->updateCookieBlockingForDomains(domainsToBlock, shouldClearFirst, [completionHandler = WTFMove(completionHandler)]() mutable {
+        m_memoryStore->updateCookieBlockingForDomains(domainsToBlock, [completionHandler = WTFMove(completionHandler)]() mutable {
             postTaskReply(WTFMove(completionHandler));
         });
     });
             postTaskReply(WTFMove(completionHandler));
         });
     });
@@ -748,17 +765,6 @@ void WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains(const
     });
 }
 
     });
 }
 
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-void WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset()
-{
-    ASSERT(RunLoop::isMain());
-    postTask([this] {
-        if (m_memoryStore)
-            m_memoryStore->resetCookieBlockingState();
-    });
-}
-#endif
-
 void WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 void WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
@@ -836,13 +842,13 @@ void WebResourceLoadStatisticsStore::setCacheMaxAgeCap(Seconds seconds, Completi
     completionHandler();
 }
 
     completionHandler();
 }
 
-void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     if (m_websiteDataStore) {
 {
     ASSERT(RunLoop::isMain());
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     if (m_websiteDataStore) {
-        m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, shouldClearFirst, WTFMove(completionHandler));
+        m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, WTFMove(completionHandler));
         return;
     }
 #endif
         return;
     }
 #endif
index 6c410fa..75811b3 100644 (file)
@@ -53,7 +53,6 @@ class WebFrameProxy;
 class WebProcessProxy;
 class WebsiteDataStore;
 
 class WebProcessProxy;
 class WebsiteDataStore;
 
-enum class ShouldClearFirst;
 enum class StorageAccessStatus {
     CannotRequestAccess,
     RequiresUserPrompt,
 enum class StorageAccessStatus {
     CannotRequestAccess,
     RequiresUserPrompt,
@@ -107,14 +106,11 @@ public:
     void setTopFrameUniqueRedirectTo(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedTo);
     void setTopFrameUniqueRedirectFrom(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedFrom);
     void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
     void setTopFrameUniqueRedirectTo(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedTo);
     void setTopFrameUniqueRedirectFrom(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedFrom);
     void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
-    void scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+    void scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
     void scheduleClearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
     void scheduleStatisticsAndDataRecordsProcessing();
     void submitTelemetry();
     void scheduleClearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
     void scheduleStatisticsAndDataRecordsProcessing();
     void submitTelemetry();
-    void scheduleCookieBlockingStateReset();
 
 
-    void scheduleClearInMemory(CompletionHandler<void()>&&);
-    
     enum class ShouldGrandfather {
         No,
         Yes,
     enum class ShouldGrandfather {
         No,
         Yes,
@@ -138,10 +134,12 @@ public:
     void logTestingEvent(const String&);
     void callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
     void removeAllStorageAccess(CompletionHandler<void()>&&);
     void logTestingEvent(const String&);
     void callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
     void removeAllStorageAccess(CompletionHandler<void()>&&);
-    void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+    void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
     void callRemoveDomainsHandler(const Vector<String>& domains);
     void callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
 
     void callRemoveDomainsHandler(const Vector<String>& domains);
     void callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
 
+    void didCreateNetworkProcess();
+
 private:
     explicit WebResourceLoadStatisticsStore(WebsiteDataStore&);
 
 private:
     explicit WebResourceLoadStatisticsStore(WebsiteDataStore&);
 
@@ -171,6 +169,8 @@ private:
     bool m_hasScheduledProcessStats { false };
 
     WTF::Function<void(const String&)> m_statisticsTestingCallback;
     bool m_hasScheduledProcessStats { false };
 
     WTF::Function<void(const String&)> m_statisticsTestingCallback;
+
+    bool m_firstNetworkProcessCreated { false };
 };
 
 } // namespace WebKit
 };
 
 } // namespace WebKit
index f40746c..1a255b8 100644 (file)
@@ -1256,13 +1256,23 @@ void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<Webs
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
+void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
     for (auto& processPool : processPools()) {
         if (auto* process = processPool->networkProcess())
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
     for (auto& processPool : processPools()) {
         if (auto* process = processPool->networkProcess())
-            process->updatePrevalentDomainsToBlockCookiesFor(m_sessionID, domainsToBlock, shouldClearFirst, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
+            process->updatePrevalentDomainsToBlockCookiesFor(m_sessionID, domainsToBlock, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
+    }
+}
+
+void WebsiteDataStore::setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies shouldCapLifetime, 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()] { });
     }
 }
 
     }
 }
 
@@ -1347,7 +1357,7 @@ void WebsiteDataStore::grantStorageAccess(String&& subFrameHost, String&& topFra
     
     m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
 }
     
     m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
 }
-#endif
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
 void WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds, CompletionHandler<void()>&& completionHandler)
 {
 
 void WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds, CompletionHandler<void()>&& completionHandler)
 {
@@ -1378,14 +1388,6 @@ void WebsiteDataStore::resetCacheMaxAgeCapForPrevalentResources(CompletionHandle
 #endif
 }
 
 #endif
 }
 
-void WebsiteDataStore::networkProcessDidCrash()
-{
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-    if (m_resourceLoadStatistics)
-        m_resourceLoadStatistics->scheduleCookieBlockingStateReset();
-#endif
-}
-
 void WebsiteDataStore::webPageWasAdded(WebPageProxy& webPageProxy)
 {
     if (m_storageManager)
 void WebsiteDataStore::webPageWasAdded(WebPageProxy& webPageProxy)
 {
     if (m_storageManager)
@@ -1687,4 +1689,10 @@ void WebsiteDataStore::setMockWebAuthenticationConfiguration(MockWebAuthenticati
 }
 #endif
 
 }
 #endif
 
+void WebsiteDataStore::didCreateNetworkProcess()
+{
+    if (m_resourceLoadStatistics)
+        m_resourceLoadStatistics->didCreateNetworkProcess();
+}
+
 }
 }
index 9163d98..bd57913 100644 (file)
@@ -74,7 +74,7 @@ enum class StorageAccessPromptStatus;
 struct PluginModuleInfo;
 #endif
 
 struct PluginModuleInfo;
 #endif
 
-enum class ShouldClearFirst { No, Yes };
+enum class ShouldCapLifetimeForClientSideCookies { No, Yes };
 
 class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore>, public CanMakeWeakPtr<WebsiteDataStore>  {
 public:
 
 class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore>, public CanMakeWeakPtr<WebsiteDataStore>  {
 public:
@@ -137,7 +137,8 @@ public:
     void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler);
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, ShouldClearFirst, CompletionHandler<void()>&&);
+    void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
+    void setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies, 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)>&&);
     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)>&&);
@@ -149,7 +150,6 @@ public:
 #endif
     void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&);
     void resetCacheMaxAgeCapForPrevalentResources(CompletionHandler<void()>&&);
 #endif
     void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&);
     void resetCacheMaxAgeCapForPrevalentResources(CompletionHandler<void()>&&);
-    void networkProcessDidCrash();
     void resolveDirectoriesIfNecessary();
     const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration.applicationCacheDirectory; }
     const String& resolvedMediaCacheDirectory() const { return m_resolvedConfiguration.mediaCacheDirectory; }
     void resolveDirectoriesIfNecessary();
     const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration.applicationCacheDirectory; }
     const String& resolvedMediaCacheDirectory() const { return m_resolvedConfiguration.mediaCacheDirectory; }
@@ -199,6 +199,8 @@ public:
     void setMockWebAuthenticationConfiguration(MockWebAuthenticationConfiguration&&);
 #endif
 
     void setMockWebAuthenticationConfiguration(MockWebAuthenticationConfiguration&&);
 #endif
 
+    void didCreateNetworkProcess();
+
 private:
     explicit WebsiteDataStore(PAL::SessionID);
     explicit WebsiteDataStore(Configuration, PAL::SessionID);
 private:
     explicit WebsiteDataStore(PAL::SessionID);
     explicit WebsiteDataStore(Configuration, PAL::SessionID);