зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551836: Ensure that we clean up PeerConnectionMedia properly when PeerConnectionImpl::Initialize fails. r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D33071 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
03db50b16c
Коммит
cd2822bab9
|
@ -371,6 +371,7 @@ PeerConnectionImpl::~PeerConnectionImpl() {
|
|||
// probably want to shut it down more aggressively to save memory. We
|
||||
// could shut down here when there are no uses. It might be more optimal
|
||||
// to release off a timer (and XPCOM Shutdown) to avoid churn
|
||||
ShutdownMedia();
|
||||
}
|
||||
|
||||
nsresult PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
|
||||
|
@ -469,27 +470,6 @@ nsresult PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mMedia = new PeerConnectionMedia(this);
|
||||
|
||||
// Connect ICE slots.
|
||||
mMedia->SignalIceGatheringStateChange.connect(
|
||||
this, &PeerConnectionImpl::IceGatheringStateChange);
|
||||
mMedia->SignalUpdateDefaultCandidate.connect(
|
||||
this, &PeerConnectionImpl::UpdateDefaultCandidate);
|
||||
mMedia->SignalIceConnectionStateChange.connect(
|
||||
this, &PeerConnectionImpl::IceConnectionStateChange);
|
||||
|
||||
mMedia->SignalCandidate.connect(this, &PeerConnectionImpl::CandidateReady);
|
||||
|
||||
// Initialize the media object.
|
||||
res = mMedia->Init();
|
||||
if (NS_FAILED(res)) {
|
||||
CSFLogError(LOGTAG, "%s: Couldn't initialize media object", __FUNCTION__);
|
||||
return res;
|
||||
}
|
||||
|
||||
PeerConnectionCtx::GetInstance()->mPeerConnections[mHandle] = this;
|
||||
|
||||
mJsepSession =
|
||||
MakeUnique<JsepSessionImpl>(mName, MakeUnique<PCUuidGenerator>());
|
||||
|
||||
|
@ -523,6 +503,27 @@ nsresult PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
|
|||
return res;
|
||||
}
|
||||
|
||||
mMedia = new PeerConnectionMedia(this);
|
||||
|
||||
// Initialize the media object.
|
||||
res = mMedia->Init();
|
||||
if (NS_FAILED(res)) {
|
||||
CSFLogError(LOGTAG, "%s: Couldn't initialize media object", __FUNCTION__);
|
||||
ShutdownMedia();
|
||||
return res;
|
||||
}
|
||||
|
||||
// Connect ICE slots.
|
||||
mMedia->SignalIceGatheringStateChange.connect(
|
||||
this, &PeerConnectionImpl::IceGatheringStateChange);
|
||||
mMedia->SignalUpdateDefaultCandidate.connect(
|
||||
this, &PeerConnectionImpl::UpdateDefaultCandidate);
|
||||
mMedia->SignalIceConnectionStateChange.connect(
|
||||
this, &PeerConnectionImpl::IceConnectionStateChange);
|
||||
mMedia->SignalCandidate.connect(this, &PeerConnectionImpl::CandidateReady);
|
||||
|
||||
PeerConnectionCtx::GetInstance()->mPeerConnections[mHandle] = this;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче