Log Message
Introduce PCM::Client for PrivateClickMeasurementManager https://bugs.webkit.org/show_bug.cgi?id=229789
Patch by Alex Christensen <achristen...@webkit.org> on 2021-09-02 Reviewed by Kate Cheney. This makes it so that PrivateClickMeasurementManager can run in environments other than the NetworkProcess. * NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::NetworkSession): * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h: Added. (WebKit::PCM::Client::~Client): * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp: Added. (WebKit::PCM::ClientImpl::ClientImpl): (WebKit::PCM::ClientImpl::loadFromNetwork): (WebKit::PCM::ClientImpl::broadcastConsoleMessage): (WebKit::PCM::ClientImpl::featureEnabled const): (WebKit::PCM::ClientImpl::debugModeEnabled const): * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h: Added. * NetworkProcess/PrivateClickMeasurementManager.cpp: (WebKit::PrivateClickMeasurementManager::PrivateClickMeasurementManager): (WebKit::PrivateClickMeasurementManager::storeUnattributed): (WebKit::PrivateClickMeasurementManager::getTokenPublicKey): (WebKit::PrivateClickMeasurementManager::getSignedUnlinkableToken): (WebKit::PrivateClickMeasurementManager::handleAttribution): (WebKit::PrivateClickMeasurementManager::attribute): (WebKit::PrivateClickMeasurementManager::fireConversionRequestImpl): (WebKit::PrivateClickMeasurementManager::featureEnabled const): (WebKit::PrivateClickMeasurementManager::debugModeEnabled const): * NetworkProcess/PrivateClickMeasurementManager.h: * Sources.txt: * WebKit.xcodeproj/project.pbxproj:
Modified Paths
- trunk/Source/WebKit/ChangeLog
- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp
- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp
- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h
- trunk/Source/WebKit/Sources.txt
- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
Added Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (281943 => 281944)
--- trunk/Source/WebKit/ChangeLog 2021-09-02 18:53:37 UTC (rev 281943)
+++ trunk/Source/WebKit/ChangeLog 2021-09-02 18:57:34 UTC (rev 281944)
@@ -1,3 +1,37 @@
+2021-09-02 Alex Christensen <achristen...@webkit.org>
+
+ Introduce PCM::Client for PrivateClickMeasurementManager
+ https://bugs.webkit.org/show_bug.cgi?id=229789
+
+ Reviewed by Kate Cheney.
+
+ This makes it so that PrivateClickMeasurementManager can run in environments other than the NetworkProcess.
+
+ * NetworkProcess/NetworkSession.cpp:
+ (WebKit::NetworkSession::NetworkSession):
+ * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h: Added.
+ (WebKit::PCM::Client::~Client):
+ * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp: Added.
+ (WebKit::PCM::ClientImpl::ClientImpl):
+ (WebKit::PCM::ClientImpl::loadFromNetwork):
+ (WebKit::PCM::ClientImpl::broadcastConsoleMessage):
+ (WebKit::PCM::ClientImpl::featureEnabled const):
+ (WebKit::PCM::ClientImpl::debugModeEnabled const):
+ * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h: Added.
+ * NetworkProcess/PrivateClickMeasurementManager.cpp:
+ (WebKit::PrivateClickMeasurementManager::PrivateClickMeasurementManager):
+ (WebKit::PrivateClickMeasurementManager::storeUnattributed):
+ (WebKit::PrivateClickMeasurementManager::getTokenPublicKey):
+ (WebKit::PrivateClickMeasurementManager::getSignedUnlinkableToken):
+ (WebKit::PrivateClickMeasurementManager::handleAttribution):
+ (WebKit::PrivateClickMeasurementManager::attribute):
+ (WebKit::PrivateClickMeasurementManager::fireConversionRequestImpl):
+ (WebKit::PrivateClickMeasurementManager::featureEnabled const):
+ (WebKit::PrivateClickMeasurementManager::debugModeEnabled const):
+ * NetworkProcess/PrivateClickMeasurementManager.h:
+ * Sources.txt:
+ * WebKit.xcodeproj/project.pbxproj:
+
2021-09-02 Chris Dumez <cdu...@apple.com>
[COOP] Cross origin isolation doesn't happen when going from an HTTP URL to a HTTPS one with COOP+COEP
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (281943 => 281944)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-09-02 18:53:37 UTC (rev 281943)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-09-02 18:57:34 UTC (rev 281944)
@@ -35,6 +35,7 @@
#include "NetworkResourceLoader.h"
#include "NetworkSessionCreationParameters.h"
#include "PingLoad.h"
+#include "PrivateClickMeasurementClientImpl.h"
#include "PrivateClickMeasurementManager.h"
#include "WebPageProxy.h"
#include "WebPageProxyMessages.h"
@@ -139,13 +140,8 @@
#if ENABLE(RESOURCE_LOAD_STATISTICS)
setResourceLoadStatisticsEnabled(parameters.resourceLoadStatisticsParameters.enabled);
- m_privateClickMeasurement = makeUnique<PrivateClickMeasurementManager>(*this, networkProcess, parameters.sessionID, pcmStoreDirectory(*this, parameters.resourceLoadStatisticsParameters.directory, parameters.resourceLoadStatisticsParameters.privateClickMeasurementStorageDirectory), [weakThis = makeWeakPtr(this)] (auto&& loadParameters, auto&& completionHandler) {
- if (!weakThis)
- return completionHandler(ResourceError(ResourceError::Type::Cancellation), { }, { });
-
- PrivateClickMeasurementNetworkLoader::start(*weakThis, WTFMove(loadParameters), WTFMove(completionHandler));
- });
#endif
+ m_privateClickMeasurement = makeUnique<PrivateClickMeasurementManager>(makeUniqueRef<PCM::ClientImpl>(*this, networkProcess), pcmStoreDirectory(*this, parameters.resourceLoadStatisticsParameters.directory, parameters.resourceLoadStatisticsParameters.privateClickMeasurementStorageDirectory));
}
NetworkSession::~NetworkSession()
Added: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h (0 => 281944)
--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h 2021-09-02 18:57:34 UTC (rev 281944)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/JSONValues.h>
+
+namespace JSC {
+enum class MessageLevel : uint8_t;
+}
+
+namespace WebCore {
+class ResourceError;
+class ResourceResponse;
+}
+
+namespace WebKit {
+
+class NetworkLoadParameters;
+
+namespace PCM {
+
+class Client {
+public:
+ virtual ~Client() { }
+ using NetworkLoadCallback = CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&, const RefPtr<JSON::Object>&)>;
+ virtual void loadFromNetwork(NetworkLoadParameters&&, NetworkLoadCallback&&) = 0;
+ virtual void broadcastConsoleMessage(JSC::MessageLevel, const String&) = 0;
+ virtual bool featureEnabled() const = 0;
+ virtual bool debugModeEnabled() const = 0;
+};
+
+} // namespace PCM
+
+} // namespace WebKit
Added: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp (0 => 281944)
--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp 2021-09-02 18:57:34 UTC (rev 281944)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PrivateClickMeasurementClientImpl.h"
+
+#include "NetworkProcess.h"
+#include "NetworkSession.h"
+
+namespace WebKit {
+
+namespace PCM {
+
+ClientImpl::ClientImpl(NetworkSession& session, NetworkProcess& networkProcess)
+ : m_networkSession(makeWeakPtr(session))
+ , m_networkProcess(networkProcess) { }
+
+void ClientImpl::loadFromNetwork(NetworkLoadParameters&& loadParameters, NetworkLoadCallback&& completionHandler)
+{
+ if (!featureEnabled())
+ return completionHandler(ResourceError(ResourceError::Type::Cancellation), { }, { });
+
+ PrivateClickMeasurementNetworkLoader::start(*m_networkSession, WTFMove(loadParameters), WTFMove(completionHandler));
+}
+
+void ClientImpl::broadcastConsoleMessage(JSC::MessageLevel messageLevel, const String& message)
+{
+ if (!featureEnabled())
+ return;
+
+ m_networkProcess->broadcastConsoleMessage(m_networkSession->sessionID(), MessageSource::PrivateClickMeasurement, messageLevel, message);
+}
+
+bool ClientImpl::featureEnabled() const
+{
+ return m_networkSession
+ && m_networkProcess->privateClickMeasurementEnabled()
+ && !m_networkSession->sessionID().isEphemeral();
+}
+
+bool ClientImpl::debugModeEnabled() const
+{
+ return m_networkSession
+ && m_networkProcess->privateClickMeasurementDebugModeEnabled()
+ && !m_networkSession->sessionID().isEphemeral();
+}
+
+} // namespace PCM
+
+} // namespace WebKit
Added: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h (0 => 281944)
--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h 2021-09-02 18:57:34 UTC (rev 281944)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "PrivateClickMeasurementClient.h"
+#include <pal/SessionID.h>
+#include <wtf/FastMalloc.h>
+
+namespace WebKit {
+
+class NetworkSession;
+class NetworkProcess;
+
+namespace PCM {
+
+class ClientImpl : public Client {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ ClientImpl(NetworkSession&, NetworkProcess&);
+
+private:
+ void loadFromNetwork(NetworkLoadParameters&&, NetworkLoadCallback&&) final;
+ void broadcastConsoleMessage(JSC::MessageLevel, const String&) final;
+ bool featureEnabled() const final;
+ bool debugModeEnabled() const final;
+
+ WeakPtr<NetworkSession> m_networkSession;
+ Ref<NetworkProcess> m_networkProcess;
+};
+
+} // namespace PCM
+
+} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp (281943 => 281944)
--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp 2021-09-02 18:53:37 UTC (rev 281943)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.cpp 2021-09-02 18:57:34 UTC (rev 281944)
@@ -53,16 +53,11 @@
constexpr Seconds debugModeSecondsUntilSend { 10_s };
-PrivateClickMeasurementManager::PrivateClickMeasurementManager(NetworkSession& networkSession, NetworkProcess& networkProcess, PAL::SessionID sessionID, const String& storageDirectory, Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)>&& networkLoadFunction)
+PrivateClickMeasurementManager::PrivateClickMeasurementManager(UniqueRef<PCM::Client>&& client, const String& storageDirectory)
: m_firePendingAttributionRequestsTimer(*this, &PrivateClickMeasurementManager::firePendingAttributionRequests)
- , m_networkSession(makeWeakPtr(networkSession))
- , m_networkProcess(networkProcess)
- , m_sessionID(sessionID)
, m_storageDirectory(storageDirectory)
- , m_networkLoadFunction(WTFMove(networkLoadFunction))
+ , m_client(WTFMove(client))
{
- ASSERT(m_networkLoadFunction);
-
// We should send any pending attributions on session-start in case their
// send delay has expired while the session was closed. Waiting 5 seconds accounts for the
// delay in database startup.
@@ -92,7 +87,7 @@
else {
if (auto errorMessage = measurement.calculateAndUpdateSourceUnlinkableToken(publicKeyBase64URL)) {
RELEASE_LOG_INFO(PrivateClickMeasurement, "Got the following error in calculateAndUpdateSourceUnlinkableToken(): '%{public}s", errorMessage->utf8().data());
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] "_s, *errorMessage));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] "_s, *errorMessage));
return;
}
}
@@ -103,7 +98,7 @@
});
}
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] Storing a click."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] Storing a click."_s);
insertPrivateClickMeasurement(WTFMove(measurement), PrivateClickMeasurementAttributionType::Unattributed);
}
@@ -158,23 +153,23 @@
auto loadParameters = generateNetworkLoadParametersForHttpGet(WTFMove(tokenPublicKeyURL), pcmDataCarried, debugModeEnabled());
RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire a token public key request.");
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] About to fire a token public key request."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] About to fire a token public key request."_s);
- m_networkLoadFunction(WTFMove(loadParameters), [weakThis = makeWeakPtr(*this), this, attribution = WTFMove(attribution), callback = WTFMove(callback)] (auto& error, auto& response, auto& jsonObject) mutable {
+ m_client->loadFromNetwork(WTFMove(loadParameters), [weakThis = makeWeakPtr(*this), this, attribution = WTFMove(attribution), callback = WTFMove(callback)] (auto& error, auto& response, auto& jsonObject) mutable {
if (!weakThis)
return;
if (!error.isNull()) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] Received error: '"_s, error.localizedDescription(), "' for token public key request."_s));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] Received error: '"_s, error.localizedDescription(), "' for token public key request."_s));
return;
}
if (!jsonObject) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] JSON response is empty for token public key request."_s));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] JSON response is empty for token public key request."_s));
return;
}
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, makeString("[Private Click Measurement] Got JSON response for token public key request."_s));
+ m_client->broadcastConsoleMessage(MessageLevel::Log, makeString("[Private Click Measurement] Got JSON response for token public key request."_s));
callback(WTFMove(attribution), jsonObject->getString("token_public_key"_s));
});
@@ -201,25 +196,25 @@
auto loadParameters = generateNetworkLoadParametersForHttpPost(WTFMove(tokenSignatureURL), measurement.tokenSignatureJSON(), pcmDataCarried, debugModeEnabled());
RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire a unlinkable token signing request.");
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] About to fire a unlinkable token signing request."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] About to fire a unlinkable token signing request."_s);
- m_networkLoadFunction(WTFMove(loadParameters), [weakThis = makeWeakPtr(*this), this, measurement = WTFMove(measurement)] (auto& error, auto& response, auto& jsonObject) mutable {
+ m_client->loadFromNetwork(WTFMove(loadParameters), [weakThis = makeWeakPtr(*this), this, measurement = WTFMove(measurement)] (auto& error, auto& response, auto& jsonObject) mutable {
if (!weakThis)
return;
if (!error.isNull()) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] Received error: '"_s, error.localizedDescription(), "' for secret token signing request."_s));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] Received error: '"_s, error.localizedDescription(), "' for secret token signing request."_s));
return;
}
if (!jsonObject) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] JSON response is empty for token signing request."_s));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] JSON response is empty for token signing request."_s));
return;
}
auto signatureBase64URL = jsonObject->getString("unlinkable_token"_s);
if (signatureBase64URL.isEmpty()) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] JSON response doesn't have the key 'unlinkable_token' for token signing request."_s));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] JSON response doesn't have the key 'unlinkable_token' for token signing request."_s));
return;
}
// FIX NOW!
@@ -229,13 +224,13 @@
else {
if (auto errorMessage = measurement.calculateAndUpdateSourceSecretToken(signatureBase64URL)) {
RELEASE_LOG_INFO(PrivateClickMeasurement, "Got the following error in calculateAndUpdateSourceSecretToken(): '%{public}s", errorMessage->utf8().data());
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] "_s, *errorMessage));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] "_s, *errorMessage));
return;
}
}
#endif
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] Storing a secret token."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] Storing a secret token."_s);
insertPrivateClickMeasurement(WTFMove(measurement), PrivateClickMeasurementAttributionType::Unattributed);
});
@@ -262,16 +257,16 @@
auto& firstPartyURL = redirectRequest.firstPartyForCookies();
if (!redirectDomain.matches(requestURL)) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Warning, "[Private Click Measurement] Triggering event was not accepted because the HTTP redirect was not same-site."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Warning, "[Private Click Measurement] Triggering event was not accepted because the HTTP redirect was not same-site."_s);
return;
}
if (redirectDomain.matches(firstPartyURL)) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Warning, "[Private Click Measurement] Triggering event was not accepted because it was requested in an HTTP redirect that is same-site as the first-party."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Warning, "[Private Click Measurement] Triggering event was not accepted because it was requested in an HTTP redirect that is same-site as the first-party."_s);
return;
}
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] Triggering event accepted."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] Triggering event accepted."_s);
attribute(SourceSite { WTFMove(redirectDomain) }, AttributionDestinationSite { firstPartyURL }, WTFMove(attributionTriggerData));
}
@@ -303,7 +298,7 @@
if (UNLIKELY(debugModeEnabled())) {
for (auto& message : debugInfo.messages)
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, message.messageLevel, message.message);
+ m_client->broadcastConsoleMessage(message.messageLevel, message.message);
}
if (attributionSecondsUntilSendData.value().hasValidSecondsUntilSendValues()) {
@@ -317,10 +312,10 @@
return;
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));
+ m_client->broadcastConsoleMessage(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));
+ m_client->broadcastConsoleMessage(MessageLevel::Log, makeString("[Private Click Measurement] Setting timer for firing attribution request to the timeout of "_s, minSecondsUntilSend.value().seconds(), " seconds."_s));
startTimer(*minSecondsUntilSend);
}
@@ -376,14 +371,14 @@
auto loadParameters = generateNetworkLoadParametersForHttpPost(WTFMove(attributionURL), attribution.attributionReportJSON(), PrivateClickMeasurement::PcmDataCarried::NonPersonallyIdentifiable, debugModeEnabled());
RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire an attribution request.");
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Log, "[Private Click Measurement] About to fire an attribution request."_s);
+ m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] About to fire an attribution request."_s);
- m_networkLoadFunction(WTFMove(loadParameters), [weakThis = makeWeakPtr(*this), this](auto& error, auto& response, auto&) {
+ m_client->loadFromNetwork(WTFMove(loadParameters), [weakThis = makeWeakPtr(*this), this](auto& error, auto& response, auto&) {
if (!weakThis)
return;
if (!error.isNull()) {
- m_networkProcess->broadcastConsoleMessage(m_sessionID, MessageSource::PrivateClickMeasurement, MessageLevel::Error, makeString("[Private Click Measurement] Received error: '"_s, error.localizedDescription(), "' for ad click attribution request."_s));
+ m_client->broadcastConsoleMessage(MessageLevel::Error, makeString("[Private Click Measurement] Received error: '"_s, error.localizedDescription(), "' for ad click attribution request."_s));
}
});
}
@@ -529,12 +524,12 @@
bool PrivateClickMeasurementManager::featureEnabled() const
{
- return m_networkSession && m_networkProcess->privateClickMeasurementEnabled() && !m_sessionID.isEphemeral();
+ return m_client->featureEnabled();
}
bool PrivateClickMeasurementManager::debugModeEnabled() const
{
- return m_networkProcess->privateClickMeasurementDebugModeEnabled() && !m_sessionID.isEphemeral();
+ return m_client->debugModeEnabled();
}
void PrivateClickMeasurementManager::markAttributedPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&& completionHandler)
Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h (281943 => 281944)
--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h 2021-09-02 18:53:37 UTC (rev 281943)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurementManager.h 2021-09-02 18:57:34 UTC (rev 281944)
@@ -27,6 +27,7 @@
#include "NetworkLoadParameters.h"
#include "NetworkProcess.h"
+#include "PrivateClickMeasurementClient.h"
#include "PrivateClickMeasurementStore.h"
#include <WebCore/PrivateClickMeasurement.h>
#include <WebCore/RegistrableDomain.h>
@@ -49,11 +50,10 @@
using AttributionDestinationSite = WebCore::PrivateClickMeasurement::AttributionDestinationSite;
using AttributionTriggerData = WebCore::PrivateClickMeasurement::AttributionTriggerData;
- using NetworkLoadCallback = CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&, const RefPtr<JSON::Object>&)>;
using PrivateClickMeasurement = WebCore::PrivateClickMeasurement;
using RegistrableDomain = WebCore::RegistrableDomain;
using SourceSite = WebCore::PrivateClickMeasurement::SourceSite;
- explicit PrivateClickMeasurementManager(NetworkSession&, NetworkProcess&, PAL::SessionID, const String& storageDirectory, Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)>&&);
+ explicit PrivateClickMeasurementManager(UniqueRef<PCM::Client>&&, const String& storageDirectory);
void storeUnattributed(PrivateClickMeasurement&&);
void handleAttribution(AttributionTriggerData&&, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest);
@@ -94,12 +94,9 @@
bool m_isRunningEphemeralMeasurementTest { false };
std::optional<URL> m_tokenPublicKeyURLForTesting;
std::optional<URL> m_tokenSignatureURLForTesting;
- WeakPtr<NetworkSession> m_networkSession;
- Ref<NetworkProcess> m_networkProcess;
- PAL::SessionID m_sessionID;
mutable RefPtr<PCM::Store> m_store;
String m_storageDirectory;
- Function<void(NetworkLoadParameters&&, NetworkLoadCallback&&)> m_networkLoadFunction;
+ UniqueRef<PCM::Client> m_client;
struct AttributionReportTestConfig {
URL attributionReportSourceURL;
Modified: trunk/Source/WebKit/Sources.txt (281943 => 281944)
--- trunk/Source/WebKit/Sources.txt 2021-09-02 18:53:37 UTC (rev 281943)
+++ trunk/Source/WebKit/Sources.txt 2021-09-02 18:57:34 UTC (rev 281944)
@@ -99,6 +99,7 @@
NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp
NetworkProcess/IndexedDB/WebIDBServer.cpp
+NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp
NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp
NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDebugInfo.cpp
NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (281943 => 281944)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-09-02 18:53:37 UTC (rev 281943)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-09-02 18:57:34 UTC (rev 281944)
@@ -4553,6 +4553,9 @@
5CB7AFE423C67D6400E49CF3 /* APIResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIResourceLoadInfo.h; sourceTree = "<group>"; };
5CB7AFE523C67DF900E49CF3 /* _WKResourceLoadInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKResourceLoadInfoInternal.h; sourceTree = "<group>"; };
5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadInfo.h; sourceTree = "<group>"; };
+ 5CB930BF26E0542E0032B1C0 /* PrivateClickMeasurementClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementClient.h; sourceTree = "<group>"; };
+ 5CB930C026E0542F0032B1C0 /* PrivateClickMeasurementClientImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementClientImpl.cpp; sourceTree = "<group>"; };
+ 5CB930C126E054B80032B1C0 /* PrivateClickMeasurementClientImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementClientImpl.h; sourceTree = "<group>"; };
5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTask.h; sourceTree = "<group>"; };
5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkDataTaskCocoa.mm; sourceTree = "<group>"; };
5CBE908F26D7FB62005A2E95 /* PrivateClickMeasurementDebugInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementDebugInfo.h; sourceTree = "<group>"; };
@@ -9262,6 +9265,9 @@
5C01BC3526D46AD400FEB42F /* PrivateClickMeasurement */ = {
isa = PBXGroup;
children = (
+ 5CB930BF26E0542E0032B1C0 /* PrivateClickMeasurementClient.h */,
+ 5CB930C026E0542F0032B1C0 /* PrivateClickMeasurementClientImpl.cpp */,
+ 5CB930C126E054B80032B1C0 /* PrivateClickMeasurementClientImpl.h */,
5C826D6A26D482EA008AEC91 /* PrivateClickMeasurementDatabase.cpp */,
5C826D6926D482EA008AEC91 /* PrivateClickMeasurementDatabase.h */,
5CBE909026D7FB7C005A2E95 /* PrivateClickMeasurementDebugInfo.cpp */,
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes