Changeset 249722 in webkit
- Timestamp:
- Sep 10, 2019 10:41:32 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249718 r249722 1 2019-09-10 Youenn Fablet <youenn@apple.com> 2 3 RTCPeerConnection can only be instantiated in documents 4 https://bugs.webkit.org/show_bug.cgi?id=201639 5 6 Reviewed by Alex Christensen. 7 8 Make it clear that RTCDataChannel expects Document since peer connections 9 and data channels can only be instantiated in document environments. 10 We keep one downcast in RTCPeerConnection constructor due to a limitation 11 in binding generator for JS built-ins. 12 No change of behavior. 13 14 * Modules/mediastream/RTCDataChannel.cpp: 15 (WebCore::RTCDataChannel::create): 16 (WebCore::RTCDataChannel::RTCDataChannel): 17 * Modules/mediastream/RTCDataChannel.h: 18 * Modules/mediastream/RTCPeerConnection.cpp: 19 (WebCore::RTCPeerConnection::create): 20 (WebCore::RTCPeerConnection::RTCPeerConnection): 21 (WebCore::RTCPeerConnection::certificatesFromConfiguration): 22 (WebCore::RTCPeerConnection::createDataChannel): 23 (WebCore::RTCPeerConnection::document): 24 * Modules/mediastream/RTCPeerConnection.h: 25 * Modules/mediastream/RTCPeerConnection.idl: 26 * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp: 27 (WebCore::LibWebRTCDataChannelHandler::channelEvent): 28 * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: 29 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: 30 (WebCore::LibWebRTCMediaEndpoint::OnDataChannel): 31 1 32 2019-09-10 Youenn Fablet <youenn@apple.com> 2 33 -
trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp
r249710 r249722 54 54 } 55 55 56 Ref<RTCDataChannel> RTCDataChannel::create( ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)56 Ref<RTCDataChannel> RTCDataChannel::create(Document& document, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options) 57 57 { 58 58 ASSERT(handler); 59 auto channel = adoptRef(*new RTCDataChannel( context, WTFMove(handler), WTFMove(label), WTFMove(options)));59 auto channel = adoptRef(*new RTCDataChannel(document, WTFMove(handler), WTFMove(label), WTFMove(options))); 60 60 channel->suspendIfNeeded(); 61 61 channel->m_handler->setClient(channel.get()); … … 79 79 } 80 80 81 RTCDataChannel::RTCDataChannel( ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)82 : ActiveDOMObject( &context)81 RTCDataChannel::RTCDataChannel(Document& document, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options) 82 : ActiveDOMObject(document) 83 83 , m_handler(WTFMove(handler)) 84 84 , m_scheduledEventTimer(*this, &RTCDataChannel::scheduledEventTimerFired) 85 85 , m_label(WTFMove(label)) 86 86 , m_options(WTFMove(options)) 87 , m_messageQueue(createMessageQueue(do wncast<Document>(context), *this))87 , m_messageQueue(createMessageQueue(document, *this)) 88 88 { 89 89 } -
trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h
r249710 r249722 51 51 WTF_MAKE_ISO_ALLOCATED(RTCDataChannel); 52 52 public: 53 static Ref<RTCDataChannel> create( ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);53 static Ref<RTCDataChannel> create(Document&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&); 54 54 55 55 bool ordered() const { return *m_options.ordered; } … … 80 80 81 81 private: 82 RTCDataChannel( ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);82 RTCDataChannel(Document&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&); 83 83 84 84 static NetworkSendQueue createMessageQueue(Document&, RTCDataChannel&); -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
r247438 r249722 68 68 Ref<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context) 69 69 { 70 auto peerConnection = adoptRef(*new RTCPeerConnection(context)); 70 auto& document = downcast<Document>(context); 71 auto peerConnection = adoptRef(*new RTCPeerConnection(document)); 71 72 peerConnection->suspendIfNeeded(); 72 73 // RTCPeerConnection may send events at about any time during its lifetime. … … 74 75 if (!peerConnection->isClosed()) { 75 76 peerConnection->m_pendingActivity = peerConnection->makePendingActivity(peerConnection.get()); 76 if (auto* page = do wncast<Document>(context).page()) {77 if (auto* page = document.page()) { 77 78 peerConnection->registerToController(page->rtcController()); 78 page->libWebRTCProvider().setEnableLogging(! context.sessionID().isEphemeral());79 page->libWebRTCProvider().setEnableLogging(!document.sessionID().isEphemeral()); 79 80 } 80 81 } … … 82 83 } 83 84 84 RTCPeerConnection::RTCPeerConnection( ScriptExecutionContext& context)85 : ActiveDOMObject( &context)85 RTCPeerConnection::RTCPeerConnection(Document& document) 86 : ActiveDOMObject(document) 86 87 #if !RELEASE_LOG_DISABLED 87 , m_logger(do wncast<Document>(context).logger())88 , m_logger(document.logger()) 88 89 , m_logIdentifier(reinterpret_cast<const void*>(cryptographicallyRandomNumber())) 89 90 #endif … … 93 94 94 95 #if !RELEASE_LOG_DISABLED 95 auto* page = do wncast<Document>(context).page();96 auto* page = document.page(); 96 97 if (page && !page->settings().webRTCEncryptionEnabled()) 97 98 ALWAYS_LOG(LOGIDENTIFIER, "encryption is disabled"); … … 319 320 { 320 321 auto currentMilliSeconds = WallTime::now().secondsSinceEpoch().milliseconds(); 321 auto& origin = do wncast<Document>(*scriptExecutionContext()).securityOrigin();322 auto& origin = document()->securityOrigin(); 322 323 323 324 Vector<MediaEndpointConfiguration::CertificatePEM> certificates; … … 402 403 } 403 404 404 ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(S criptExecutionContext& context, String&& label, RTCDataChannelInit&& options)405 ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(String&& label, RTCDataChannelInit&& options) 405 406 { 406 407 ALWAYS_LOG(LOGIDENTIFIER); … … 422 423 return Exception { NotSupportedError }; 423 424 424 return RTCDataChannel::create( context, WTFMove(channelHandler), WTFMove(label), WTFMove(options));425 return RTCDataChannel::create(*document(), WTFMove(channelHandler), WTFMove(label), WTFMove(options)); 425 426 } 426 427 … … 670 671 } 671 672 673 Document* RTCPeerConnection::document() 674 { 675 return downcast<Document>(scriptExecutionContext()); 676 } 677 672 678 #if !RELEASE_LOG_DISABLED 673 679 WTFLogChannel& RTCPeerConnection::logChannel() const -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
r243887 r249722 143 143 144 144 // 6.1 Peer-to-peer data API 145 ExceptionOr<Ref<RTCDataChannel>> createDataChannel(S criptExecutionContext&, String&&, RTCDataChannelInit&&);145 ExceptionOr<Ref<RTCDataChannel>> createDataChannel(String&&, RTCDataChannelInit&&); 146 146 147 147 // 8.2 Statistics API … … 175 175 // ActiveDOMObject. 176 176 bool hasPendingActivity() const final; 177 178 Document* document(); 177 179 178 180 #if !RELEASE_LOG_DISABLED … … 184 186 185 187 private: 186 RTCPeerConnection( ScriptExecutionContext&);188 RTCPeerConnection(Document&); 187 189 188 190 ExceptionOr<void> initializeConfiguration(RTCConfiguration&&); -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl
r238100 r249722 74 74 ActiveDOMObject, 75 75 Conditional=WEB_RTC, 76 ConstructorCallWith= ScriptExecutionContext,76 ConstructorCallWith=Document, 77 77 EnabledAtRuntime=PeerConnection, 78 78 ExportMacro=WEBCORE_EXPORT, … … 147 147 // FIXME 169644: missing sctp 148 148 149 [ CallWith=ScriptExecutionContext,MayThrowException] RTCDataChannel createDataChannel([TreatNullAs=EmptyString] USVString label, optional RTCDataChannelInit options);149 [MayThrowException] RTCDataChannel createDataChannel([TreatNullAs=EmptyString] USVString label, optional RTCDataChannelInit options); 150 150 attribute EventHandler ondatachannel; 151 151 -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp
r248846 r249722 57 57 } 58 58 59 Ref<RTCDataChannelEvent> LibWebRTCDataChannelHandler::channelEvent( ScriptExecutionContext& context, rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel)59 Ref<RTCDataChannelEvent> LibWebRTCDataChannelHandler::channelEvent(Document& document, rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel) 60 60 { 61 61 auto protocol = dataChannel->protocol(); … … 71 71 72 72 auto handler = makeUnique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel)); 73 auto channel = RTCDataChannel::create( context, WTFMove(handler), fromStdString(label), WTFMove(init));73 auto channel = RTCDataChannel::create(document, WTFMove(handler), fromStdString(label), WTFMove(init)); 74 74 75 75 return RTCDataChannelEvent::create(eventNames().datachannelEvent, Event::CanBubble::No, Event::IsCancelable::No, WTFMove(channel)); -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h
r241183 r249722 42 42 namespace WebCore { 43 43 44 class Document; 44 45 class RTCDataChannelEvent; 45 46 class RTCDataChannelHandlerClient; … … 54 55 55 56 static webrtc::DataChannelInit fromRTCDataChannelInit(const RTCDataChannelInit&); 56 static Ref<RTCDataChannelEvent> channelEvent( ScriptExecutionContext&, rtc::scoped_refptr<webrtc::DataChannelInterface>&&);57 static Ref<RTCDataChannelEvent> channelEvent(Document&, rtc::scoped_refptr<webrtc::DataChannelInterface>&&); 57 58 58 59 private: -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
r248846 r249722 664 664 return; 665 665 auto& connection = protectedThis->m_peerConnectionBackend.connection(); 666 connection.fireEvent(LibWebRTCDataChannelHandler::channelEvent(*connection. scriptExecutionContext(), WTFMove(dataChannel)));666 connection.fireEvent(LibWebRTCDataChannelHandler::channelEvent(*connection.document(), WTFMove(dataChannel))); 667 667 }); 668 668 }
Note: See TracChangeset
for help on using the changeset viewer.