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

Unified Diff: Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

Issue 11339018: Merge 132420 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1271/
Patch Set: Created 8 years, 2 months 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
« no previous file with comments | « Source/WebCore/Modules/mediastream/RTCPeerConnection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
===================================================================
--- Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (revision 132836)
+++ Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (working copy)
@@ -127,6 +127,7 @@
, m_iceState(IceStateClosed)
, m_localStreams(MediaStreamList::create())
, m_remoteStreams(MediaStreamList::create())
+ , m_scheduledEventTimer(this, &RTCPeerConnection::scheduledEventTimerFired)
{
m_peerHandler = RTCPeerConnectionHandler::create(this);
if (!m_peerHandler || !m_peerHandler->initialize(configuration, constraints))
@@ -393,17 +394,17 @@
void RTCPeerConnection::negotiationNeeded()
{
- dispatchEvent(Event::create(eventNames().negotiationneededEvent, false, false));
+ scheduleDispatchEvent(Event::create(eventNames().negotiationneededEvent, false, false));
}
void RTCPeerConnection::didGenerateIceCandidate(PassRefPtr<RTCIceCandidateDescriptor> iceCandidateDescriptor)
{
ASSERT(scriptExecutionContext()->isContextThread());
if (!iceCandidateDescriptor)
- dispatchEvent(RTCIceCandidateEvent::create(false, false, 0));
+ scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, 0));
else {
RefPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::create(iceCandidateDescriptor);
- dispatchEvent(RTCIceCandidateEvent::create(false, false, iceCandidate.release()));
+ scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCandidate.release()));
}
}
@@ -429,7 +430,7 @@
RefPtr<MediaStream> stream = MediaStream::create(scriptExecutionContext(), streamDescriptor);
m_remoteStreams->append(stream);
- dispatchEvent(MediaStreamEvent::create(eventNames().addstreamEvent, false, false, stream.release()));
+ scheduleDispatchEvent(MediaStreamEvent::create(eventNames().addstreamEvent, false, false, stream.release()));
}
void RTCPeerConnection::didRemoveRemoteStream(MediaStreamDescriptor* streamDescriptor)
@@ -446,7 +447,7 @@
ASSERT(m_remoteStreams->contains(stream.get()));
m_remoteStreams->remove(stream.get());
- dispatchEvent(MediaStreamEvent::create(eventNames().removestreamEvent, false, false, stream.release()));
+ scheduleDispatchEvent(MediaStreamEvent::create(eventNames().removestreamEvent, false, false, stream.release()));
}
const AtomicString& RTCPeerConnection::interfaceName() const
@@ -491,7 +492,7 @@
case ReadyStateOpening:
break;
case ReadyStateActive:
- dispatchEvent(Event::create(eventNames().openEvent, false, false));
+ scheduleDispatchEvent(Event::create(eventNames().openEvent, false, false));
break;
case ReadyStateClosing:
case ReadyStateClosed:
@@ -501,7 +502,7 @@
break;
}
- dispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
+ scheduleDispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
}
void RTCPeerConnection::changeIceState(IceState iceState)
@@ -510,9 +511,29 @@
return;
m_iceState = iceState;
- dispatchEvent(Event::create(eventNames().icechangeEvent, false, false));
+ scheduleDispatchEvent(Event::create(eventNames().icechangeEvent, false, false));
}
+void RTCPeerConnection::scheduleDispatchEvent(PassRefPtr<Event> event)
+{
+ m_scheduledEvents.append(event);
+
+ if (!m_scheduledEventTimer.isActive())
+ m_scheduledEventTimer.startOneShot(0);
+}
+
+void RTCPeerConnection::scheduledEventTimerFired(Timer<RTCPeerConnection>*)
+{
+ Vector<RefPtr<Event> > events;
+ events.swap(m_scheduledEvents);
+
+ Vector<RefPtr<Event> >::iterator it = events.begin();
+ for (; it != events.end(); ++it)
+ dispatchEvent((*it).release());
+
+ events.clear();
+}
+
} // namespace WebCore
#endif // ENABLE(MEDIA_STREAM)
« no previous file with comments | « Source/WebCore/Modules/mediastream/RTCPeerConnection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698