Bug 855796 - vcmOnSdpParseError should be dispatched to main thread r=abr

This commit is contained in:
Ethan Hugg 2013-03-29 13:11:19 -07:00
parent ffc494cab7
commit beea5eb77e

View File

@ -83,6 +83,14 @@ static mozilla::RefPtr<TransportFlow> vcmCreateTransportFlow(sipcc::PeerConnecti
} \
} while(0)
#define ENSURE_PC_NO_RET(pc, peerconnection) \
do { \
if (!pc.impl()) { \
CSFLogDebug(logTag, "%s: couldn't acquire peerconnection %s", __FUNCTION__, peerconnection); \
return; \
} \
} while(0)
VcmSIPCCBinding::VcmSIPCCBinding ()
: streamObserver(NULL)
{
@ -2697,19 +2705,50 @@ vcmCreateTransportFlow(sipcc::PeerConnectionImpl *pc, int level, bool rtcp,
/**
* vcmOnSdpParseError
* vcmOnSdpParseError_m
*
* This method is called for each parsing error of SDP. It does not necessarily
* mean the SDP read was fatal and can be called many times for the same SDP.
*
* This function should only be called on the main thread.
*
*/
static void vcmOnSdpParseError_m(nsAutoPtr<std::string> peerconnection,
nsAutoPtr<std::string> message) {
sipcc::PeerConnectionWrapper pc(peerconnection->c_str());
ENSURE_PC_NO_RET(pc, peerconnection->c_str());
pc.impl()->OnSdpParseError(message->c_str());
}
/**
* vcmOnSdpParseError
*
* Dispatch the static version of this function on the main thread.
* The string parameters are autoptr in order to survive the DISPATCH_NORMAL
*
*/
int vcmOnSdpParseError(const char *peerconnection, const char *message) {
MOZ_ASSERT(peerconnection);
MOZ_ASSERT(message);
nsAutoPtr<std::string> peerconnectionDuped(new std::string(peerconnection));
nsAutoPtr<std::string> messageDuped(new std::string(message));
sipcc::PeerConnectionWrapper pc(peerconnection);
ENSURE_PC(pc, VCM_ERROR);
// Now DISPATCH_NORMAL with the duped strings
nsresult rv = VcmSIPCCBinding::getMainThread()->Dispatch(
WrapRunnableNM(&vcmOnSdpParseError_m,
peerconnectionDuped,
messageDuped),
NS_DISPATCH_NORMAL);
pc.impl()->OnSdpParseError(message);
if (!NS_SUCCEEDED(rv)) {
CSFLogError( logTag, "%s(): Could not dispatch to main thread", __FUNCTION__);
return VCM_ERROR;
}
return 0;
}