Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Unified Diff: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp

Issue 1523213002: Make sure peer connection states are updated properly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
diff --git a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
index 38891a8d0269205ad1d942039f1cb7937d656331..df8bf1581982710c2826ec201198d017e64714f0 100644
--- a/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
+++ b/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.cpp
@@ -128,6 +128,22 @@ private:
} // namespace
+RTCPeerConnection::EventWrapper::EventWrapper(
+ PassRefPtrWillBeRawPtr<Event> event,
+ PassOwnPtrWillBeRawPtr<BoolFunction> function)
+ : m_event(event)
+ , m_setupFunction(function)
+{
+}
+
+bool RTCPeerConnection::EventWrapper::setup()
+{
+ if (m_setupFunction) {
+ return (*m_setupFunction)();
+ }
+ return true;
+}
+
RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionState& exceptionState)
{
if (configuration.isUndefinedOrNull())
@@ -959,11 +975,20 @@ void RTCPeerConnection::changeIceGatheringState(ICEGatheringState iceGatheringSt
m_iceGatheringState = iceGatheringState;
}
-void RTCPeerConnection::changeIceConnectionState(ICEConnectionState iceConnectionState)
+bool RTCPeerConnection::setIceConnectionState(ICEConnectionState iceConnectionState)
{
if (m_iceConnectionState != ICEConnectionStateClosed && m_iceConnectionState != iceConnectionState) {
m_iceConnectionState = iceConnectionState;
- scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatechange));
+ return true;
+ }
+ return false;
+}
+
+void RTCPeerConnection::changeIceConnectionState(ICEConnectionState iceConnectionState)
+{
+ if (m_iceConnectionState != ICEConnectionStateClosed) {
+ scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatechange),
+ WTF::bind(&RTCPeerConnection::setIceConnectionState, this, iceConnectionState));
}
}
@@ -980,7 +1005,13 @@ void RTCPeerConnection::closeInternal()
void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
{
- m_scheduledEvents.append(event);
+ scheduleDispatchEvent(event, nullptr);
+}
+
+void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> event,
+ PassOwnPtrWillBeRawPtr<BoolFunction> setupFunction)
+{
+ m_scheduledEvents.append(EventWrapper(event, setupFunction));
m_dispatchScheduledEventRunner.runAsync();
}
@@ -990,12 +1021,15 @@ void RTCPeerConnection::dispatchScheduledEvent()
if (m_stopped)
return;
- WillBeHeapVector<RefPtrWillBeMember<Event>> events;
+ WillBeHeapVector<EventWrapper> events;
events.swap(m_scheduledEvents);
- WillBeHeapVector<RefPtrWillBeMember<Event>>::iterator it = events.begin();
- for (; it != events.end(); ++it)
- dispatchEvent((*it).release());
+ WillBeHeapVector<EventWrapper>::iterator it = events.begin();
+ for (; it != events.end(); ++it) {
+ if ((*it).setup()) {
+ dispatchEvent((*it).m_event.release());
+ }
+ }
events.clear();
}

Powered by Google App Engine
This is Rietveld 408576698