Bug 1675207 - Fail the websocket connection when there is no enough memory r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D99145
This commit is contained in:
Kershaw Chang
2020-12-11 09:35:05 +00:00
parent 514bb94009
commit 2cffa76813
5 changed files with 62 additions and 7 deletions

View File

@@ -860,6 +860,23 @@ WebSocketImpl::OnServerClose(nsISupports* aContext, uint16_t aCode,
return NS_OK;
}
NS_IMETHODIMP
WebSocketImpl::OnError() {
if (!IsTargetThread()) {
return Dispatch(
NS_NewRunnableFunction("dom::FailConnectionRunnable",
[self = RefPtr{this}]() {
self->FailConnection(
nsIWebSocketChannel::CLOSE_ABNORMAL);
}),
NS_DISPATCH_NORMAL);
}
AssertIsOnTargetThread();
FailConnection(nsIWebSocketChannel::CLOSE_ABNORMAL);
return NS_OK;
}
//-----------------------------------------------------------------------------
// WebSocketImpl::nsIInterfaceRequestor
//-----------------------------------------------------------------------------