Bug 1240760: Update DataChannel::Close() r=mcmanus

MozReview-Commit-ID: 7nN9h3M3O8w
This commit is contained in:
Randell Jesup 2016-02-19 01:08:07 -05:00
parent f29e1e96ca
commit 5e9bb49bdd
2 changed files with 8 additions and 5 deletions

View File

@ -1778,7 +1778,7 @@ DataChannelConnection::HandleStreamResetEvent(const struct sctp_stream_reset_eve
LOG(("Disconnected DataChannel %p from connection %p",
(void *) channel.get(), (void *) channel->mConnection.get()));
channel->Destroy();
channel->DestroyLocked();
// At this point when we leave here, the object is a zombie held alive only by the DOM object
} else {
LOG(("Can't find incoming channel %d",i));
@ -2502,7 +2502,7 @@ DataChannelConnection::CloseInt(DataChannel *aChannel)
aChannel->mState = CLOSING;
if (mState == CLOSED) {
// we're not going to hang around waiting
channel->Destroy();
channel->DestroyLocked();
}
// At this point when we leave here, the object is a zombie held alive only by the DOM object
}
@ -2556,13 +2556,15 @@ void
DataChannel::Close()
{
ENSURE_DATACONNECTION;
RefPtr<DataChannelConnection> connection(mConnection);
mConnection->Close(this);
}
// Used when disconnecting from the DataChannelConnection
void
DataChannel::Destroy()
DataChannel::DestroyLocked()
{
mConnection->mLock.AssertCurrentThreadOwns();
ENSURE_DATACONNECTION;
LOG(("Destroying Data channel %u", mStream));

View File

@ -337,10 +337,11 @@ private:
~DataChannel();
public:
void Destroy(); // when we disconnect from the connection after stream RESET
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DataChannel)
// when we disconnect from the connection after stream RESET
void DestroyLocked();
// Close this DataChannel. Can be called multiple times. MUST be called
// before destroying the DataChannel (state must be CLOSED or CLOSING).
void Close();