<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[281886] trunk/Source/WebKit</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/281886">281886</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-09-01 16:26:50 -0700 (Wed, 01 Sep 2021)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move PCM::Store ownership from WebResourceLoadStatisticsStore to PrivateClickMeasurementManager
https://bugs.webkit.org/show_bug.cgi?id=229770
Patch by Alex Christensen <achristensen@webkit.org> on 2021-09-01
Reviewed by Kate Cheney.
Now that PrivateClickMeasurement storage is separate from ResourceLoadStatistics storage, they don't need to know about each other.
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::migrateDataToPCMDatabaseIfNecessary):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
(WebKit::WebResourceLoadStatisticsStore::create):
(WebKit::WebResourceLoadStatisticsStore::didDestroyNetworkSession):
(WebKit::pcmStoreDirectory): Deleted.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkSession.cpp:
(WebKit::pcmStoreDirectory):
(WebKit::NetworkSession::NetworkSession):
(WebKit::NetworkSession::~NetworkSession):
(WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
(WebKit::NetworkSession::recreateResourceLoadStatisticStore):
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:
(WebKit::PCM::Database::privateClickMeasurementToStringForTesting const):
(WebKit::PCM::Database::attributionToStringForTesting const):
(WebKit::PCM::Database::privateClickMeasurementToStringForTesting): Deleted.
(WebKit::PCM::Database::attributionToStringForTesting): Deleted.
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h:
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp:
(WebKit::PCM::Store::postTask const):
(WebKit::PCM::Store::postTaskReply const):
(WebKit::PCM::Store::privateClickMeasurementToStringForTesting const):
(WebKit::PCM::Store::postTask): Deleted.
(WebKit::PCM::Store::postTaskReply): Deleted.
(WebKit::PCM::Store::privateClickMeasurementToStringForTesting): Deleted.
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h:
* NetworkProcess/PrivateClickMeasurementManager.cpp:
(WebKit::PrivateClickMeasurementManager::PrivateClickMeasurementManager):
(WebKit::PrivateClickMeasurementManager::insertPrivateClickMeasurement):
(WebKit::PrivateClickMeasurementManager::attribute):
(WebKit::PrivateClickMeasurementManager::clearSentAttribution):
(WebKit::PrivateClickMeasurementManager::firePendingAttributionRequests):
(WebKit::PrivateClickMeasurementManager::clear):
(WebKit::PrivateClickMeasurementManager::clearForRegistrableDomain):
(WebKit::PrivateClickMeasurementManager::clearExpired):
(WebKit::PrivateClickMeasurementManager::toStringForTesting const):
(WebKit::PrivateClickMeasurementManager::markAllUnattributedAsExpiredForTesting):
(WebKit::PrivateClickMeasurementManager::markAttributedPrivateClickMeasurementsAsExpiredForTesting):
* NetworkProcess/PrivateClickMeasurementManager.h:
(WebKit::PrivateClickMeasurementManager::store):
(WebKit::PrivateClickMeasurementManager::store const):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessClassifierResourceLoadStatisticsDatabaseStorecpp">trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessClassifierResourceLoadStatisticsDatabaseStoreh">trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStorecpp">trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStoreh">trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkProcesscpp">trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSessioncpp">trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSessionh">trunk/Source/WebKit/NetworkProcess/NetworkSession.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementDatabasecpp">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementDatabaseh">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementStorecpp">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementStoreh">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementManagercpp">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementManagerh">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/ChangeLog 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -1,5 +1,58 @@
</span><span class="cx"> 2021-09-01 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><ins>+ Move PCM::Store ownership from WebResourceLoadStatisticsStore to PrivateClickMeasurementManager
+ https://bugs.webkit.org/show_bug.cgi?id=229770
+
+ Reviewed by Kate Cheney.
+
+ Now that PrivateClickMeasurement storage is separate from ResourceLoadStatistics storage, they don't need to know about each other.
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+ (WebKit::ResourceLoadStatisticsDatabaseStore::migrateDataToPCMDatabaseIfNecessary):
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+ (WebKit::WebResourceLoadStatisticsStore::create):
+ (WebKit::WebResourceLoadStatisticsStore::didDestroyNetworkSession):
+ (WebKit::pcmStoreDirectory): Deleted.
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+ * NetworkProcess/NetworkSession.cpp:
+ (WebKit::pcmStoreDirectory):
+ (WebKit::NetworkSession::NetworkSession):
+ (WebKit::NetworkSession::~NetworkSession):
+ (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
+ (WebKit::NetworkSession::recreateResourceLoadStatisticStore):
+ * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:
+ (WebKit::PCM::Database::privateClickMeasurementToStringForTesting const):
+ (WebKit::PCM::Database::attributionToStringForTesting const):
+ (WebKit::PCM::Database::privateClickMeasurementToStringForTesting): Deleted.
+ (WebKit::PCM::Database::attributionToStringForTesting): Deleted.
+ * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h:
+ * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp:
+ (WebKit::PCM::Store::postTask const):
+ (WebKit::PCM::Store::postTaskReply const):
+ (WebKit::PCM::Store::privateClickMeasurementToStringForTesting const):
+ (WebKit::PCM::Store::postTask): Deleted.
+ (WebKit::PCM::Store::postTaskReply): Deleted.
+ (WebKit::PCM::Store::privateClickMeasurementToStringForTesting): Deleted.
+ * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h:
+ * NetworkProcess/PrivateClickMeasurementManager.cpp:
+ (WebKit::PrivateClickMeasurementManager::PrivateClickMeasurementManager):
+ (WebKit::PrivateClickMeasurementManager::insertPrivateClickMeasurement):
+ (WebKit::PrivateClickMeasurementManager::attribute):
+ (WebKit::PrivateClickMeasurementManager::clearSentAttribution):
+ (WebKit::PrivateClickMeasurementManager::firePendingAttributionRequests):
+ (WebKit::PrivateClickMeasurementManager::clear):
+ (WebKit::PrivateClickMeasurementManager::clearForRegistrableDomain):
+ (WebKit::PrivateClickMeasurementManager::clearExpired):
+ (WebKit::PrivateClickMeasurementManager::toStringForTesting const):
+ (WebKit::PrivateClickMeasurementManager::markAllUnattributedAsExpiredForTesting):
+ (WebKit::PrivateClickMeasurementManager::markAttributedPrivateClickMeasurementsAsExpiredForTesting):
+ * NetworkProcess/PrivateClickMeasurementManager.h:
+ (WebKit::PrivateClickMeasurementManager::store):
+ (WebKit::PrivateClickMeasurementManager::store const):
+
+2021-09-01 Alex Christensen <achristensen@webkit.org>
+
</ins><span class="cx"> Remove _statisticsDatabaseColumnsForTable and related unused test functions
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=229771
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessClassifierResourceLoadStatisticsDatabaseStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -552,7 +552,11 @@
</span><span class="cx">
</span><span class="cx"> if (!unattributed.isEmpty() || !attributed.isEmpty()) {
</span><span class="cx"> RunLoop::main().dispatch([store = makeRef(store()), unattributed = unattributed.isolatedCopy(), attributed = attributed.isolatedCopy()] () mutable {
</span><del>- auto& pcmStore = store->privateClickMeasurementStore();
</del><ins>+ auto* networkSession = store->networkSession();
+ if (!networkSession)
+ return;
+
+ auto& pcmStore = networkSession->privateClickMeasurement().store();
</ins><span class="cx"> for (auto& pcm : WTFMove(attributed))
</span><span class="cx"> pcmStore.insertPrivateClickMeasurement(WTFMove(pcm), PrivateClickMeasurementAttributionType::Attributed);
</span><span class="cx"> for (auto& pcm : WTFMove(unattributed))
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessClassifierResourceLoadStatisticsDatabaseStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -49,12 +49,7 @@
</span><span class="cx"> static constexpr std::array<unsigned, numberOfBucketsPerStatistic> bucketSizes {{ 1, 3, 10, 50, 100 }};
</span><span class="cx">
</span><span class="cx"> class ResourceLoadStatisticsMemoryStore;
</span><del>-class PrivateClickMeasurementManager;
</del><span class="cx">
</span><del>-using SourceSite = WebCore::PrivateClickMeasurement::SourceSite;
-using AttributionDestinationSite = WebCore::PrivateClickMeasurement::AttributionDestinationSite;
-using AttributionTriggerData = WebCore::PrivateClickMeasurement::AttributionTriggerData;
-
</del><span class="cx"> typedef std::pair<String, std::optional<String>> TableAndIndexPair;
</span><span class="cx">
</span><span class="cx"> // This is always constructed / used / destroyed on the WebResourceLoadStatisticsStore's statistics queue.
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -150,23 +150,11 @@
</span><span class="cx"> return queue.get().copyRef();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static String pcmStoreDirectory(const NetworkSession& session, const String& resourceLoadStatisticsDirectory, const String& privateClickMeasurementStorageDirectory)
-{
- if (session.sessionID().isEphemeral())
- return { };
-
- if (!privateClickMeasurementStorageDirectory.isEmpty())
- return privateClickMeasurementStorageDirectory;
-
- return resourceLoadStatisticsDirectory;
-}
-
-WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, const String& privateClickMeasurementStorageDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost, ResourceLoadStatistics::IsEphemeral isEphemeral)
</del><ins>+WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost, ResourceLoadStatistics::IsEphemeral isEphemeral)
</ins><span class="cx"> : m_networkSession(makeWeakPtr(networkSession))
</span><span class="cx"> , m_statisticsQueue(sharedStatisticsQueue())
</span><span class="cx"> , m_dailyTasksTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::performDailyTasks)
</span><span class="cx"> , m_isEphemeral(isEphemeral)
</span><del>- , m_pcmStore(PCM::Store::create(pcmStoreDirectory(networkSession, resourceLoadStatisticsDirectory, privateClickMeasurementStorageDirectory)))
</del><span class="cx"> {
</span><span class="cx"> RELEASE_ASSERT(RunLoop::isMain());
</span><span class="cx">
</span><span class="lines">@@ -198,9 +186,9 @@
</span><span class="cx"> RELEASE_ASSERT(!m_statisticsStore);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-Ref<WebResourceLoadStatisticsStore> WebResourceLoadStatisticsStore::create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, const String& privateClickMeasurementStorageDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost, WebCore::ResourceLoadStatistics::IsEphemeral isEphemeral)
</del><ins>+Ref<WebResourceLoadStatisticsStore> WebResourceLoadStatisticsStore::create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost, WebCore::ResourceLoadStatistics::IsEphemeral isEphemeral)
</ins><span class="cx"> {
</span><del>- return adoptRef(*new WebResourceLoadStatisticsStore(networkSession, resourceLoadStatisticsDirectory, privateClickMeasurementStorageDirectory, shouldIncludeLocalhost, isEphemeral));
</del><ins>+ return adoptRef(*new WebResourceLoadStatisticsStore(networkSession, resourceLoadStatisticsDirectory, shouldIncludeLocalhost, isEphemeral));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebResourceLoadStatisticsStore::didDestroyNetworkSession(CompletionHandler<void()>&& completionHandler)
</span><span class="lines">@@ -213,7 +201,6 @@
</span><span class="cx">
</span><span class="cx"> m_networkSession = nullptr;
</span><span class="cx"> destroyResourceLoadStatisticsStore([callbackAggregator] { });
</span><del>- privateClickMeasurementStore().close([callbackAggregator] { });
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline void WebResourceLoadStatisticsStore::postTask(WTF::Function<void()>&& task)
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessClassifierWebResourceLoadStatisticsStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #include "ArgumentCoders.h"
</span><span class="cx"> #include "Decoder.h"
</span><span class="cx"> #include "Encoder.h"
</span><del>-#include "PrivateClickMeasurementStore.h"
</del><span class="cx"> #include "StorageAccessStatus.h"
</span><span class="cx"> #include "WebPageProxyIdentifier.h"
</span><span class="cx"> #include "WebsiteDataType.h"
</span><span class="lines">@@ -38,7 +37,6 @@
</span><span class="cx"> #include <WebCore/FrameIdentifier.h>
</span><span class="cx"> #include <WebCore/NetworkStorageSession.h>
</span><span class="cx"> #include <WebCore/PageIdentifier.h>
</span><del>-#include <WebCore/PrivateClickMeasurement.h>
</del><span class="cx"> #include <WebCore/RegistrableDomain.h>
</span><span class="cx"> #include <WebCore/ResourceLoadObserver.h>
</span><span class="cx"> #include <wtf/CompletionHandler.h>
</span><span class="lines">@@ -66,7 +64,6 @@
</span><span class="cx"> class ResourceLoadStatisticsStore;
</span><span class="cx"> class WebFrameProxy;
</span><span class="cx"> class WebProcessProxy;
</span><del>-enum class PrivateClickMeasurementAttributionType : bool;
</del><span class="cx"> enum class ShouldGrandfatherStatistics : bool;
</span><span class="cx"> enum class ShouldIncludeLocalhost : bool { No, Yes };
</span><span class="cx"> enum class EnableResourceLoadStatisticsDebugMode : bool { No, Yes };
</span><span class="lines">@@ -109,7 +106,7 @@
</span><span class="cx"> using StorageAccessScope = WebCore::StorageAccessScope;
</span><span class="cx"> using RequestStorageAccessResult = WebCore::RequestStorageAccessResult;
</span><span class="cx">
</span><del>- static Ref<WebResourceLoadStatisticsStore> create(NetworkSession&, const String& resourceLoadStatisticsDirectory, const String& privateClickMeasurementStorageDirectory, ShouldIncludeLocalhost, ResourceLoadStatistics::IsEphemeral);
</del><ins>+ static Ref<WebResourceLoadStatisticsStore> create(NetworkSession&, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost, ResourceLoadStatistics::IsEphemeral);
</ins><span class="cx">
</span><span class="cx"> ~WebResourceLoadStatisticsStore();
</span><span class="cx">
</span><span class="lines">@@ -239,9 +236,8 @@
</span><span class="cx"> bool isEphemeral() const { return m_isEphemeral == WebCore::ResourceLoadStatistics::IsEphemeral::Yes; };
</span><span class="cx"> void insertExpiredStatisticForTesting(const RegistrableDomain&, unsigned numberOfOperatingDaysPassed, bool hadUserInteraction, bool isScheduledForAllButCookieDataRemoval, bool isPrevalent, CompletionHandler<void()>&&);
</span><span class="cx">
</span><del>- PCM::Store& privateClickMeasurementStore() { return m_pcmStore.get(); }
</del><span class="cx"> private:
</span><del>- explicit WebResourceLoadStatisticsStore(NetworkSession&, const String&, const String&, ShouldIncludeLocalhost, WebCore::ResourceLoadStatistics::IsEphemeral);
</del><ins>+ explicit WebResourceLoadStatisticsStore(NetworkSession&, const String&, ShouldIncludeLocalhost, WebCore::ResourceLoadStatistics::IsEphemeral);
</ins><span class="cx">
</span><span class="cx"> void postTask(WTF::Function<void()>&&);
</span><span class="cx"> static void postTaskReply(WTF::Function<void()>&&);
</span><span class="lines">@@ -276,8 +272,6 @@
</span><span class="cx"> bool m_hasScheduledProcessStats { false };
</span><span class="cx">
</span><span class="cx"> bool m_firstNetworkProcessCreated { false };
</span><del>-
- Ref<PCM::Store> m_pcmStore;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -2580,15 +2580,14 @@
</span><span class="cx">
</span><span class="cx"> void NetworkProcess::simulateResourceLoadStatisticsSessionRestart(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><ins>+ // FIXME: Rename this to simulatePrivateClickMeasurementSessionRestart.
</ins><span class="cx"> if (auto* session = networkSession(sessionID)) {
</span><del>- session->recreateResourceLoadStatisticStore([this, sessionID, completionHandler = WTFMove(completionHandler)] () mutable {
</del><ins>+ session->recreatePrivateClickMeasurementStore([this, sessionID, completionHandler = WTFMove(completionHandler)] () mutable {
</ins><span class="cx"> firePrivateClickMeasurementTimerImmediately(sessionID);
</span><span class="cx"> completionHandler();
</span><span class="cx"> });
</span><span class="cx"> return;
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> completionHandler();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -80,6 +80,17 @@
</span><span class="cx"> return storageSession;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static String pcmStoreDirectory(const NetworkSession& session, const String& resourceLoadStatisticsDirectory, const String& privateClickMeasurementStorageDirectory)
+{
+ if (session.sessionID().isEphemeral())
+ return { };
+
+ if (!privateClickMeasurementStorageDirectory.isEmpty())
+ return privateClickMeasurementStorageDirectory;
+
+ return resourceLoadStatisticsDirectory;
+}
+
</ins><span class="cx"> NetworkSession::NetworkSession(NetworkProcess& networkProcess, const NetworkSessionCreationParameters& parameters)
</span><span class="cx"> : m_sessionID(parameters.sessionID)
</span><span class="cx"> , m_networkProcess(networkProcess)
</span><span class="lines">@@ -128,7 +139,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><span class="cx"> setResourceLoadStatisticsEnabled(parameters.resourceLoadStatisticsParameters.enabled);
</span><del>- m_privateClickMeasurement = makeUnique<PrivateClickMeasurementManager>(*this, networkProcess, parameters.sessionID, [weakThis = makeWeakPtr(this)] (auto&& loadParameters, auto&& completionHandler) {
</del><ins>+ m_privateClickMeasurement = makeUnique<PrivateClickMeasurementManager>(*this, networkProcess, parameters.sessionID, pcmStoreDirectory(*this, parameters.resourceLoadStatisticsParameters.directory, parameters.resourceLoadStatisticsParameters.privateClickMeasurementStorageDirectory), [weakThis = makeWeakPtr(this)] (auto&& loadParameters, auto&& completionHandler) {
</ins><span class="cx"> if (!weakThis)
</span><span class="cx"> return completionHandler(ResourceError(ResourceError::Type::Cancellation), { }, { });
</span><span class="cx">
</span><span class="lines">@@ -142,6 +153,7 @@
</span><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><span class="cx"> destroyResourceLoadStatistics([] { });
</span><span class="cx"> #endif
</span><ins>+ privateClickMeasurement().store().close([] { });
</ins><span class="cx"> for (auto& loader : std::exchange(m_keptAliveLoads, { }))
</span><span class="cx"> loader->abort();
</span><span class="cx"> }
</span><span class="lines">@@ -170,6 +182,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void NetworkSession::recreatePrivateClickMeasurementStore(CompletionHandler<void()>&& completionHandler)
+{
+ privateClickMeasurement().destroyStoreForTesting(WTFMove(completionHandler));
+}
+
</ins><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><span class="cx"> void NetworkSession::setResourceLoadStatisticsEnabled(bool enable)
</span><span class="cx"> {
</span><span class="lines">@@ -184,7 +201,7 @@
</span><span class="cx"> if (m_resourceLoadStatistics)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_privateClickMeasurementStorageDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics, (m_sessionID.isEphemeral() ? ResourceLoadStatistics::IsEphemeral::Yes : ResourceLoadStatistics::IsEphemeral::No));
</del><ins>+ m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics, (m_sessionID.isEphemeral() ? ResourceLoadStatistics::IsEphemeral::Yes : ResourceLoadStatistics::IsEphemeral::No));
</ins><span class="cx"> if (!m_sessionID.isEphemeral())
</span><span class="cx"> m_resourceLoadStatistics->populateMemoryStoreFromDisk([] { });
</span><span class="cx">
</span><span class="lines">@@ -196,20 +213,6 @@
</span><span class="cx"> forwardResourceLoadStatisticsSettings();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void NetworkSession::recreateResourceLoadStatisticStore(CompletionHandler<void()>&& completionHandler)
-{
- destroyResourceLoadStatistics([this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)] () mutable {
- if (!weakThis)
- return completionHandler();
- m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_privateClickMeasurementStorageDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics, (m_sessionID.isEphemeral() ? ResourceLoadStatistics::IsEphemeral::Yes : ResourceLoadStatistics::IsEphemeral::No));
- forwardResourceLoadStatisticsSettings();
- if (!m_sessionID.isEphemeral())
- m_resourceLoadStatistics->populateMemoryStoreFromDisk(WTFMove(completionHandler));
- else
- completionHandler();
- });
-}
-
</del><span class="cx"> void NetworkSession::forwardResourceLoadStatisticsSettings()
</span><span class="cx"> {
</span><span class="cx"> m_resourceLoadStatistics->setThirdPartyCookieBlockingMode(m_thirdPartyCookieBlockingMode);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -94,10 +94,11 @@
</span><span class="cx"> void registerNetworkDataTask(NetworkDataTask&);
</span><span class="cx"> void unregisterNetworkDataTask(NetworkDataTask&);
</span><span class="cx">
</span><ins>+ void recreatePrivateClickMeasurementStore(CompletionHandler<void()>&&);
+
</ins><span class="cx"> #if ENABLE(RESOURCE_LOAD_STATISTICS)
</span><span class="cx"> WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
</span><span class="cx"> void setResourceLoadStatisticsEnabled(bool);
</span><del>- void recreateResourceLoadStatisticStore(CompletionHandler<void()>&&);
</del><span class="cx"> bool isResourceLoadStatisticsEnabled() const;
</span><span class="cx"> void notifyResourceLoadStatisticsProcessed();
</span><span class="cx"> void deleteAndRestrictWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType>, RegistrableDomainsToDeleteOrRestrictWebsiteDataFor&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<WebCore::RegistrableDomain>&)>&&);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -338,7 +338,7 @@
</span><span class="cx"> return attributions;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-String Database::privateClickMeasurementToStringForTesting()
</del><ins>+String Database::privateClickMeasurementToStringForTesting() const
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!RunLoop::isMain());
</span><span class="cx"> auto privateClickMeasurementDataExists = m_database.prepareStatement("SELECT (SELECT COUNT(*) FROM UnattributedPrivateClickMeasurement) as cnt1, (SELECT COUNT(*) FROM AttributedPrivateClickMeasurement) as cnt2"_s);
</span><span class="lines">@@ -385,7 +385,7 @@
</span><span class="cx"> return builder.toString();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-String Database::attributionToStringForTesting(WebCore::SQLiteStatement& statement, PrivateClickMeasurementAttributionType attributionType)
</del><ins>+String Database::attributionToStringForTesting(WebCore::SQLiteStatement& statement, PrivateClickMeasurementAttributionType attributionType) const
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!RunLoop::isMain());
</span><span class="cx"> auto sourceSiteDomain = getDomainStringFromDomainID(statement.columnInt(0));
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> void clearExpiredPrivateClickMeasurement();
</span><span class="cx"> void clearSentAttribution(WebCore::PrivateClickMeasurement&&, WebCore::PrivateClickMeasurement::AttributionReportEndpoint);
</span><span class="cx">
</span><del>- String privateClickMeasurementToStringForTesting();
</del><ins>+ String privateClickMeasurementToStringForTesting() const;
</ins><span class="cx"> void markAllUnattributedPrivateClickMeasurementAsExpiredForTesting();
</span><span class="cx"> void markAttributedPrivateClickMeasurementsAsExpiredForTesting();
</span><span class="cx">
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> void destroyStatements() final;
</span><span class="cx"> std::pair<std::optional<UnattributedPrivateClickMeasurement>, std::optional<AttributedPrivateClickMeasurement>> findPrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&);
</span><span class="cx"> void removeUnattributed(WebCore::PrivateClickMeasurement&);
</span><del>- String attributionToStringForTesting(WebCore::SQLiteStatement&, PrivateClickMeasurementAttributionType);
</del><ins>+ String attributionToStringForTesting(WebCore::SQLiteStatement&, PrivateClickMeasurementAttributionType) const;
</ins><span class="cx"> void markReportAsSentToDestination(SourceDomainID, DestinationDomainID);
</span><span class="cx"> void markReportAsSentToSource(SourceDomainID, DestinationDomainID);
</span><span class="cx"> std::pair<std::optional<SourceEarliestTimeToSend>, std::optional<DestinationEarliestTimeToSend>> earliestTimesToSend(const WebCore::PrivateClickMeasurement&);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -67,13 +67,13 @@
</span><span class="cx">
</span><span class="cx"> Store::~Store() = default;
</span><span class="cx">
</span><del>-void Store::postTask(Function<void()>&& task)
</del><ins>+void Store::postTask(Function<void()>&& task) const
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(RunLoop::isMain());
</span><span class="cx"> m_queue->dispatch(WTFMove(task));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Store::postTaskReply(WTF::Function<void()>&& reply)
</del><ins>+void Store::postTaskReply(WTF::Function<void()>&& reply) const
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!RunLoop::isMain());
</span><span class="cx"> RunLoop::main().dispatch(WTFMove(reply));
</span><span class="lines">@@ -118,7 +118,7 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Store::privateClickMeasurementToStringForTesting(CompletionHandler<void(String)>&& completionHandler)
</del><ins>+void Store::privateClickMeasurementToStringForTesting(CompletionHandler<void(String)>&& completionHandler) const
</ins><span class="cx"> {
</span><span class="cx"> postTask([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
</span><span class="cx"> String result;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx"> void insertPrivateClickMeasurement(WebCore::PrivateClickMeasurement&&, WebKit::PrivateClickMeasurementAttributionType);
</span><span class="cx"> void attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&, WebCore::PrivateClickMeasurement::AttributionTriggerData&&, std::optional<WebCore::PrivateClickMeasurement>&& ephemeralMeasurement, CompletionHandler<void(std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>&&, DebugInfo&&)>&&);
</span><span class="cx">
</span><del>- void privateClickMeasurementToStringForTesting(CompletionHandler<void(String)>&&);
</del><ins>+ void privateClickMeasurementToStringForTesting(CompletionHandler<void(String)>&&) const;
</ins><span class="cx"> void markAllUnattributedPrivateClickMeasurementAsExpiredForTesting();
</span><span class="cx"> void markAttributedPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&&);
</span><span class="cx">
</span><span class="lines">@@ -68,8 +68,8 @@
</span><span class="cx"> private:
</span><span class="cx"> Store(const String& databaseDirectory);
</span><span class="cx">
</span><del>- void postTask(Function<void()>&&);
- void postTaskReply(Function<void()>&&);
</del><ins>+ void postTask(Function<void()>&&) const;
+ void postTaskReply(Function<void()>&&) const;
</ins><span class="cx">
</span><span class="cx"> std::unique_ptr<Database> m_database;
</span><span class="cx"> Ref<SuspendableWorkQueue> m_queue;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -53,11 +53,12 @@
</span><span class="cx">
</span><span class="cx"> constexpr Seconds debugModeSecondsUntilSend { 10_s };
</span><span class="cx">
</span><del>-PrivateClickMeasurementManager::PrivateClickMeasurementManager(NetworkSession& networkSession, NetworkProcess& networkProcess, PAL::SessionID sessionID, Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)>&& networkLoadFunction)
</del><ins>+PrivateClickMeasurementManager::PrivateClickMeasurementManager(NetworkSession& networkSession, NetworkProcess& networkProcess, PAL::SessionID sessionID, const String& storageDirectory, Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)>&& networkLoadFunction)
</ins><span class="cx"> : m_firePendingAttributionRequestsTimer(*this, &PrivateClickMeasurementManager::firePendingAttributionRequests)
</span><span class="cx"> , m_networkSession(makeWeakPtr(networkSession))
</span><span class="cx"> , m_networkProcess(networkProcess)
</span><span class="cx"> , m_sessionID(sessionID)
</span><ins>+ , m_storageDirectory(storageDirectory)
</ins><span class="cx"> , m_networkLoadFunction(WTFMove(networkLoadFunction))
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_networkLoadFunction);
</span><span class="lines">@@ -249,10 +250,7 @@
</span><span class="cx"> m_ephemeralMeasurement = WTFMove(measurement);
</span><span class="cx"> return;
</span><span class="cx"> }
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics())
- resourceLoadStatistics->privateClickMeasurementStore().insertPrivateClickMeasurement(WTFMove(measurement), type);
-#endif
</del><ins>+ store().insertPrivateClickMeasurement(WTFMove(measurement), type);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::handleAttribution(AttributionTriggerData&& attributionTriggerData, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest)
</span><span class="lines">@@ -285,7 +283,6 @@
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::attribute(const SourceSite& sourceSite, const AttributionDestinationSite& destinationSite, AttributionTriggerData&& attributionTriggerData)
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><span class="cx"> if (!featureEnabled())
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -297,40 +294,37 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics()) {
- resourceLoadStatistics->privateClickMeasurementStore().attributePrivateClickMeasurement(sourceSite, destinationSite, WTFMove(attributionTriggerData), std::exchange(m_ephemeralMeasurement, std::nullopt), [this, weakThis = makeWeakPtr(*this)] (auto attributionSecondsUntilSendData, auto debugInfo) {
- if (!weakThis)
- return;
-
- if (!attributionSecondsUntilSendData)
- return;
</del><ins>+ store().attributePrivateClickMeasurement(sourceSite, destinationSite, WTFMove(attributionTriggerData), std::exchange(m_ephemeralMeasurement, std::nullopt), [this, weakThis = makeWeakPtr(*this)] (auto attributionSecondsUntilSendData, auto debugInfo) {
+ if (!weakThis)
+ return;
+
+ if (!attributionSecondsUntilSendData)
+ return;
</ins><span class="cx">
</span><del>- if (UNLIKELY(debugModeEnabled())) {
- for (auto& message : debugInfo.messages)
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, message.messageLevel, message.message);
- }
</del><ins>+ if (UNLIKELY(debugModeEnabled())) {
+ for (auto& message : debugInfo.messages)
+ m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, message.messageLevel, message.message);
+ }
</ins><span class="cx">
</span><del>- if (attributionSecondsUntilSendData.value().hasValidSecondsUntilSendValues()) {
- auto minSecondsUntilSend = attributionSecondsUntilSendData.value().minSecondsUntilSend();
</del><ins>+ if (attributionSecondsUntilSendData.value().hasValidSecondsUntilSendValues()) {
+ auto minSecondsUntilSend = attributionSecondsUntilSendData.value().minSecondsUntilSend();
</ins><span class="cx">
</span><del>- ASSERT(minSecondsUntilSend);
- if (!minSecondsUntilSend)
- return;
</del><ins>+ ASSERT(minSecondsUntilSend);
+ if (!minSecondsUntilSend)
+ return;
</ins><span class="cx">
</span><del>- if (m_firePendingAttributionRequestsTimer.isActive() && m_firePendingAttributionRequestsTimer.nextFireInterval() < *minSecondsUntilSend)
- return;
</del><ins>+ if (m_firePendingAttributionRequestsTimer.isActive() && m_firePendingAttributionRequestsTimer.nextFireInterval() < *minSecondsUntilSend)
+ return;
</ins><span class="cx">
</span><del>- if (UNLIKELY(debugModeEnabled())) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, makeString("[Private Click Measurement] Setting timer for firing attribution request to the debug mode timeout of "_s, debugModeSecondsUntilSend.seconds(), " seconds where the regular timeout would have been "_s, minSecondsUntilSend.value().seconds(), " seconds."_s));
- minSecondsUntilSend = debugModeSecondsUntilSend;
- } else
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, makeString("[Private Click Measurement] Setting timer for firing attribution request to the timeout of "_s, minSecondsUntilSend.value().seconds(), " seconds."_s));
</del><ins>+ if (UNLIKELY(debugModeEnabled())) {
+ m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, makeString("[Private Click Measurement] Setting timer for firing attribution request to the debug mode timeout of "_s, debugModeSecondsUntilSend.seconds(), " seconds where the regular timeout would have been "_s, minSecondsUntilSend.value().seconds(), " seconds."_s));
+ minSecondsUntilSend = debugModeSecondsUntilSend;
+ } else
+ m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, makeString("[Private Click Measurement] Setting timer for firing attribution request to the timeout of "_s, minSecondsUntilSend.value().seconds(), " seconds."_s));
</ins><span class="cx">
</span><del>- startTimer(*minSecondsUntilSend);
- }
- });
- }
-#endif
</del><ins>+ startTimer(*minSecondsUntilSend);
+ }
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::fireConversionRequest(const PrivateClickMeasurement& attribution, PrivateClickMeasurement::AttributionReportEndpoint attributionReportEndpoint)
</span><span class="lines">@@ -396,26 +390,18 @@
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::clearSentAttribution(PrivateClickMeasurement&& sentConversion, PrivateClickMeasurement::AttributionReportEndpoint attributionReportEndpoint)
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><span class="cx"> if (!featureEnabled())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics())
- resourceLoadStatistics->privateClickMeasurementStore().clearSentAttribution(WTFMove(sentConversion), attributionReportEndpoint);
-#endif
</del><ins>+ store().clearSentAttribution(WTFMove(sentConversion), attributionReportEndpoint);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::firePendingAttributionRequests()
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><span class="cx"> if (!featureEnabled())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics();
- if (!resourceLoadStatistics)
- return;
-
- resourceLoadStatistics->privateClickMeasurementStore().allAttributedPrivateClickMeasurement([this, weakThis = makeWeakPtr(*this)] (auto&& attributions) {
</del><ins>+ store().allAttributedPrivateClickMeasurement([this, weakThis = makeWeakPtr(*this)] (auto&& attributions) {
</ins><span class="cx"> if (!weakThis)
</span><span class="cx"> return;
</span><span class="cx"> auto nextTimeToFire = Seconds::infinity();
</span><span class="lines">@@ -465,7 +451,6 @@
</span><span class="cx"> if (nextTimeToFire < Seconds::infinity())
</span><span class="cx"> startTimer(nextTimeToFire);
</span><span class="cx"> });
</span><del>-#endif
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::clear(CompletionHandler<void()>&& completionHandler)
</span><span class="lines">@@ -474,53 +459,34 @@
</span><span class="cx"> m_ephemeralMeasurement = std::nullopt;
</span><span class="cx"> m_isRunningEphemeralMeasurementTest = false;
</span><span class="cx">
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><span class="cx"> if (!featureEnabled())
</span><span class="cx"> return completionHandler();
</span><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics())
- return resourceLoadStatistics->privateClickMeasurementStore().clearPrivateClickMeasurement(WTFMove(completionHandler));
-#endif
- completionHandler();
</del><ins>+ store().clearPrivateClickMeasurement(WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::clearForRegistrableDomain(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler)
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><span class="cx"> if (!featureEnabled())
</span><span class="cx"> return completionHandler();
</span><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics())
- return resourceLoadStatistics->privateClickMeasurementStore().clearPrivateClickMeasurementForRegistrableDomain(domain, WTFMove(completionHandler));
-#endif
- completionHandler();
</del><ins>+ store().clearPrivateClickMeasurementForRegistrableDomain(domain, WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::clearExpired()
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><span class="cx"> if (!featureEnabled())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics())
- resourceLoadStatistics->privateClickMeasurementStore().clearExpiredPrivateClickMeasurement();
-#endif
</del><ins>+ store().clearExpiredPrivateClickMeasurement();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::toStringForTesting(CompletionHandler<void(String)>&& completionHandler) const
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
- if (!featureEnabled()) {
- completionHandler("\nNo stored Private Click Measurement data.\n"_s);
- return;
- }
</del><ins>+ if (!featureEnabled())
+ return completionHandler("\nNo stored Private Click Measurement data.\n"_s);
</ins><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics()) {
- resourceLoadStatistics->privateClickMeasurementStore().privateClickMeasurementToStringForTesting(WTFMove(completionHandler));
- return;
- }
-#endif
- completionHandler("\nNo stored Private Click Measurement data.\n"_s);
</del><ins>+ store().privateClickMeasurementToStringForTesting(WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::setTokenPublicKeyURLForTesting(URL&& testURL)
</span><span class="lines">@@ -548,13 +514,10 @@
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::markAllUnattributedAsExpiredForTesting()
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
</del><span class="cx"> if (!featureEnabled())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics())
- resourceLoadStatistics->privateClickMeasurementStore().markAllUnattributedPrivateClickMeasurementAsExpiredForTesting();
-#endif
</del><ins>+ store().markAllUnattributedPrivateClickMeasurementAsExpiredForTesting();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::setPCMFraudPreventionValuesForTesting(String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID)
</span><span class="lines">@@ -576,18 +539,35 @@
</span><span class="cx">
</span><span class="cx"> void PrivateClickMeasurementManager::markAttributedPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&& completionHandler)
</span><span class="cx"> {
</span><del>-#if ENABLE(RESOURCE_LOAD_STATISTICS)
- if (!featureEnabled()) {
- completionHandler();
- return;
- }
</del><ins>+ if (!featureEnabled())
+ return completionHandler();
</ins><span class="cx">
</span><del>- if (auto* resourceLoadStatistics = m_networkSession->resourceLoadStatistics()) {
- resourceLoadStatistics->privateClickMeasurementStore().markAttributedPrivateClickMeasurementsAsExpiredForTesting(WTFMove(completionHandler));
- return;
- }
-#endif
- completionHandler();
</del><ins>+ store().markAttributedPrivateClickMeasurementsAsExpiredForTesting(WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+PCM::Store& PrivateClickMeasurementManager::store()
+{
+ if (!m_store)
+ m_store = PCM::Store::create(m_storageDirectory);
+ return *m_store;
+}
+
+const PCM::Store& PrivateClickMeasurementManager::store() const
+{
+ if (!m_store)
+ m_store = PCM::Store::create(m_storageDirectory);
+ return *m_store;
+}
+
+void PrivateClickMeasurementManager::destroyStoreForTesting(CompletionHandler<void()>&& completionHandler)
+{
+ if (!m_store)
+ return completionHandler();
+ m_store->close([weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)] () mutable {
+ if (weakThis)
+ weakThis->m_store = nullptr;
+ return completionHandler();
+ });
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h (281885 => 281886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h 2021-09-01 22:54:42 UTC (rev 281885)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h 2021-09-01 23:26:50 UTC (rev 281886)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">
</span><span class="cx"> #include "NetworkLoadParameters.h"
</span><span class="cx"> #include "NetworkProcess.h"
</span><ins>+#include "PrivateClickMeasurementStore.h"
</ins><span class="cx"> #include <WebCore/PrivateClickMeasurement.h>
</span><span class="cx"> #include <WebCore/RegistrableDomain.h>
</span><span class="cx"> #include <WebCore/ResourceError.h>
</span><span class="lines">@@ -52,7 +53,7 @@
</span><span class="cx"> using PrivateClickMeasurement = WebCore::PrivateClickMeasurement;
</span><span class="cx"> using RegistrableDomain = WebCore::RegistrableDomain;
</span><span class="cx"> using SourceSite = WebCore::PrivateClickMeasurement::SourceSite;
</span><del>- explicit PrivateClickMeasurementManager(NetworkSession&, NetworkProcess&, PAL::SessionID, Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)>&&);
</del><ins>+ explicit PrivateClickMeasurementManager(NetworkSession&, NetworkProcess&, PAL::SessionID, const String& storageDirectory, Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)>&&);
</ins><span class="cx">
</span><span class="cx"> void storeUnattributed(PrivateClickMeasurement&&);
</span><span class="cx"> void handleAttribution(AttributionTriggerData&&, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest);
</span><span class="lines">@@ -69,6 +70,11 @@
</span><span class="cx"> void setPCMFraudPreventionValuesForTesting(String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID);
</span><span class="cx"> void startTimer(Seconds);
</span><span class="cx">
</span><ins>+ void destroyStoreForTesting(CompletionHandler<void()>&&);
+
+ PCM::Store& store();
+ const PCM::Store& store() const;
+
</ins><span class="cx"> private:
</span><span class="cx"> void getTokenPublicKey(PrivateClickMeasurement&&, PrivateClickMeasurement::AttributionReportEndpoint, PrivateClickMeasurement::PcmDataCarried, Function<void(PrivateClickMeasurement&& attribution, const String& publicKeyBase64URL)>&&);
</span><span class="cx"> void getSignedUnlinkableToken(PrivateClickMeasurement&&);
</span><span class="lines">@@ -91,6 +97,8 @@
</span><span class="cx"> WeakPtr<NetworkSession> m_networkSession;
</span><span class="cx"> Ref<NetworkProcess> m_networkProcess;
</span><span class="cx"> PAL::SessionID m_sessionID;
</span><ins>+ mutable RefPtr<PCM::Store> m_store;
+ String m_storageDirectory;
</ins><span class="cx"> Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)> m_networkLoadFunction;
</span><span class="cx">
</span><span class="cx"> struct AttributionReportTestConfig {
</span></span></pre>
</div>
</div>
</body>
</html>