Diff
Modified: trunk/Source/WebCore/ChangeLog (283027 => 283028)
--- trunk/Source/WebCore/ChangeLog 2021-09-24 06:52:53 UTC (rev 283027)
+++ trunk/Source/WebCore/ChangeLog 2021-09-24 07:11:46 UTC (rev 283028)
@@ -1,3 +1,32 @@
+2021-09-24 Youenn Fablet <you...@apple.com>
+
+ DOMPromiseDeferred should be able to handle Ref/RefPtr resolution values for interface types
+ https://bugs.webkit.org/show_bug.cgi?id=230603
+
+ Reviewed by Sihui Liu.
+
+ Refactoring to allow DOMPromiseDeferred<IDLInterface<T>> to be able to call settle on ExceptionOr<Ref<T>>&&.
+ Apply new support on PeerConnectionBackend::generateCertificate.
+ Small refactoring to use reject instead of settle in ApplePaySetup.
+ No expected change of behavior.
+
+ * Modules/applepay/ApplePaySetup.cpp:
+ (WebCore::ApplePaySetup::getSetupFeatures):
+ (WebCore::ApplePaySetup::begin):
+ * Modules/mediastream/PeerConnectionBackend.cpp:
+ (WebCore::PeerConnectionBackend::generateCertificate):
+ * Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.cpp:
+ (WebCore::LibWebRTCCertificateGenerator::RTCCertificateGeneratorCallback::RTCCertificateGeneratorCallback):
+ (WebCore::LibWebRTCCertificateGenerator::generateCertificate):
+ * Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.h:
+ * bindings/js/JSDOMPromiseDeferred.h:
+ (WebCore::DOMPromiseDeferred::resolve):
+ (WebCore::DOMPromiseDeferred::settle):
+ (WebCore::DOMPromiseDeferred<IDLInterface<T>>::resolve):
+ (WebCore::DOMPromiseDeferred<IDLInterface<T>>::settle):
+ * testing/Internals.cpp:
+ (WebCore::Internals::sendH2Ping):
+
2021-09-23 Rob Buis <rb...@igalia.com>
RenderElement::moveLayers should take reference
Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySetup.cpp (283027 => 283028)
--- trunk/Source/WebCore/Modules/applepay/ApplePaySetup.cpp 2021-09-24 06:52:53 UTC (rev 283027)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySetup.cpp 2021-09-24 07:11:46 UTC (rev 283028)
@@ -59,12 +59,12 @@
auto page = document.page();
if (!page) {
- promise.settle(Exception { InvalidStateError });
+ promise.reject(Exception { InvalidStateError });
return;
}
if (m_setupFeaturesPromise) {
- promise.settle(Exception { InvalidStateError });
+ promise.reject(Exception { InvalidStateError });
return;
}
@@ -91,18 +91,18 @@
}
if (!UserGestureIndicator::processingUserGesture()) {
- promise.settle(Exception { InvalidAccessError, "Must call ApplePaySetup.begin from a user gesture handler." });
+ promise.reject(Exception { InvalidAccessError, "Must call ApplePaySetup.begin from a user gesture handler." });
return;
}
auto page = document.page();
if (!page) {
- promise.settle(Exception { InvalidStateError });
+ promise.reject(Exception { InvalidStateError });
return;
}
if (m_beginPromise) {
- promise.settle(Exception { InvalidStateError });
+ promise.reject(Exception { InvalidStateError });
return;
}
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (283027 => 283028)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2021-09-24 06:52:53 UTC (rev 283027)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2021-09-24 07:11:46 UTC (rev 283028)
@@ -35,6 +35,7 @@
#if ENABLE(WEB_RTC)
#include "EventNames.h"
+#include "JSRTCCertificate.h"
#include "LibWebRTCCertificateGenerator.h"
#include "Logging.h"
#include "Page.h"
@@ -435,7 +436,9 @@
promise.reject(InvalidStateError);
return;
}
- LibWebRTCCertificateGenerator::generateCertificate(document.securityOrigin(), page->libWebRTCProvider(), info, WTFMove(promise));
+ LibWebRTCCertificateGenerator::generateCertificate(document.securityOrigin(), page->libWebRTCProvider(), info, [promise = WTFMove(promise)](auto&& result) mutable {
+ promise.settle(WTFMove(result));
+ });
#else
UNUSED_PARAM(document);
UNUSED_PARAM(expires);
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.cpp (283027 => 283028)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.cpp 2021-09-24 06:52:53 UTC (rev 283027)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.cpp 2021-09-24 07:11:46 UTC (rev 283028)
@@ -27,8 +27,6 @@
#if USE(LIBWEBRTC)
-#include "JSDOMPromiseDeferred.h"
-#include "JSRTCCertificate.h"
#include "LibWebRTCMacros.h"
#include "RTCCertificate.h"
@@ -49,9 +47,9 @@
class RTCCertificateGeneratorCallback : public ThreadSafeRefCounted<RTCCertificateGeneratorCallback, WTF::DestructionThread::Main>, public rtc::RTCCertificateGeneratorCallback {
public:
- RTCCertificateGeneratorCallback(Ref<SecurityOrigin>&& origin, DOMPromiseDeferred<IDLInterface<RTCCertificate>>&& promise)
+ RTCCertificateGeneratorCallback(Ref<SecurityOrigin>&& origin, Function<void(ExceptionOr<Ref<RTCCertificate>>&&)>&& resultCallback)
: m_origin(WTFMove(origin))
- , m_promise(WTFMove(promise))
+ , m_resultCallback(WTFMove(resultCallback))
{
}
@@ -66,7 +64,7 @@
private:
void OnSuccess(const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) final
{
- callOnMainThread([origin = m_origin.releaseNonNull(), promise = WTFMove(m_promise.value()), certificate]() mutable {
+ callOnMainThread([origin = m_origin.releaseNonNull(), callback = WTFMove(m_resultCallback), certificate]() mutable {
Vector<RTCCertificate::DtlsFingerprint> fingerprints;
auto stats = certificate->ssl_certificate().GetStats();
auto* info = stats.get();
@@ -77,19 +75,19 @@
};
auto pem = certificate->ToPEM();
- promise.resolve(RTCCertificate::create(WTFMove(origin), certificate->Expires(), WTFMove(fingerprints), fromStdString(pem.certificate()), fromStdString(pem.private_key())));
+ callback(RTCCertificate::create(WTFMove(origin), certificate->Expires(), WTFMove(fingerprints), fromStdString(pem.certificate()), fromStdString(pem.private_key())));
});
}
void OnFailure() final
{
- callOnMainThread([promise = WTFMove(m_promise.value())]() mutable {
- promise.reject(Exception { TypeError, "Unable to create a certificate"_s});
+ callOnMainThread([callback = WTFMove(m_resultCallback)]() mutable {
+ callback(Exception { TypeError, "Unable to create a certificate"_s});
});
}
RefPtr<SecurityOrigin> m_origin;
- std::optional<DOMPromiseDeferred<IDLInterface<RTCCertificate>>> m_promise;
+ Function<void(ExceptionOr<Ref<RTCCertificate>>&&)> m_resultCallback;
};
static inline rtc::KeyParams keyParamsFromCertificateType(const PeerConnectionBackend::CertificateInformation& info)
@@ -106,9 +104,9 @@
RELEASE_ASSERT_NOT_REACHED();
}
-void generateCertificate(Ref<SecurityOrigin>&& origin, LibWebRTCProvider& provider, const PeerConnectionBackend::CertificateInformation& info, DOMPromiseDeferred<IDLInterface<RTCCertificate>>&& promise)
+void generateCertificate(Ref<SecurityOrigin>&& origin, LibWebRTCProvider& provider, const PeerConnectionBackend::CertificateInformation& info, Function<void(ExceptionOr<Ref<RTCCertificate>>&&)>&& resultCallback)
{
- rtc::scoped_refptr<RTCCertificateGeneratorCallback> callback(new rtc::RefCountedObject<RTCCertificateGeneratorCallback>(WTFMove(origin), WTFMove(promise)));
+ rtc::scoped_refptr<RTCCertificateGeneratorCallback> callback(new rtc::RefCountedObject<RTCCertificateGeneratorCallback>(WTFMove(origin), WTFMove(resultCallback)));
absl::optional<uint64_t> expiresMs;
if (info.expires)
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.h (283027 => 283028)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.h 2021-09-24 06:52:53 UTC (rev 283027)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCCertificateGenerator.h 2021-09-24 07:11:46 UTC (rev 283028)
@@ -35,7 +35,7 @@
namespace LibWebRTCCertificateGenerator {
-void generateCertificate(Ref<SecurityOrigin>&&, LibWebRTCProvider&, const PeerConnectionBackend::CertificateInformation&, DOMPromiseDeferred<IDLInterface<RTCCertificate>>&&);
+void generateCertificate(Ref<SecurityOrigin>&&, LibWebRTCProvider&, const PeerConnectionBackend::CertificateInformation&, Function<void(ExceptionOr<Ref<RTCCertificate>>&&)>&&);
} // namespace LibWebRTCCertificateGenerator
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h (283027 => 283028)
--- trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h 2021-09-24 06:52:53 UTC (rev 283027)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h 2021-09-24 07:11:46 UTC (rev 283028)
@@ -261,7 +261,7 @@
Ref<DeferredPromise> m_promise;
};
-template<typename IDLType>
+template<typename IDLType>
class DOMPromiseDeferred : public DOMPromiseDeferredBase {
public:
using DOMPromiseDeferredBase::DOMPromiseDeferredBase;
@@ -270,7 +270,7 @@
using DOMPromiseDeferredBase::reject;
void resolve(typename IDLType::ParameterType value)
- {
+ {
m_promise->resolve<IDLType>(std::forward<typename IDLType::ParameterType>(value));
}
@@ -284,6 +284,39 @@
}
};
+template<typename T>
+class DOMPromiseDeferred<IDLInterface<T>> : public DOMPromiseDeferredBase {
+public:
+ using DOMPromiseDeferredBase::DOMPromiseDeferredBase;
+ using DOMPromiseDeferredBase::operator=;
+ using DOMPromiseDeferredBase::promise;
+ using DOMPromiseDeferredBase::reject;
+ using IDLType = IDLInterface<T>;
+
+ void resolve(typename IDLType::InnerParameterType value)
+ {
+ m_promise->resolve<IDLType>(std::forward<typename IDLType::ParameterType>(value));
+ }
+
+ void settle(ExceptionOr<typename IDLType::InnerParameterType>&& result)
+ {
+ if (result.hasException()) {
+ reject(result.releaseException());
+ return;
+ }
+ resolve(result.releaseReturnValue());
+ }
+
+ void settle(ExceptionOr<typename IDLType::ParameterType>&& result)
+ {
+ if (result.hasException()) {
+ reject(result.releaseException());
+ return;
+ }
+ resolve(result.releaseReturnValue());
+ }
+};
+
template<> class DOMPromiseDeferred<void> : public DOMPromiseDeferredBase {
public:
using DOMPromiseDeferredBase::DOMPromiseDeferredBase;
Modified: trunk/Source/WebCore/testing/Internals.cpp (283027 => 283028)
--- trunk/Source/WebCore/testing/Internals.cpp 2021-09-24 06:52:53 UTC (rev 283027)
+++ trunk/Source/WebCore/testing/Internals.cpp 2021-09-24 07:11:46 UTC (rev 283028)
@@ -5587,13 +5587,13 @@
{
auto* document = contextDocument();
if (!document) {
- promise.settle(InvalidStateError);
+ promise.reject(InvalidStateError);
return;
}
auto* frame = document->frame();
if (!frame) {
- promise.settle(InvalidStateError);
+ promise.reject(InvalidStateError);
return;
}
@@ -5601,7 +5601,7 @@
if (result.has_value())
promise.resolve(result.value().value());
else
- promise.settle(InvalidStateError);
+ promise.reject(InvalidStateError);
});
}