Follow-up on comments for bug 169664
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2017 02:51:00 +0000 (02:51 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2017 02:51:00 +0000 (02:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169709

Reviewed by Youenn Fablet.

* Modules/mediastream/MediaEndpointPeerConnection.cpp:
(WebCore::deriveAggregatedIceConnectionState): Update deriveAggregatedIceConnectionState.
(WebCore::MediaEndpointPeerConnection::iceTransportStateChanged): Set a capacity and used
uncheckedAppend.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214207 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp

index ea7ec26..8e3dfab 100644 (file)
@@ -1,3 +1,15 @@
+2017-03-20  Jon Lee  <jonlee@apple.com>
+
+        Follow-up on comments for bug 169664
+        https://bugs.webkit.org/show_bug.cgi?id=169709
+
+        Reviewed by Youenn Fablet.
+
+        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+        (WebCore::deriveAggregatedIceConnectionState): Update deriveAggregatedIceConnectionState.
+        (WebCore::MediaEndpointPeerConnection::iceTransportStateChanged): Set a capacity and used
+        uncheckedAppend.
+
 2017-03-20  Simon Fraser  <simon.fraser@apple.com>
 
         Add a system trace point for memory warning handling
index c9c216c..7465779 100644 (file)
@@ -806,7 +806,7 @@ void MediaEndpointPeerConnection::doneGatheringCandidates(const String& mid)
         PeerConnectionBackend::doneGatheringCandidates();
 }
 
-static RTCIceTransportState deriveAggregatedIceConnectionState(const Vector<RTCIceTransportState>& states)
+static RTCIceConnectionState deriveAggregatedIceConnectionState(const Vector<RTCIceTransportState>& states)
 {
     unsigned newCount = 0;
     unsigned checkingCount = 0;
@@ -844,25 +844,25 @@ static RTCIceTransportState deriveAggregatedIceConnectionState(const Vector<RTCI
 
     // The aggregated RTCIceConnectionState is derived from the RTCIceTransportState of all RTCIceTransports.
     if ((newCount > 0 && !checkingCount && !failedCount && !disconnectedCount) || (closedCount == states.size()))
-        return RTCIceTransportState::New;
+        return RTCIceConnectionState::New;
 
     if (checkingCount > 0 && !failedCount && !disconnectedCount)
-        return RTCIceTransportState::Checking;
+        return RTCIceConnectionState::Checking;
 
     if ((connectedCount + completedCount + closedCount) == states.size() && connectedCount > 0)
-        return RTCIceTransportState::Connected;
+        return RTCIceConnectionState::Connected;
 
     if ((completedCount + closedCount) == states.size() && completedCount > 0)
-        return RTCIceTransportState::Completed;
+        return RTCIceConnectionState::Completed;
 
     if (failedCount > 0)
-        return RTCIceTransportState::Failed;
+        return RTCIceConnectionState::Failed;
 
     if (disconnectedCount > 0) // Any failed caught above.
-        return RTCIceTransportState::Disconnected;
+        return RTCIceConnectionState::Disconnected;
 
     ASSERT_NOT_REACHED();
-    return RTCIceTransportState::New;
+    return RTCIceConnectionState::New;
 }
 
 void MediaEndpointPeerConnection::iceTransportStateChanged(const String& mid, RTCIceTransportState mediaEndpointIceTransportState)
@@ -877,11 +877,11 @@ void MediaEndpointPeerConnection::iceTransportStateChanged(const String& mid, RT
 
     // Determine if the script needs to be notified.
     Vector<RTCIceTransportState> transportStates;
+    transportStates.reserveInitialCapacity(m_peerConnection.getTransceivers().size());
     for (auto& transceiver : m_peerConnection.getTransceivers())
-        transportStates.append(transceiver->iceTransport().state());
+        transportStates.uncheckedAppend(transceiver->iceTransport().state());
 
-    RTCIceTransportState derivedState = deriveAggregatedIceConnectionState(transportStates);
-    m_peerConnection.updateIceConnectionState(static_cast<RTCIceConnectionState>(derivedState));
+    m_peerConnection.updateIceConnectionState(deriveAggregatedIceConnectionState(transportStates));
 }
 
 } // namespace WebCore