Bug 822158: Use async dispatch of Ice(Gathering)Completed to unwind stack r=jesup,ekr

This commit is contained in:
Jan-Ivar Bruaroey 2012-12-21 15:21:15 -05:00
Родитель fb807cea7c
Коммит fc51b305da
3 изменённых файлов: 20 добавлений и 10 удалений

Просмотреть файл

@ -896,6 +896,8 @@ PeerConnectionImpl::CheckApiState(bool assert_ice_ready) const
if (mReadyState == kClosed)
return NS_ERROR_FAILURE;
if (!mMedia)
return NS_ERROR_FAILURE;
return NS_OK;
}
@ -1045,17 +1047,19 @@ PeerConnectionImpl::GetHandle()
void
PeerConnectionImpl::IceGatheringCompleted(NrIceCtx *aCtx)
{
// Do an async call here to unwind the stack. refptr keeps the PC alive.
nsRefPtr<PeerConnectionImpl> pc(this);
RUN_ON_THREAD(mThread,
WrapRunnable(this,
WrapRunnable(pc,
&PeerConnectionImpl::IceGatheringCompleted_m,
aCtx),
NS_DISPATCH_SYNC);
NS_DISPATCH_NORMAL);
}
void
nsresult
PeerConnectionImpl::IceGatheringCompleted_m(NrIceCtx *aCtx)
{
PC_AUTO_ENTER_API_CALL_NO_CHECK();
PC_AUTO_ENTER_API_CALL(false);
MOZ_ASSERT(aCtx);
CSFLogDebugS(logTag, __FUNCTION__ << ": ctx: " << static_cast<void*>(aCtx));
@ -1072,22 +1076,25 @@ PeerConnectionImpl::IceGatheringCompleted_m(NrIceCtx *aCtx)
NS_DISPATCH_NORMAL);
}
#endif
return NS_OK;
}
void
PeerConnectionImpl::IceCompleted(NrIceCtx *aCtx)
{
// Do an async call here to unwind the stack. refptr keeps the PC alive.
nsRefPtr<PeerConnectionImpl> pc(this);
RUN_ON_THREAD(mThread,
WrapRunnable(this,
WrapRunnable(pc,
&PeerConnectionImpl::IceCompleted_m,
aCtx),
NS_DISPATCH_SYNC);
NS_DISPATCH_NORMAL);
}
void
nsresult
PeerConnectionImpl::IceCompleted_m(NrIceCtx *aCtx)
{
PC_AUTO_ENTER_API_CALL_NO_CHECK();
PC_AUTO_ENTER_API_CALL(false);
MOZ_ASSERT(aCtx);
CSFLogDebugS(logTag, __FUNCTION__ << ": ctx: " << static_cast<void*>(aCtx));
@ -1104,6 +1111,7 @@ PeerConnectionImpl::IceCompleted_m(NrIceCtx *aCtx)
NS_DISPATCH_NORMAL);
}
#endif
return NS_OK;
}
void

Просмотреть файл

@ -217,8 +217,8 @@ private:
void ShutdownMedia(bool isSynchronous);
// ICE callbacks run on the right thread.
void IceGatheringCompleted_m(NrIceCtx *aCtx);
void IceCompleted_m(NrIceCtx *aCtx);
nsresult IceGatheringCompleted_m(NrIceCtx *aCtx);
nsresult IceCompleted_m(NrIceCtx *aCtx);
// The role we are adopting
Role mRole;

Просмотреть файл

@ -245,6 +245,8 @@ PeerConnectionMedia::DisconnectMediaStreams()
void
PeerConnectionMedia::ShutdownMediaTransport()
{
mIceCtx->SignalCompleted.disconnect(this);
mIceCtx->SignalGatheringCompleted.disconnect(this);
mTransportFlows.clear();
mIceStreams.clear();
mIceCtx = NULL;