Bug 1374047 - Keep WebSocketImpl alive before calling DisconnectInternal. r=smaug

--HG--
extra : rebase_source : 89a230a93132029be40dd620ac29a6698e88790f
This commit is contained in:
Andrea Marchesini 2017-07-10 15:19:36 -04:00
Родитель 22d94d1020
Коммит bded2d68fd
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -620,6 +620,10 @@ WebSocketImpl::Disconnect()
AssertIsOnTargetThread();
// DontKeepAliveAnyMore() and DisconnectInternal() can release the object. So
// hold a reference to this until the end of the method.
RefPtr<WebSocketImpl> kungfuDeathGrip = this;
// Disconnect can be called from some control event (such as Notify() of
// WorkerHolder). This will be schedulated before any other sync/async
// runnable. In order to prevent some double Disconnect() calls, we use this
@ -641,10 +645,6 @@ WebSocketImpl::Disconnect()
rv.SuppressException();
}
// DontKeepAliveAnyMore() can release the object. So hold a reference to this
// until the end of the method.
RefPtr<WebSocketImpl> kungfuDeathGrip = this;
NS_ReleaseOnMainThread("WebSocketImpl::mChannel", mChannel.forget());
NS_ReleaseOnMainThread("WebSocketImpl::mService", mService.forget());