Diff
Modified: trunk/Source/WebCore/ChangeLog (249721 => 249722)
--- trunk/Source/WebCore/ChangeLog 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/ChangeLog 2019-09-10 17:41:32 UTC (rev 249722)
@@ -1,5 +1,36 @@
2019-09-10 Youenn Fablet <you...@apple.com>
+ RTCPeerConnection can only be instantiated in documents
+ https://bugs.webkit.org/show_bug.cgi?id=201639
+
+ Reviewed by Alex Christensen.
+
+ Make it clear that RTCDataChannel expects Document since peer connections
+ and data channels can only be instantiated in document environments.
+ We keep one downcast in RTCPeerConnection constructor due to a limitation
+ in binding generator for JS built-ins.
+ No change of behavior.
+
+ * Modules/mediastream/RTCDataChannel.cpp:
+ (WebCore::RTCDataChannel::create):
+ (WebCore::RTCDataChannel::RTCDataChannel):
+ * Modules/mediastream/RTCDataChannel.h:
+ * Modules/mediastream/RTCPeerConnection.cpp:
+ (WebCore::RTCPeerConnection::create):
+ (WebCore::RTCPeerConnection::RTCPeerConnection):
+ (WebCore::RTCPeerConnection::certificatesFromConfiguration):
+ (WebCore::RTCPeerConnection::createDataChannel):
+ (WebCore::RTCPeerConnection::document):
+ * Modules/mediastream/RTCPeerConnection.h:
+ * Modules/mediastream/RTCPeerConnection.idl:
+ * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
+ (WebCore::LibWebRTCDataChannelHandler::channelEvent):
+ * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+ (WebCore::LibWebRTCMediaEndpoint::OnDataChannel):
+
+2019-09-10 Youenn Fablet <you...@apple.com>
+
Remove MediaStreamPrivate::scheduleDeferredTask
https://bugs.webkit.org/show_bug.cgi?id=200975
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2019-09-10 17:41:32 UTC (rev 249722)
@@ -53,10 +53,10 @@
return arraybuffer;
}
-Ref<RTCDataChannel> RTCDataChannel::create(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
+Ref<RTCDataChannel> RTCDataChannel::create(Document& document, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
{
ASSERT(handler);
- auto channel = adoptRef(*new RTCDataChannel(context, WTFMove(handler), WTFMove(label), WTFMove(options)));
+ auto channel = adoptRef(*new RTCDataChannel(document, WTFMove(handler), WTFMove(label), WTFMove(options)));
channel->suspendIfNeeded();
channel->m_handler->setClient(channel.get());
channel->setPendingActivity(channel.get());
@@ -78,13 +78,13 @@
} };
}
-RTCDataChannel::RTCDataChannel(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
- : ActiveDOMObject(&context)
+RTCDataChannel::RTCDataChannel(Document& document, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
+ : ActiveDOMObject(document)
, m_handler(WTFMove(handler))
, m_scheduledEventTimer(*this, &RTCDataChannel::scheduledEventTimerFired)
, m_label(WTFMove(label))
, m_options(WTFMove(options))
- , m_messageQueue(createMessageQueue(downcast<Document>(context), *this))
+ , m_messageQueue(createMessageQueue(document, *this))
{
}
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2019-09-10 17:41:32 UTC (rev 249722)
@@ -50,7 +50,7 @@
class RTCDataChannel final : public ActiveDOMObject, public RTCDataChannelHandlerClient, public EventTargetWithInlineData {
WTF_MAKE_ISO_ALLOCATED(RTCDataChannel);
public:
- static Ref<RTCDataChannel> create(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
+ static Ref<RTCDataChannel> create(Document&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
bool ordered() const { return *m_options.ordered; }
Optional<unsigned short> maxPacketLifeTime() const { return m_options.maxPacketLifeTime; }
@@ -79,7 +79,7 @@
using RTCDataChannelHandlerClient::deref;
private:
- RTCDataChannel(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
+ RTCDataChannel(Document&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
static NetworkSendQueue createMessageQueue(Document&, RTCDataChannel&);
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2019-09-10 17:41:32 UTC (rev 249722)
@@ -67,24 +67,25 @@
Ref<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context)
{
- auto peerConnection = adoptRef(*new RTCPeerConnection(context));
+ auto& document = downcast<Document>(context);
+ auto peerConnection = adoptRef(*new RTCPeerConnection(document));
peerConnection->suspendIfNeeded();
// RTCPeerConnection may send events at about any time during its lifetime.
// Let's make it uncollectable until the pc is closed by JS or the page stops it.
if (!peerConnection->isClosed()) {
peerConnection->m_pendingActivity = peerConnection->makePendingActivity(peerConnection.get());
- if (auto* page = downcast<Document>(context).page()) {
+ if (auto* page = document.page()) {
peerConnection->registerToController(page->rtcController());
- page->libWebRTCProvider().setEnableLogging(!context.sessionID().isEphemeral());
+ page->libWebRTCProvider().setEnableLogging(!document.sessionID().isEphemeral());
}
}
return peerConnection;
}
-RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context)
- : ActiveDOMObject(&context)
+RTCPeerConnection::RTCPeerConnection(Document& document)
+ : ActiveDOMObject(document)
#if !RELEASE_LOG_DISABLED
- , m_logger(downcast<Document>(context).logger())
+ , m_logger(document.logger())
, m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber()))
#endif
, m_backend(PeerConnectionBackend::create(*this))
@@ -92,7 +93,7 @@
ALWAYS_LOG(LOGIDENTIFIER);
#if !RELEASE_LOG_DISABLED
- auto* page = downcast<Document>(context).page();
+ auto* page = document.page();
if (page && !page->settings().webRTCEncryptionEnabled())
ALWAYS_LOG(LOGIDENTIFIER, "encryption is disabled");
#endif
@@ -318,7 +319,7 @@
ExceptionOr<Vector<MediaEndpointConfiguration::CertificatePEM>> RTCPeerConnection::certificatesFromConfiguration(const RTCConfiguration& configuration)
{
auto currentMilliSeconds = WallTime::now().secondsSinceEpoch().milliseconds();
- auto& origin = downcast<Document>(*scriptExecutionContext()).securityOrigin();
+ auto& origin = document()->securityOrigin();
Vector<MediaEndpointConfiguration::CertificatePEM> certificates;
certificates.reserveInitialCapacity(configuration.certificates.size());
@@ -401,7 +402,7 @@
m_backend->getStats(WTFMove(promise));
}
-ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(ScriptExecutionContext& context, String&& label, RTCDataChannelInit&& options)
+ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(String&& label, RTCDataChannelInit&& options)
{
ALWAYS_LOG(LOGIDENTIFIER);
@@ -421,7 +422,7 @@
if (!channelHandler)
return Exception { NotSupportedError };
- return RTCDataChannel::create(context, WTFMove(channelHandler), WTFMove(label), WTFMove(options));
+ return RTCDataChannel::create(*document(), WTFMove(channelHandler), WTFMove(label), WTFMove(options));
}
bool RTCPeerConnection::doClose()
@@ -669,6 +670,11 @@
return m_transceiverSet->list();
}
+Document* RTCPeerConnection::document()
+{
+ return downcast<Document>(scriptExecutionContext());
+}
+
#if !RELEASE_LOG_DISABLED
WTFLogChannel& RTCPeerConnection::logChannel() const
{
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2019-09-10 17:41:32 UTC (rev 249722)
@@ -142,7 +142,7 @@
ExceptionOr<Ref<RTCRtpTransceiver>> addTransceiver(AddTransceiverTrackOrKind&&, const RTCRtpTransceiverInit&);
// 6.1 Peer-to-peer data API
- ExceptionOr<Ref<RTCDataChannel>> createDataChannel(ScriptExecutionContext&, String&&, RTCDataChannelInit&&);
+ ExceptionOr<Ref<RTCDataChannel>> createDataChannel(String&&, RTCDataChannelInit&&);
// 8.2 Statistics API
void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&);
@@ -174,6 +174,8 @@
// ActiveDOMObject.
bool hasPendingActivity() const final;
+
+ Document* document();
#if !RELEASE_LOG_DISABLED
const Logger& logger() const final { return m_logger.get(); }
@@ -183,7 +185,7 @@
#endif
private:
- RTCPeerConnection(ScriptExecutionContext&);
+ RTCPeerConnection(Document&);
ExceptionOr<void> initializeConfiguration(RTCConfiguration&&);
Ref<RTCRtpTransceiver> completeAddTransceiver(Ref<RTCRtpSender>&&, const RTCRtpTransceiverInit&, const String& trackId, const String& trackKind);
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl 2019-09-10 17:41:32 UTC (rev 249722)
@@ -73,7 +73,7 @@
[
ActiveDOMObject,
Conditional=WEB_RTC,
- ConstructorCallWith=ScriptExecutionContext,
+ ConstructorCallWith=Document,
EnabledAtRuntime=PeerConnection,
ExportMacro=WEBCORE_EXPORT,
JSBuiltinConstructor
@@ -146,7 +146,7 @@
// 6.1 Peer-to-peer data API
// FIXME 169644: missing sctp
- [CallWith=ScriptExecutionContext, MayThrowException] RTCDataChannel createDataChannel([TreatNullAs=EmptyString] USVString label, optional RTCDataChannelInit options);
+ [MayThrowException] RTCDataChannel createDataChannel([TreatNullAs=EmptyString] USVString label, optional RTCDataChannelInit options);
attribute EventHandler ondatachannel;
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp 2019-09-10 17:41:32 UTC (rev 249722)
@@ -56,7 +56,7 @@
return String::fromUTF8(value.data(), value.length());
}
-Ref<RTCDataChannelEvent> LibWebRTCDataChannelHandler::channelEvent(ScriptExecutionContext& context, rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel)
+Ref<RTCDataChannelEvent> LibWebRTCDataChannelHandler::channelEvent(Document& document, rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel)
{
auto protocol = dataChannel->protocol();
auto label = dataChannel->label();
@@ -70,7 +70,7 @@
init.id = dataChannel->id();
auto handler = makeUnique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel));
- auto channel = RTCDataChannel::create(context, WTFMove(handler), fromStdString(label), WTFMove(init));
+ auto channel = RTCDataChannel::create(document, WTFMove(handler), fromStdString(label), WTFMove(init));
return RTCDataChannelEvent::create(eventNames().datachannelEvent, Event::CanBubble::No, Event::IsCancelable::No, WTFMove(channel));
}
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h 2019-09-10 17:41:32 UTC (rev 249722)
@@ -41,6 +41,7 @@
namespace WebCore {
+class Document;
class RTCDataChannelEvent;
class RTCDataChannelHandlerClient;
struct RTCDataChannelInit;
@@ -53,7 +54,7 @@
~LibWebRTCDataChannelHandler();
static webrtc::DataChannelInit fromRTCDataChannelInit(const RTCDataChannelInit&);
- static Ref<RTCDataChannelEvent> channelEvent(ScriptExecutionContext&, rtc::scoped_refptr<webrtc::DataChannelInterface>&&);
+ static Ref<RTCDataChannelEvent> channelEvent(Document&, rtc::scoped_refptr<webrtc::DataChannelInterface>&&);
private:
// RTCDataChannelHandler API
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (249721 => 249722)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2019-09-10 17:07:24 UTC (rev 249721)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2019-09-10 17:41:32 UTC (rev 249722)
@@ -663,7 +663,7 @@
if (protectedThis->isStopped())
return;
auto& connection = protectedThis->m_peerConnectionBackend.connection();
- connection.fireEvent(LibWebRTCDataChannelHandler::channelEvent(*connection.scriptExecutionContext(), WTFMove(dataChannel)));
+ connection.fireEvent(LibWebRTCDataChannelHandler::channelEvent(*connection.document(), WTFMove(dataChannel)));
});
}