Bug 944854 - Avoid triggering harmless assertion on PeerConnectionObserver weakref. r=abr

This commit is contained in:
Jan-Ivar Bruaroey 2013-12-03 09:02:07 -05:00
parent c4fd8f4be2
commit 06185186a7

View File

@ -992,15 +992,18 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
// Without it, each weak-ref call in this file would look like this:
//
// nsCOMPtr<nsISupportsWeakReference> tmp = do_QueryReferent(mPCObserver);
// nsRefPtr<nsSupportsWeakReference> tmp2 = do_QueryObject(tmp);
// nsRefPtr<PeerConnectionObserver> pco = static_cast<PeerConnectionObserver*>(&*tmp2);
// if (!pco) {
// if (!tmp) {
// return;
// }
// nsRefPtr<nsSupportsWeakReference> tmp2 = do_QueryObject(tmp);
// nsRefPtr<PeerConnectionObserver> pco = static_cast<PeerConnectionObserver*>(&*tmp2);
static already_AddRefed<PeerConnectionObserver>
do_QueryObjectReferent(nsIWeakReference* aRawPtr) {
nsCOMPtr<nsISupportsWeakReference> tmp = do_QueryReferent(aRawPtr);
if (!tmp) {
return nullptr;
}
nsRefPtr<nsSupportsWeakReference> tmp2 = do_QueryObject(tmp);
nsRefPtr<PeerConnectionObserver> tmp3 = static_cast<PeerConnectionObserver*>(&*tmp2);
return tmp3.forget();