Diff
Modified: trunk/Source/WebCore/ChangeLog (288415 => 288416)
--- trunk/Source/WebCore/ChangeLog 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/ChangeLog 2022-01-23 05:20:57 UTC (rev 288416)
@@ -1,3 +1,48 @@
+2022-01-22 Ben Nham <n...@apple.com>
+
+ Add PushSubscriptionIdentifier
+ https://bugs.webkit.org/show_bug.cgi?id=234797
+
+ Reviewed by Darin Adler.
+
+ This adds a PushSubscriptionIdentifier to each PushSubscription. Implementation-wise, it
+ will be the rowid if the subscription in the subscription database. We need this so that
+ PushSubscription.unsubscribe only unsubscribes from the given subscription. Currently it
+ unsubscribes from any active subscription associated with the subscription's service worker
+ scope.
+
+ No new tests. I plan on adding a test for this case in an API test which will work with real
+ PushSubscription objects when I submit the patch that implements the subscription business
+ logic in webpushd. The current layout tests only work with fake PushSubscription objects
+ that aren't connected to webpushd.
+
+ * Headers.cmake:
+ * Modules/push-api/PushSubscription.cpp:
+ (WebCore::PushSubscription::unsubscribe):
+ * Modules/push-api/PushSubscriptionData.cpp:
+ (WebCore::PushSubscriptionData::isolatedCopy const):
+ * Modules/push-api/PushSubscriptionData.h:
+ (WebCore::PushSubscriptionData::encode const):
+ (WebCore::PushSubscriptionData::decode):
+ webpushd only supports modern decoding and we need to send this object to it, so use modern decoding.
+
+ * Modules/push-api/PushSubscriptionIdentifier.h:
+ * WebCore.xcodeproj/project.pbxproj:
+ * testing/Internals.cpp:
+ (WebCore::Internals::createPushSubscription):
+ * testing/ServiceWorkerInternals.cpp:
+ (WebCore::ServiceWorkerInternals::createPushSubscription):
+ * workers/service/SWClientConnection.h:
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::unsubscribeFromPushService):
+ * workers/service/ServiceWorkerContainer.h:
+ * workers/service/ServiceWorkerRegistration.cpp:
+ (WebCore::ServiceWorkerRegistration::unsubscribeFromPushService):
+ * workers/service/ServiceWorkerRegistration.h:
+ * workers/service/WorkerSWClientConnection.cpp:
+ (WebCore::WorkerSWClientConnection::unsubscribeFromPushService):
+ * workers/service/WorkerSWClientConnection.h:
+
2022-01-22 Alan Bujtas <za...@apple.com>
REGRESSION(r280887) broke some svg based chart content repaint
Modified: trunk/Source/WebCore/Headers.cmake (288415 => 288416)
--- trunk/Source/WebCore/Headers.cmake 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/Headers.cmake 2022-01-23 05:20:57 UTC (rev 288416)
@@ -296,6 +296,7 @@
Modules/push-api/PushMessageCrypto.h
Modules/push-api/PushPermissionState.h
Modules/push-api/PushSubscriptionData.h
+ Modules/push-api/PushSubscriptionIdentifier.h
Modules/speech/SpeechRecognitionCaptureSource.h
Modules/speech/SpeechRecognitionCaptureSourceImpl.h
Modified: trunk/Source/WebCore/Modules/push-api/PushSubscription.cpp (288415 => 288416)
--- trunk/Source/WebCore/Modules/push-api/PushSubscription.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/Modules/push-api/PushSubscription.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -106,13 +106,13 @@
void PushSubscription::unsubscribe(ScriptExecutionContext& scriptExecutionContext, DOMPromiseDeferred<IDLBoolean>&& promise)
{
- scriptExecutionContext.eventLoop().queueTask(TaskSource::Networking, [this, protectedThis = Ref { *this }, promise = WTFMove(promise)]() mutable {
+ scriptExecutionContext.eventLoop().queueTask(TaskSource::Networking, [this, protectedThis = Ref { *this }, pushSubscriptionIdentifier = m_data.identifier, promise = WTFMove(promise)]() mutable {
if (!m_serviceWorkerRegistration) {
promise.resolve(false);
return;
}
- m_serviceWorkerRegistration->unsubscribeFromPushService(WTFMove(promise));
+ m_serviceWorkerRegistration->unsubscribeFromPushService(pushSubscriptionIdentifier, WTFMove(promise));
});
}
Modified: trunk/Source/WebCore/Modules/push-api/PushSubscriptionData.cpp (288415 => 288416)
--- trunk/Source/WebCore/Modules/push-api/PushSubscriptionData.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/Modules/push-api/PushSubscriptionData.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -33,6 +33,7 @@
PushSubscriptionData PushSubscriptionData::isolatedCopy() const
{
PushSubscriptionData result;
+ result.identifier = identifier;
result.endpoint = endpoint.isolatedCopy();
result.expirationTime = expirationTime;
result.serverVAPIDPublicKey = serverVAPIDPublicKey;
Modified: trunk/Source/WebCore/Modules/push-api/PushSubscriptionData.h (288415 => 288416)
--- trunk/Source/WebCore/Modules/push-api/PushSubscriptionData.h 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/Modules/push-api/PushSubscriptionData.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -28,6 +28,7 @@
#if ENABLE(SERVICE_WORKER)
#include "EpochTimeStamp.h"
+#include "PushSubscriptionIdentifier.h"
#include <wtf/text/WTFString.h>
@@ -34,6 +35,7 @@
namespace WebCore {
struct PushSubscriptionData {
+ PushSubscriptionIdentifier identifier;
String endpoint;
std::optional<WebCore::EpochTimeStamp> expirationTime;
Vector<uint8_t> serverVAPIDPublicKey;
@@ -49,6 +51,7 @@
template<class Encoder>
void PushSubscriptionData::encode(Encoder& encoder) const
{
+ encoder << identifier;
encoder << endpoint;
encoder << expirationTime;
encoder << serverVAPIDPublicKey;
@@ -59,18 +62,37 @@
template<class Decoder>
std::optional<PushSubscriptionData> PushSubscriptionData::decode(Decoder& decoder)
{
- PushSubscriptionData result;
- if (!decoder.decode(result.endpoint))
+ std::optional<PushSubscriptionIdentifier> identifier;
+ decoder >> identifier;
+ if (!identifier)
return std::nullopt;
- if (!decoder.decode(result.expirationTime))
+
+ std::optional<String> endpoint;
+ decoder >> endpoint;
+ if (!endpoint)
return std::nullopt;
- if (!decoder.decode(result.serverVAPIDPublicKey))
+
+ std::optional<std::optional<WebCore::EpochTimeStamp>> expirationTime;
+ decoder >> expirationTime;
+ if (!expirationTime)
return std::nullopt;
- if (!decoder.decode(result.clientECDHPublicKey))
+
+ std::optional<Vector<uint8_t>> serverVAPIDPublicKey;
+ decoder >> serverVAPIDPublicKey;
+ if (!serverVAPIDPublicKey)
return std::nullopt;
- if (!decoder.decode(result.sharedAuthenticationSecret))
+
+ std::optional<Vector<uint8_t>> clientECDHPublicKey;
+ decoder >> clientECDHPublicKey;
+ if (!clientECDHPublicKey)
return std::nullopt;
- return result;
+
+ std::optional<Vector<uint8_t>> sharedAuthenticationSecret;
+ decoder >> sharedAuthenticationSecret;
+ if (!sharedAuthenticationSecret)
+ return std::nullopt;
+
+ return PushSubscriptionData { WTFMove(*identifier), WTFMove(*endpoint), WTFMove(*expirationTime), WTFMove(*serverVAPIDPublicKey), WTFMove(*clientECDHPublicKey), WTFMove(*sharedAuthenticationSecret) };
}
} // namespace WebCore
Copied: trunk/Source/WebCore/Modules/push-api/PushSubscriptionIdentifier.h (from rev 288415, trunk/Source/WebCore/Modules/push-api/PushSubscriptionData.cpp) (0 => 288416)
--- trunk/Source/WebCore/Modules/push-api/PushSubscriptionIdentifier.h (rev 0)
+++ trunk/Source/WebCore/Modules/push-api/PushSubscriptionIdentifier.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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/ObjectIdentifier.h>
+
+namespace WebCore {
+
+enum PushSubscriptionIdentifierType { };
+using PushSubscriptionIdentifier = ObjectIdentifier<PushSubscriptionIdentifierType>;
+
+}
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (288415 => 288416)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-01-23 05:20:57 UTC (rev 288416)
@@ -5469,6 +5469,7 @@
EBB9738127100671007732EF /* PushManager.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB9738027100654007732EF /* PushManager.h */; };
EBB9738227100676007732EF /* PushPermissionState.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB9737827100651007732EF /* PushPermissionState.h */; settings = {ATTRIBUTES = (Private, ); }; };
EBB9738327100684007732EF /* ServiceWorkerRegistrationPushAPI.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB9737A27100652007732EF /* ServiceWorkerRegistrationPushAPI.h */; };
+ EBE095E5277D14DA00804D61 /* PushSubscriptionIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = EBE095E3277D14C700804D61 /* PushSubscriptionIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
EBE5B226245A26EF003A5A88 /* SQLiteStatementAutoResetScope.h in Headers */ = {isa = PBXBuildFile; fileRef = EBE5B224245A26EE003A5A88 /* SQLiteStatementAutoResetScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBF5121A1696496C0056BD25 /* JSTypeConversions.cpp */; };
EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */ = {isa = PBXBuildFile; fileRef = EBF5121B1696496C0056BD25 /* JSTypeConversions.h */; };
@@ -17689,6 +17690,7 @@
EBB9737E27100653007732EF /* PushManager.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushManager.idl; sourceTree = "<group>"; };
EBB9737F27100653007732EF /* PushPermissionState.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PushPermissionState.idl; sourceTree = "<group>"; };
EBB9738027100654007732EF /* PushManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushManager.h; sourceTree = "<group>"; };
+ EBE095E3277D14C700804D61 /* PushSubscriptionIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushSubscriptionIdentifier.h; sourceTree = "<group>"; };
EBE5B224245A26EE003A5A88 /* SQLiteStatementAutoResetScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLiteStatementAutoResetScope.h; sourceTree = "<group>"; };
EBE5B227245A29CF003A5A88 /* SQLiteStatementAutoResetScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteStatementAutoResetScope.cpp; sourceTree = "<group>"; };
EBF5121A1696496C0056BD25 /* JSTypeConversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTypeConversions.cpp; sourceTree = "<group>"; };
@@ -21199,6 +21201,7 @@
EB3C29B22729C36E00FB65B4 /* PushSubscriptionChangeEventInit.idl */,
EB28ED432717ABA9005F0393 /* PushSubscriptionData.cpp */,
EB28ED412717ABA9005F0393 /* PushSubscriptionData.h */,
+ EBE095E3277D14C700804D61 /* PushSubscriptionIdentifier.h */,
EB0FB703270D0AEB00F7810D /* PushSubscriptionJSON.h */,
EB0FB702270D0AEA00F7810D /* PushSubscriptionJSON.idl */,
EB0FB6FB270D0AE600F7810D /* PushSubscriptionOptions.cpp */,
@@ -36616,6 +36619,7 @@
EB3C29B62729C38800FB65B4 /* PushSubscriptionChangeEvent.h in Headers */,
EB3C29B72729C38C00FB65B4 /* PushSubscriptionChangeEventInit.h in Headers */,
EB28ED442717AC11005F0393 /* PushSubscriptionData.h in Headers */,
+ EBE095E5277D14DA00804D61 /* PushSubscriptionIdentifier.h in Headers */,
EB0FB70A270D0B1B00F7810D /* PushSubscriptionJSON.h in Headers */,
EB0FB70C270D0B2900F7810D /* PushSubscriptionOptions.h in Headers */,
EB0FB70D270D0B2E00F7810D /* PushSubscriptionOptionsInit.h in Headers */,
Modified: trunk/Source/WebCore/testing/Internals.cpp (288415 => 288416)
--- trunk/Source/WebCore/testing/Internals.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/testing/Internals.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -6630,7 +6630,7 @@
Vector<uint8_t> myClientECDHPublicKey { static_cast<const uint8_t*>(clientECDHPublicKey.data()), clientECDHPublicKey.byteLength() };
Vector<uint8_t> myAuth { static_cast<const uint8_t*>(auth.data()), auth.byteLength() };
- return PushSubscription::create(PushSubscriptionData { WTFMove(myEndpoint), expirationTime, WTFMove(myServerVAPIDPublicKey), WTFMove(myClientECDHPublicKey), WTFMove(myAuth) });
+ return PushSubscription::create(PushSubscriptionData { { }, WTFMove(myEndpoint), expirationTime, WTFMove(myServerVAPIDPublicKey), WTFMove(myClientECDHPublicKey), WTFMove(myAuth) });
}
#endif
Modified: trunk/Source/WebCore/testing/ServiceWorkerInternals.cpp (288415 => 288416)
--- trunk/Source/WebCore/testing/ServiceWorkerInternals.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/testing/ServiceWorkerInternals.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -186,7 +186,7 @@
Vector<uint8_t> myClientECDHPublicKey { static_cast<const uint8_t*>(clientECDHPublicKey.data()), clientECDHPublicKey.byteLength() };
Vector<uint8_t> myAuth { static_cast<const uint8_t*>(auth.data()), auth.byteLength() };
- return PushSubscription::create(PushSubscriptionData { WTFMove(myEndpoint), expirationTime, WTFMove(myServerVAPIDPublicKey), WTFMove(myClientECDHPublicKey), WTFMove(myAuth) });
+ return PushSubscription::create(PushSubscriptionData { { }, WTFMove(myEndpoint), expirationTime, WTFMove(myServerVAPIDPublicKey), WTFMove(myClientECDHPublicKey), WTFMove(myAuth) });
}
bool ServiceWorkerInternals::fetchEventIsSameSite(FetchEvent& event)
Modified: trunk/Source/WebCore/workers/service/SWClientConnection.h (288415 => 288416)
--- trunk/Source/WebCore/workers/service/SWClientConnection.h 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -93,7 +93,7 @@
virtual void subscribeToPushService(ServiceWorkerRegistrationIdentifier, const Vector<uint8_t>& applicationServerKey, SubscribeToPushServiceCallback&&) = 0;
using UnsubscribeFromPushServiceCallback = CompletionHandler<void(ExceptionOr<bool>&&)>;
- virtual void unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier, UnsubscribeFromPushServiceCallback&&) = 0;
+ virtual void unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier, PushSubscriptionIdentifier, UnsubscribeFromPushServiceCallback&&) = 0;
using GetPushSubscriptionCallback = CompletionHandler<void(ExceptionOr<std::optional<PushSubscriptionData>>&&)>;
virtual void getPushSubscription(ServiceWorkerRegistrationIdentifier, GetPushSubscriptionCallback&&) = 0;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (288415 => 288416)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -570,9 +570,9 @@
});
}
-void ServiceWorkerContainer::unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier identifier, DOMPromiseDeferred<IDLBoolean>&& promise)
+void ServiceWorkerContainer::unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier identifier, PushSubscriptionIdentifier subscriptionIdentifier, DOMPromiseDeferred<IDLBoolean>&& promise)
{
- ensureSWClientConnection().unsubscribeFromPushService(identifier, [promise = WTFMove(promise)](auto&& result) mutable {
+ ensureSWClientConnection().unsubscribeFromPushService(identifier, subscriptionIdentifier, [promise = WTFMove(promise)](auto&& result) mutable {
promise.settle(WTFMove(result));
});
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (288415 => 288416)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -88,7 +88,7 @@
void removeRegistration(ServiceWorkerRegistration&);
void subscribeToPushService(ServiceWorkerRegistration&, const Vector<uint8_t>& applicationServerKey, DOMPromiseDeferred<IDLInterface<PushSubscription>>&&);
- void unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier, DOMPromiseDeferred<IDLBoolean>&&);
+ void unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier, PushSubscriptionIdentifier, DOMPromiseDeferred<IDLBoolean>&&);
void getPushSubscription(ServiceWorkerRegistration&, DOMPromiseDeferred<IDLNullable<IDLInterface<PushSubscription>>>&&);
void getPushPermissionState(ServiceWorkerRegistrationIdentifier, DOMPromiseDeferred<IDLEnumeration<PushPermissionState>>&&);
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp (288415 => 288416)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -173,7 +173,7 @@
m_container->subscribeToPushService(*this, applicationServerKey, WTFMove(promise));
}
-void ServiceWorkerRegistration::unsubscribeFromPushService(DOMPromiseDeferred<IDLBoolean>&& promise)
+void ServiceWorkerRegistration::unsubscribeFromPushService(PushSubscriptionIdentifier subscriptionIdentifier, DOMPromiseDeferred<IDLBoolean>&& promise)
{
if (isContextStopped()) {
promise.reject(Exception(InvalidStateError));
@@ -180,7 +180,7 @@
return;
}
- m_container->unsubscribeFromPushService(identifier(), WTFMove(promise));
+ m_container->unsubscribeFromPushService(identifier(), subscriptionIdentifier, WTFMove(promise));
}
void ServiceWorkerRegistration::getPushSubscription(DOMPromiseDeferred<IDLNullable<IDLInterface<PushSubscription>>>&& promise)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h (288415 => 288416)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -75,7 +75,7 @@
void unregister(Ref<DeferredPromise>&&);
void subscribeToPushService(const Vector<uint8_t>& applicationServerKey, DOMPromiseDeferred<IDLInterface<PushSubscription>>&&);
- void unsubscribeFromPushService(DOMPromiseDeferred<IDLBoolean>&&);
+ void unsubscribeFromPushService(PushSubscriptionIdentifier, DOMPromiseDeferred<IDLBoolean>&&);
void getPushSubscription(DOMPromiseDeferred<IDLNullable<IDLInterface<PushSubscription>>>&&);
void getPushPermissionState(DOMPromiseDeferred<IDLEnumeration<PushPermissionState>>&&);
Modified: trunk/Source/WebCore/workers/service/WorkerSWClientConnection.cpp (288415 => 288416)
--- trunk/Source/WebCore/workers/service/WorkerSWClientConnection.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/workers/service/WorkerSWClientConnection.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -245,14 +245,14 @@
});
}
-void WorkerSWClientConnection::unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier registrationIdentifier, UnsubscribeFromPushServiceCallback&& callback)
+void WorkerSWClientConnection::unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier registrationIdentifier, PushSubscriptionIdentifier subscriptionIdentifier, UnsubscribeFromPushServiceCallback&& callback)
{
uint64_t requestIdentifier = ++m_lastRequestIdentifier;
m_unsubscribeFromPushServiceRequests.add(requestIdentifier, WTFMove(callback));
- callOnMainThread([thread = m_thread, requestIdentifier, registrationIdentifier]() mutable {
+ callOnMainThread([thread = m_thread, requestIdentifier, registrationIdentifier, subscriptionIdentifier]() mutable {
auto& connection = ServiceWorkerProvider::singleton().serviceWorkerConnection();
- connection.unsubscribeFromPushService(registrationIdentifier, [thread = WTFMove(thread), requestIdentifier](auto&& result) {
+ connection.unsubscribeFromPushService(registrationIdentifier, subscriptionIdentifier, [thread = WTFMove(thread), requestIdentifier](auto&& result) {
thread->runLoop().postTaskForMode([requestIdentifier, result = crossThreadCopy(result)](auto& scope) mutable {
auto callback = downcast<WorkerGlobalScope>(scope).swClientConnection().m_unsubscribeFromPushServiceRequests.take(requestIdentifier);
callback(WTFMove(result));
Modified: trunk/Source/WebCore/workers/service/WorkerSWClientConnection.h (288415 => 288416)
--- trunk/Source/WebCore/workers/service/WorkerSWClientConnection.h 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebCore/workers/service/WorkerSWClientConnection.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -58,7 +58,7 @@
void scheduleJob(ServiceWorkerOrClientIdentifier, const ServiceWorkerJobData&) final;
void scheduleUnregisterJobInServer(ServiceWorkerRegistrationIdentifier, ServiceWorkerOrClientIdentifier, CompletionHandler<void(ExceptionOr<bool>&&)>&&) final;
void subscribeToPushService(ServiceWorkerRegistrationIdentifier, const Vector<uint8_t>& applicationServerKey, SubscribeToPushServiceCallback&&) final;
- void unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier, UnsubscribeFromPushServiceCallback&&) final;
+ void unsubscribeFromPushService(ServiceWorkerRegistrationIdentifier, PushSubscriptionIdentifier, UnsubscribeFromPushServiceCallback&&) final;
void getPushSubscription(ServiceWorkerRegistrationIdentifier, GetPushSubscriptionCallback&&) final;
void getPushPermissionState(ServiceWorkerRegistrationIdentifier, GetPushPermissionStateCallback&&) final;
Modified: trunk/Source/WebKit/ChangeLog (288415 => 288416)
--- trunk/Source/WebKit/ChangeLog 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebKit/ChangeLog 2022-01-23 05:20:57 UTC (rev 288416)
@@ -1,3 +1,24 @@
+2022-01-22 Ben Nham <n...@apple.com>
+
+ Add PushSubscriptionIdentifier
+ https://bugs.webkit.org/show_bug.cgi?id=234797
+
+ Reviewed by Darin Adler.
+
+ Pass the subscription identifier in the PushSubscription.unsubscribe call to guarantee that
+ we only unsubscribe from the given subscription.
+
+ * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::unsubscribeFromPushService):
+ * NetworkProcess/ServiceWorker/WebSWServerConnection.h:
+ * NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in:
+ * Scripts/webkit/messages.py:
+ (types_that_cannot_be_forward_declared):
+ (headers_for_type):
+ * WebProcess/Storage/WebSWClientConnection.cpp:
+ (WebKit::WebSWClientConnection::unsubscribeFromPushService):
+ * WebProcess/Storage/WebSWClientConnection.h:
+
2022-01-22 Said Abou-Hallawa <s...@apple.com>
[GPU Process] Add the class 'SourceImage' to represent variants of image
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp (288415 => 288416)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -448,32 +448,23 @@
}
}
-void WebSWServerConnection::subscribeToPushService(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, Vector<uint8_t>&& applicationServerKey, CompletionHandler<void(Expected<PushSubscriptionData, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::subscribeToPushService(WebCore::ServiceWorkerRegistrationIdentifier, Vector<uint8_t>&&, CompletionHandler<void(Expected<PushSubscriptionData, ExceptionData>&&)>&& completionHandler)
{
- UNUSED_PARAM(registrationIdentifier);
- UNUSED_PARAM(applicationServerKey);
-
completionHandler(makeUnexpected(ExceptionData { NotAllowedError, "Push permission was denied"_s }));
}
-void WebSWServerConnection::unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, CompletionHandler<void(Expected<bool, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::PushSubscriptionIdentifier, CompletionHandler<void(Expected<bool, ExceptionData>&&)>&& completionHandler)
{
- UNUSED_PARAM(registrationIdentifier);
-
completionHandler(false);
}
-void WebSWServerConnection::getPushSubscription(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, CompletionHandler<void(Expected<std::optional<PushSubscriptionData>, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::getPushSubscription(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<std::optional<PushSubscriptionData>, ExceptionData>&&)>&& completionHandler)
{
- UNUSED_PARAM(registrationIdentifier);
-
completionHandler(std::optional<PushSubscriptionData>(std::nullopt));
}
-void WebSWServerConnection::getPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, CompletionHandler<void(Expected<uint8_t, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::getPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<uint8_t, ExceptionData>&&)>&& completionHandler)
{
- UNUSED_PARAM(registrationIdentifier);
-
completionHandler(static_cast<uint8_t>(PushPermissionState::Denied));
}
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h (288415 => 288416)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -122,7 +122,7 @@
void updateThrottleState();
void subscribeToPushService(WebCore::ServiceWorkerRegistrationIdentifier, Vector<uint8_t>&& applicationServerKey, CompletionHandler<void(Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&&)>&&);
- void unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<bool, WebCore::ExceptionData>&&)>&&);
+ void unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::PushSubscriptionIdentifier, CompletionHandler<void(Expected<bool, WebCore::ExceptionData>&&)>&&);
void getPushSubscription(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&&)>&&);
void getPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<uint8_t, WebCore::ExceptionData>&&)>&&);
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in (288415 => 288416)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in 2022-01-23 05:20:57 UTC (rev 288416)
@@ -48,7 +48,7 @@
StoreRegistrationsOnDisk() -> () Async
SubscribeToPushService(WebCore::ServiceWorkerRegistrationIdentifier identifier, Vector<uint8_t> applicationServerKey) -> (Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData> result) Async
- UnsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier identifier) -> (Expected<bool, WebCore::ExceptionData> result) Async
+ UnsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier serviceWorkerRegistrationIdentifier, WebCore::PushSubscriptionIdentifier pushSubscriptionIdentifier) -> (Expected<bool, WebCore::ExceptionData> result) Async
GetPushSubscription(WebCore::ServiceWorkerRegistrationIdentifier identifier) -> (Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData> result) Async
GetPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier identifier) -> (Expected<uint8_t, WebCore::ExceptionData> result) Async
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (288415 => 288416)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2022-01-23 05:20:57 UTC (rev 288416)
@@ -289,6 +289,7 @@
'WebCore::PlaybackTargetClientContextIdentifier',
'WebCore::PluginLoadClientPolicy',
'WebCore::PointerID',
+ 'WebCore::PushSubscriptionIdentifier',
'WebCore::ProcessIdentifier',
'WebCore::RealtimeMediaSourceIdentifier',
'WebCore::RenderingMode',
@@ -817,6 +818,7 @@
'WebCore::PolicyCheckIdentifier': ['<WebCore/FrameLoaderTypes.h>'],
'WebCore::PreserveResolution': ['<WebCore/ImageBufferBackend.h>'],
'WebCore::ProcessIdentifier': ['<WebCore/ProcessIdentifier.h>'],
+ 'WebCore::PushSubscriptionIdentifier': ['<WebCore/PushSubscriptionIdentifier.h>'],
'WebCore::QuadCurveData': ['<WebCore/InlinePathData.h>'],
'WebCore::RecentSearch': ['<WebCore/SearchPopupMenu.h>'],
'WebCore::RequestStorageAccessResult': ['<WebCore/DocumentStorageAccess.h>'],
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (288415 => 288416)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp 2022-01-23 05:20:57 UTC (rev 288416)
@@ -238,9 +238,9 @@
});
}
-void WebSWClientConnection::unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, UnsubscribeFromPushServiceCallback&& callback)
+void WebSWClientConnection::unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, WebCore::PushSubscriptionIdentifier subscriptionIdentifier, UnsubscribeFromPushServiceCallback&& callback)
{
- sendWithAsyncReply(Messages::WebSWServerConnection::UnsubscribeFromPushService { registrationIdentifier }, [callback = WTFMove(callback)](auto&& result) mutable {
+ sendWithAsyncReply(Messages::WebSWServerConnection::UnsubscribeFromPushService { registrationIdentifier, subscriptionIdentifier }, [callback = WTFMove(callback)](auto&& result) mutable {
if (!result.has_value())
return callback(result.error().toException());
callback(*result);
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (288415 => 288416)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h 2022-01-23 05:01:37 UTC (rev 288415)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h 2022-01-23 05:20:57 UTC (rev 288416)
@@ -91,7 +91,7 @@
void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&&) final;
void subscribeToPushService(WebCore::ServiceWorkerRegistrationIdentifier, const Vector<uint8_t>& applicationServerKey, SubscribeToPushServiceCallback&&) final;
- void unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier, UnsubscribeFromPushServiceCallback&&) final;
+ void unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::PushSubscriptionIdentifier, UnsubscribeFromPushServiceCallback&&) final;
void getPushSubscription(WebCore::ServiceWorkerRegistrationIdentifier, GetPushSubscriptionCallback&&) final;
void getPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier, GetPushPermissionStateCallback&&) final;