Title: [215327] trunk
Revision
215327
Author
commit-qu...@webkit.org
Date
2017-04-13 11:28:29 -0700 (Thu, 13 Apr 2017)

Log Message

Remove RTCSignalingState::Closed
https://bugs.webkit.org/show_bug.cgi?id=170811

Patch by Youenn Fablet <you...@apple.com> on 2017-04-13
Reviewed by Eric Carlson.

Source/WebCore:

Covered by existing and rebased tests.

Adding RTCPeerConnection::isClosed to better match the isClosed internal slot in webrtc specification.
Using isClosed instead of checking signalingState value.
Implementing isClosed in terms of m_connectionState which has a Closed value.

* Modules/mediastream/MediaEndpointPeerConnection.cpp:
(WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
(WebCore::MediaEndpointPeerConnection::replaceTrackTask):
* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::createOffer):
(WebCore::PeerConnectionBackend::createOfferSucceeded):
(WebCore::PeerConnectionBackend::createOfferFailed):
(WebCore::PeerConnectionBackend::createAnswer):
(WebCore::PeerConnectionBackend::createAnswerSucceeded):
(WebCore::PeerConnectionBackend::createAnswerFailed):
(WebCore::PeerConnectionBackend::setLocalDescription):
(WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
(WebCore::PeerConnectionBackend::setLocalDescriptionFailed):
(WebCore::PeerConnectionBackend::setRemoteDescription):
(WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
(WebCore::PeerConnectionBackend::setRemoteDescriptionFailed):
(WebCore::PeerConnectionBackend::addIceCandidate):
(WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
(WebCore::PeerConnectionBackend::addIceCandidateFailed):
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::create):
(WebCore::RTCPeerConnection::RTCPeerConnection):
(WebCore::RTCPeerConnection::addTrack):
(WebCore::RTCPeerConnection::removeTrack):
(WebCore::RTCPeerConnection::queuedCreateOffer):
(WebCore::RTCPeerConnection::queuedCreateAnswer):
(WebCore::RTCPeerConnection::queuedSetLocalDescription):
(WebCore::RTCPeerConnection::queuedSetRemoteDescription):
(WebCore::RTCPeerConnection::queuedAddIceCandidate):
(WebCore::RTCPeerConnection::setConfiguration):
(WebCore::RTCPeerConnection::createDataChannel):
(WebCore::RTCPeerConnection::doClose):
(WebCore::RTCPeerConnection::updateIceGatheringState):
(WebCore::RTCPeerConnection::updateIceConnectionState):
(WebCore::RTCPeerConnection::scheduleNegotiationNeededEvent):
* Modules/mediastream/RTCPeerConnection.h:
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::signalingState):
* platform/mediastream/RTCSignalingState.h:

LayoutTests:

* webrtc/connection-state.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (215326 => 215327)


--- trunk/LayoutTests/ChangeLog	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/LayoutTests/ChangeLog	2017-04-13 18:28:29 UTC (rev 215327)
@@ -1,3 +1,12 @@
+2017-04-13  Youenn Fablet  <you...@apple.com>
+
+        Remove RTCSignalingState::Closed
+        https://bugs.webkit.org/show_bug.cgi?id=170811
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/connection-state.html:
+
 2017-04-13  Jonathan Bedard  <jbed...@apple.com>
 
         Remove compositing/masks/solid-color-masked.html expectation

Modified: trunk/LayoutTests/webrtc/connection-state.html (215326 => 215327)


--- trunk/LayoutTests/webrtc/connection-state.html	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/LayoutTests/webrtc/connection-state.html	2017-04-13 18:28:29 UTC (rev 215327)
@@ -69,10 +69,10 @@
     return new Promise((resolve, reject) => {
         var pc = new RTCPeerConnection();
         pc._onconnectionstatechange_ = () => {
-            assert_equals(pc.connectionState, "closed");
-            resolve();
+            assert_unreached();
         };
         pc.close();
+        setTimeout(resolve, 200);
     })
 }, "Checking connection state event when closing peer connetion");
         </script>

Modified: trunk/Source/WebCore/ChangeLog (215326 => 215327)


--- trunk/Source/WebCore/ChangeLog	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/Source/WebCore/ChangeLog	2017-04-13 18:28:29 UTC (rev 215327)
@@ -1,3 +1,56 @@
+2017-04-13  Youenn Fablet  <you...@apple.com>
+
+        Remove RTCSignalingState::Closed
+        https://bugs.webkit.org/show_bug.cgi?id=170811
+
+        Reviewed by Eric Carlson.
+
+        Covered by existing and rebased tests.
+
+        Adding RTCPeerConnection::isClosed to better match the isClosed internal slot in webrtc specification.
+        Using isClosed instead of checking signalingState value.
+        Implementing isClosed in terms of m_connectionState which has a Closed value.
+
+        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+        (WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
+        (WebCore::MediaEndpointPeerConnection::replaceTrackTask):
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::createOffer):
+        (WebCore::PeerConnectionBackend::createOfferSucceeded):
+        (WebCore::PeerConnectionBackend::createOfferFailed):
+        (WebCore::PeerConnectionBackend::createAnswer):
+        (WebCore::PeerConnectionBackend::createAnswerSucceeded):
+        (WebCore::PeerConnectionBackend::createAnswerFailed):
+        (WebCore::PeerConnectionBackend::setLocalDescription):
+        (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded):
+        (WebCore::PeerConnectionBackend::setLocalDescriptionFailed):
+        (WebCore::PeerConnectionBackend::setRemoteDescription):
+        (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded):
+        (WebCore::PeerConnectionBackend::setRemoteDescriptionFailed):
+        (WebCore::PeerConnectionBackend::addIceCandidate):
+        (WebCore::PeerConnectionBackend::addIceCandidateSucceeded):
+        (WebCore::PeerConnectionBackend::addIceCandidateFailed):
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::create):
+        (WebCore::RTCPeerConnection::RTCPeerConnection):
+        (WebCore::RTCPeerConnection::addTrack):
+        (WebCore::RTCPeerConnection::removeTrack):
+        (WebCore::RTCPeerConnection::queuedCreateOffer):
+        (WebCore::RTCPeerConnection::queuedCreateAnswer):
+        (WebCore::RTCPeerConnection::queuedSetLocalDescription):
+        (WebCore::RTCPeerConnection::queuedSetRemoteDescription):
+        (WebCore::RTCPeerConnection::queuedAddIceCandidate):
+        (WebCore::RTCPeerConnection::setConfiguration):
+        (WebCore::RTCPeerConnection::createDataChannel):
+        (WebCore::RTCPeerConnection::doClose):
+        (WebCore::RTCPeerConnection::updateIceGatheringState):
+        (WebCore::RTCPeerConnection::updateIceConnectionState):
+        (WebCore::RTCPeerConnection::scheduleNegotiationNeededEvent):
+        * Modules/mediastream/RTCPeerConnection.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::signalingState):
+        * platform/mediastream/RTCSignalingState.h:
+
 2017-04-13  Zalan Bujtas  <za...@apple.com>
 
         BreakingContext::WordTrailingSpace cleanup.

Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (215326 => 215327)


--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-04-13 18:28:29 UTC (rev 215327)
@@ -332,7 +332,7 @@
 
 void MediaEndpointPeerConnection::setLocalDescriptionTask(RefPtr<RTCSessionDescription>&& description)
 {
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     auto result = MediaEndpointSessionDescription::create(WTFMove(description), *m_sdpProcessor);
@@ -718,7 +718,7 @@
 
 void MediaEndpointPeerConnection::replaceTrackTask(RTCRtpSender& sender, const String& mid, Ref<MediaStreamTrack>&& withTrack, DOMPromise<void>& promise)
 {
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     m_mediaEndpoint->replaceSendSource(withTrack->source(), mid);

Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (215326 => 215327)


--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2017-04-13 18:28:29 UTC (rev 215327)
@@ -46,7 +46,7 @@
 void PeerConnectionBackend::createOffer(RTCOfferOptions&& options, PeerConnection::SessionDescriptionPromise&& promise)
 {
     ASSERT(!m_offerAnswerPromise);
-    ASSERT(m_peerConnection.signalingState() != RTCSignalingState::Closed);
+    ASSERT(!m_peerConnection.isClosed());
 
     m_offerAnswerPromise = WTFMove(promise);
     doCreateOffer(WTFMove(options));
@@ -56,7 +56,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_offerAnswerPromise);
@@ -68,7 +68,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_offerAnswerPromise);
@@ -79,7 +79,7 @@
 void PeerConnectionBackend::createAnswer(RTCAnswerOptions&& options, PeerConnection::SessionDescriptionPromise&& promise)
 {
     ASSERT(!m_offerAnswerPromise);
-    ASSERT(m_peerConnection.signalingState() != RTCSignalingState::Closed);
+    ASSERT(!m_peerConnection.isClosed());
 
     m_offerAnswerPromise = WTFMove(promise);
     doCreateAnswer(WTFMove(options));
@@ -89,7 +89,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_offerAnswerPromise);
@@ -101,7 +101,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_offerAnswerPromise);
@@ -130,7 +130,7 @@
 
 void PeerConnectionBackend::setLocalDescription(RTCSessionDescription& sessionDescription, DOMPromise<void>&& promise)
 {
-    ASSERT(m_peerConnection.signalingState() != RTCSignalingState::Closed);
+    ASSERT(!m_peerConnection.isClosed());
 
     if (!isLocalDescriptionTypeValidForState(sessionDescription.type(), m_peerConnection.signalingState())) {
         promise.reject(INVALID_STATE_ERR, "Description type incompatible with current signaling state");
@@ -145,7 +145,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_setDescriptionPromise);
@@ -158,7 +158,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_setDescriptionPromise);
@@ -188,7 +188,7 @@
 
 void PeerConnectionBackend::setRemoteDescription(RTCSessionDescription& sessionDescription, DOMPromise<void>&& promise)
 {
-    ASSERT(m_peerConnection.signalingState() != RTCSignalingState::Closed);
+    ASSERT(!m_peerConnection.isClosed());
 
     if (!isRemoteDescriptionTypeValidForState(sessionDescription.type(), m_peerConnection.signalingState())) {
         promise.reject(INVALID_STATE_ERR, "Description type incompatible with current signaling state");
@@ -203,7 +203,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_setDescriptionPromise);
@@ -216,7 +216,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_setDescriptionPromise);
@@ -227,7 +227,7 @@
 
 void PeerConnectionBackend::addIceCandidate(RTCIceCandidate* iceCandidate, DOMPromise<void>&& promise)
 {
-    ASSERT(m_peerConnection.signalingState() != RTCSignalingState::Closed);
+    ASSERT(!m_peerConnection.isClosed());
 
     if (!iceCandidate) {
         endOfIceCandidates(WTFMove(promise));
@@ -247,7 +247,7 @@
 {
     ASSERT(isMainThread());
 
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     // FIXME: Update remote description and set ICE connection state to checking if not already done so.
@@ -260,7 +260,7 @@
 void PeerConnectionBackend::addIceCandidateFailed(Exception&& exception)
 {
     ASSERT(isMainThread());
-    if (m_peerConnection.signalingState() == RTCSignalingState::Closed)
+    if (m_peerConnection.isClosed())
         return;
 
     ASSERT(m_addIceCandidatePromise);

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (215326 => 215327)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-04-13 18:28:29 UTC (rev 215327)
@@ -65,7 +65,7 @@
     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->m_signalingState != RTCSignalingState::Closed) {
+    if (!peerConnection->isClosed()) {
         peerConnection->setPendingActivity(peerConnection.ptr());
         peerConnection->registerToController();
     }
@@ -76,10 +76,8 @@
     : ActiveDOMObject(&context)
     , m_backend(PeerConnectionBackend::create(*this))
 {
-    if (!m_backend) {
-        m_signalingState = RTCSignalingState::Closed;
-        m_iceConnectionState = RTCIceConnectionState::Closed;
-    }
+    if (!m_backend)
+        m_connectionState = RTCPeerConnectionState::Closed;
 }
 
 RTCPeerConnection::~RTCPeerConnection()
@@ -100,7 +98,7 @@
 
 ExceptionOr<Ref<RTCRtpSender>> RTCPeerConnection::addTrack(Ref<MediaStreamTrack>&& track, const Vector<std::reference_wrapper<MediaStream>>& streams)
 {
-    if (m_signalingState == RTCSignalingState::Closed)
+    if (isClosed())
         return Exception { INVALID_STATE_ERR };
 
     // Require at least one stream until https://github.com/w3c/webrtc-pc/issues/288 is resolved
@@ -158,7 +156,7 @@
 
 ExceptionOr<void> RTCPeerConnection::removeTrack(RTCRtpSender& sender)
 {
-    if (m_signalingState == RTCSignalingState::Closed)
+    if (isClosed())
         return Exception { INVALID_STATE_ERR };
 
     bool shouldAbort = true;
@@ -216,7 +214,7 @@
 
 void RTCPeerConnection::queuedCreateOffer(RTCOfferOptions&& options, SessionDescriptionPromise&& promise)
 {
-    if (m_signalingState == RTCSignalingState::Closed) {
+    if (isClosed()) {
         promise.reject(INVALID_STATE_ERR);
         return;
     }
@@ -226,7 +224,7 @@
 
 void RTCPeerConnection::queuedCreateAnswer(RTCAnswerOptions&& options, SessionDescriptionPromise&& promise)
 {
-    if (m_signalingState == RTCSignalingState::Closed) {
+    if (isClosed()) {
         promise.reject(INVALID_STATE_ERR);
         return;
     }
@@ -236,7 +234,7 @@
 
 void RTCPeerConnection::queuedSetLocalDescription(RTCSessionDescription& description, DOMPromise<void>&& promise)
 {
-    if (m_signalingState == RTCSignalingState::Closed) {
+    if (isClosed()) {
         promise.reject(INVALID_STATE_ERR);
         return;
     }
@@ -261,7 +259,7 @@
 
 void RTCPeerConnection::queuedSetRemoteDescription(RTCSessionDescription& description, DOMPromise<void>&& promise)
 {
-    if (m_signalingState == RTCSignalingState::Closed) {
+    if (isClosed()) {
         promise.reject(INVALID_STATE_ERR);
         return;
     }
@@ -286,7 +284,7 @@
 
 void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate* rtcCandidate, DOMPromise<void>&& promise)
 {
-    if (m_signalingState == RTCSignalingState::Closed) {
+    if (isClosed()) {
         promise.reject(INVALID_STATE_ERR);
         return;
     }
@@ -296,7 +294,7 @@
 
 ExceptionOr<void> RTCPeerConnection::setConfiguration(RTCConfiguration&& configuration)
 {
-    if (m_signalingState == RTCSignalingState::Closed)
+    if (isClosed())
         return Exception { INVALID_STATE_ERR };
 
     Vector<MediaEndpointConfiguration::IceServerInfo> servers;
@@ -335,7 +333,7 @@
 
 ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(ScriptExecutionContext& context, String&& label, RTCDataChannelInit&& options)
 {
-    if (m_signalingState == RTCSignalingState::Closed)
+    if (isClosed())
         return Exception { INVALID_STATE_ERR };
 
     if (options.negotiated && !options.negotiated.value() && (label.length() > 65535 || options.protocol.length() > 65535))
@@ -356,11 +354,11 @@
 
 bool RTCPeerConnection::doClose()
 {
-    if (m_signalingState == RTCSignalingState::Closed)
+    if (isClosed())
         return false;
 
+    m_connectionState = RTCPeerConnectionState::Closed;
     m_iceConnectionState = RTCIceConnectionState::Closed;
-    m_signalingState = RTCSignalingState::Closed;
 
     for (RTCRtpReceiver& receiver : m_transceiverSet->receivers())
         receiver.stop();
@@ -449,7 +447,7 @@
 void RTCPeerConnection::updateIceGatheringState(RTCIceGatheringState newState)
 {
     scriptExecutionContext()->postTask([protectedThis = makeRef(*this), newState](ScriptExecutionContext&) {
-        if (protectedThis->m_signalingState == RTCSignalingState::Closed || protectedThis->m_iceGatheringState == newState)
+        if (protectedThis->isClosed() || protectedThis->m_iceGatheringState == newState)
             return;
 
         protectedThis->m_iceGatheringState = newState;
@@ -461,7 +459,7 @@
 void RTCPeerConnection::updateIceConnectionState(RTCIceConnectionState newState)
 {
     scriptExecutionContext()->postTask([protectedThis = makeRef(*this), newState](ScriptExecutionContext&) {
-        if (protectedThis->m_signalingState == RTCSignalingState::Closed || protectedThis->m_iceConnectionState == newState)
+        if (protectedThis->isClosed() || protectedThis->m_iceConnectionState == newState)
             return;
 
         protectedThis->m_iceConnectionState = newState;
@@ -499,7 +497,7 @@
 void RTCPeerConnection::scheduleNegotiationNeededEvent()
 {
     scriptExecutionContext()->postTask([protectedThis = makeRef(*this)](ScriptExecutionContext&) {
-        if (protectedThis->m_signalingState == RTCSignalingState::Closed)
+        if (protectedThis->isClosed())
             return;
         if (!protectedThis->m_backend->isNegotiationNeeded())
             return;

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (215326 => 215327)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2017-04-13 18:28:29 UTC (rev 215327)
@@ -97,6 +97,8 @@
     ExceptionOr<void> setConfiguration(RTCConfiguration&&);
     void close();
 
+    bool isClosed() const { return m_connectionState == RTCPeerConnectionState::Closed; }
+
     // 5.1 RTCPeerConnection extensions
     const Vector<std::reference_wrapper<RTCRtpSender>>& getSenders() const { return m_transceiverSet->senders(); }
     const Vector<std::reference_wrapper<RTCRtpReceiver>>& getReceivers() const { return m_transceiverSet->receivers(); }

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (215326 => 215327)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-04-13 18:28:29 UTC (rev 215327)
@@ -428,7 +428,7 @@
     case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer:
         return RTCSignalingState::HaveRemotePranswer;
     case webrtc::PeerConnectionInterface::kClosed:
-        return RTCSignalingState::Closed;
+        return RTCSignalingState::Stable;
     }
 }
 

Modified: trunk/Source/WebCore/platform/mediastream/RTCSignalingState.h (215326 => 215327)


--- trunk/Source/WebCore/platform/mediastream/RTCSignalingState.h	2017-04-13 17:54:20 UTC (rev 215326)
+++ trunk/Source/WebCore/platform/mediastream/RTCSignalingState.h	2017-04-13 18:28:29 UTC (rev 215327)
@@ -34,7 +34,6 @@
     HaveRemoteOffer,
     HaveLocalPranswer,
     HaveRemotePranswer,
-    Closed
 };
 
 }; // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to