From 5736de1d3fafac3df750bbe4e798d1b6ff460ad1 Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Thu, 21 May 2015 10:42:05 -0700 Subject: [PATCH] Bug 1167274 - Do the right thing when accessing the proxyinfo fails for some reason. r=mt --- .../peerconnection/PeerConnectionMedia.cpp | 72 +++++++++++-------- .../src/peerconnection/PeerConnectionMedia.h | 5 +- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp index e0e66b43c35..3c772767d2b 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp @@ -162,46 +162,56 @@ OnProxyAvailable(nsICancelable *request, nsIChannel *aChannel, nsIProxyInfo *proxyinfo, nsresult result) { + + if (result == NS_ERROR_ABORT) { + // NS_ERROR_ABORT means that the PeerConnectionMedia is no longer waiting + return NS_OK; + } + CSFLogInfo(logTag, "%s: Proxy Available: %d", __FUNCTION__, (int)result); if (NS_SUCCEEDED(result) && proxyinfo) { - CSFLogInfo(logTag, "%s: Had proxyinfo", __FUNCTION__); - nsresult rv; - nsCString httpsProxyHost; - int32_t httpsProxyPort; - - rv = proxyinfo->GetHost(httpsProxyHost); - if (NS_FAILED(rv)) { - CSFLogError(logTag, "%s: Failed to get proxy server host", __FUNCTION__); - return rv; - } - - rv = proxyinfo->GetPort(&httpsProxyPort); - if (NS_FAILED(rv)) { - CSFLogError(logTag, "%s: Failed to get proxy server port", __FUNCTION__); - return rv; - } - - if (pcm_->mIceCtx.get()) { - assert(httpsProxyPort >= 0 && httpsProxyPort < (1 << 16)); - pcm_->mProxyServer.reset( - new NrIceProxyServer(httpsProxyHost.get(), - static_cast(httpsProxyPort))); - } else { - CSFLogError(logTag, "%s: Failed to set proxy server (ICE ctx unavailable)", - __FUNCTION__); - } + SetProxyOnPcm(*proxyinfo); } - if (result != NS_ERROR_ABORT) { - // NS_ERROR_ABORT means that the PeerConnectionMedia is no longer waiting - pcm_->mProxyResolveCompleted = true; - pcm_->FlushIceCtxOperationQueueIfReady(); - } + pcm_->mProxyResolveCompleted = true; + pcm_->FlushIceCtxOperationQueueIfReady(); return NS_OK; } +void +PeerConnectionMedia::ProtocolProxyQueryHandler::SetProxyOnPcm( + nsIProxyInfo& proxyinfo) +{ + CSFLogInfo(logTag, "%s: Had proxyinfo", __FUNCTION__); + nsresult rv; + nsCString httpsProxyHost; + int32_t httpsProxyPort; + + rv = proxyinfo.GetHost(httpsProxyHost); + if (NS_FAILED(rv)) { + CSFLogError(logTag, "%s: Failed to get proxy server host", __FUNCTION__); + return; + } + + rv = proxyinfo.GetPort(&httpsProxyPort); + if (NS_FAILED(rv)) { + CSFLogError(logTag, "%s: Failed to get proxy server port", __FUNCTION__); + return; + } + + if (pcm_->mIceCtx.get()) { + assert(httpsProxyPort >= 0 && httpsProxyPort < (1 << 16)); + pcm_->mProxyServer.reset( + new NrIceProxyServer(httpsProxyHost.get(), + static_cast(httpsProxyPort))); + } else { + CSFLogError(logTag, "%s: Failed to set proxy server (ICE ctx unavailable)", + __FUNCTION__); + } +} + NS_IMPL_ISUPPORTS(PeerConnectionMedia::ProtocolProxyQueryHandler, nsIProtocolProxyCallback) #endif // !defined(MOZILLA_XPCOMRT_API) diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h index ee898d90bfb..fb9d7768e31 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h @@ -407,8 +407,9 @@ class PeerConnectionMedia : public sigslot::has_slots<> { NS_DECL_ISUPPORTS private: - RefPtr pcm_; - virtual ~ProtocolProxyQueryHandler() {} + void SetProxyOnPcm(nsIProxyInfo& proxyinfo); + RefPtr pcm_; + virtual ~ProtocolProxyQueryHandler() {} }; #endif // !defined(MOZILLA_XPCOMRT_API)