mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset fce8528ac1e2 (bug 1111971) for M-1/M-4 Test failures on a CLOSED TREE
This commit is contained in:
parent
8f391a6bc0
commit
cf45b45207
@ -646,14 +646,13 @@ WebSocketImpl::DoOnMessageAvailable(const nsACString& aMsg, bool isBinary)
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch the message event");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
} else {
|
||||
// CLOSING should be the only other state where it's possible to get msgs
|
||||
// from channel: Spec says to drop them.
|
||||
MOZ_ASSERT(readyState == WebSocket::CLOSING,
|
||||
"Received message while CONNECTING or CLOSED");
|
||||
}
|
||||
|
||||
// CLOSING should be the only other state where it's possible to get msgs
|
||||
// from channel: Spec says to drop them.
|
||||
MOZ_ASSERT(readyState == WebSocket::CLOSING,
|
||||
"Received message while CONNECTING or CLOSED");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -719,17 +718,14 @@ WebSocketImpl::OnStart(nsISupports* aContext)
|
||||
|
||||
mWebSocket->SetReadyState(WebSocket::OPEN);
|
||||
|
||||
// Let's keep the object alive because the webSocket can be CCed in the
|
||||
// onopen callback.
|
||||
nsRefPtr<WebSocket> webSocket = mWebSocket;
|
||||
|
||||
// Call 'onopen'
|
||||
rv = webSocket->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open"));
|
||||
rv = mWebSocket->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open"));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch the open event");
|
||||
}
|
||||
|
||||
webSocket->UpdateMustKeepAlive();
|
||||
mWebSocket->UpdateMustKeepAlive();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1600,27 +1596,23 @@ WebSocketImpl::DispatchConnectionCloseEvents()
|
||||
|
||||
mWebSocket->SetReadyState(WebSocket::CLOSED);
|
||||
|
||||
// Let's keep the object alive because the webSocket can be CCed in the
|
||||
// onerror or in the onclose callback.
|
||||
nsRefPtr<WebSocket> webSocket = mWebSocket;
|
||||
|
||||
// Call 'onerror' if needed
|
||||
if (mFailed) {
|
||||
nsresult rv =
|
||||
webSocket->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error"));
|
||||
mWebSocket->CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("error"));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch the error event");
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = webSocket->CreateAndDispatchCloseEvent(mCloseEventWasClean,
|
||||
mCloseEventCode,
|
||||
mCloseEventReason);
|
||||
nsresult rv = mWebSocket->CreateAndDispatchCloseEvent(mCloseEventWasClean,
|
||||
mCloseEventCode,
|
||||
mCloseEventReason);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch the close event");
|
||||
}
|
||||
|
||||
webSocket->UpdateMustKeepAlive();
|
||||
mWebSocket->UpdateMustKeepAlive();
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
|
@ -72,22 +72,6 @@ extern PRThread *gSocketThread;
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::net;
|
||||
|
||||
static void
|
||||
ReleaseListenerAndContext(nsCOMPtr<nsIWebSocketListener>& aListener,
|
||||
nsCOMPtr<nsISupports>& aContext)
|
||||
{
|
||||
nsCOMPtr<nsIThread> mainThread;
|
||||
NS_GetMainThread(getter_AddRefs(mainThread));
|
||||
|
||||
if (aListener) {
|
||||
NS_ProxyRelease(mainThread, aListener, false);
|
||||
}
|
||||
|
||||
if (aContext) {
|
||||
NS_ProxyRelease(mainThread, aContext, false);
|
||||
}
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
@ -571,9 +555,9 @@ class CallOnMessageAvailable MOZ_FINAL : public nsIRunnable
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
CallOnMessageAvailable(WebSocketChannel* aChannel,
|
||||
nsACString& aData,
|
||||
int32_t aLen)
|
||||
CallOnMessageAvailable(WebSocketChannel *aChannel,
|
||||
nsCString &aData,
|
||||
int32_t aLen)
|
||||
: mChannel(aChannel),
|
||||
mData(aData),
|
||||
mLen(aLen) {}
|
||||
@ -582,14 +566,10 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(mChannel->IsOnTargetThread());
|
||||
|
||||
if (mChannel->mListener) {
|
||||
if (mLen < 0) {
|
||||
mChannel->mListener->OnMessageAvailable(mChannel->mContext, mData);
|
||||
} else {
|
||||
mChannel->mListener->OnBinaryMessageAvailable(mChannel->mContext, mData);
|
||||
}
|
||||
}
|
||||
|
||||
if (mLen < 0)
|
||||
mChannel->mListener->OnMessageAvailable(mChannel->mContext, mData);
|
||||
else
|
||||
mChannel->mListener->OnBinaryMessageAvailable(mChannel->mContext, mData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -611,16 +591,10 @@ class CallOnStop MOZ_FINAL : public nsIRunnable
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
// CallOnStop steals mListener and mContext from the aChannel in order to
|
||||
// release them on the main thread when needed.
|
||||
CallOnStop(WebSocketChannel* aChannel,
|
||||
nsresult aReason)
|
||||
CallOnStop(WebSocketChannel *aChannel,
|
||||
nsresult aReason)
|
||||
: mChannel(aChannel),
|
||||
mReason(aReason)
|
||||
{
|
||||
mListener.swap(mChannel->mListener);
|
||||
mContext.swap(mChannel->mContext);
|
||||
}
|
||||
mReason(aReason) {}
|
||||
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE
|
||||
{
|
||||
@ -628,11 +602,11 @@ public:
|
||||
|
||||
nsWSAdmissionManager::OnStopSession(mChannel, mReason);
|
||||
|
||||
if (mListener) {
|
||||
mListener->OnStop(mContext, mReason);
|
||||
ReleaseListenerAndContext(mListener, mContext);
|
||||
if (mChannel->mListener) {
|
||||
mChannel->mListener->OnStop(mChannel->mContext, mReason);
|
||||
mChannel->mListener = nullptr;
|
||||
mChannel->mContext = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -640,8 +614,6 @@ private:
|
||||
~CallOnStop() {}
|
||||
|
||||
nsRefPtr<WebSocketChannel> mChannel;
|
||||
nsCOMPtr<nsIWebSocketListener> mListener;
|
||||
nsCOMPtr<nsISupports> mContext;
|
||||
nsresult mReason;
|
||||
};
|
||||
NS_IMPL_ISUPPORTS(CallOnStop, nsIRunnable)
|
||||
@ -655,9 +627,9 @@ class CallOnServerClose MOZ_FINAL : public nsIRunnable
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
CallOnServerClose(WebSocketChannel* aChannel,
|
||||
uint16_t aCode,
|
||||
nsACString& aReason)
|
||||
CallOnServerClose(WebSocketChannel *aChannel,
|
||||
uint16_t aCode,
|
||||
nsCString &aReason)
|
||||
: mChannel(aChannel),
|
||||
mCode(aCode),
|
||||
mReason(aReason) {}
|
||||
@ -666,9 +638,7 @@ public:
|
||||
{
|
||||
MOZ_ASSERT(mChannel->IsOnTargetThread());
|
||||
|
||||
if (mChannel->mListener) {
|
||||
mChannel->mListener->OnServerClose(mChannel->mContext, mCode, mReason);
|
||||
}
|
||||
mChannel->mListener->OnServerClose(mChannel->mContext, mCode, mReason);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -688,8 +658,8 @@ NS_IMPL_ISUPPORTS(CallOnServerClose, nsIRunnable)
|
||||
class CallAcknowledge MOZ_FINAL : public nsCancelableRunnable
|
||||
{
|
||||
public:
|
||||
CallAcknowledge(WebSocketChannel* aChannel,
|
||||
uint32_t aSize)
|
||||
CallAcknowledge(WebSocketChannel *aChannel,
|
||||
uint32_t aSize)
|
||||
: mChannel(aChannel),
|
||||
mSize(aSize) {}
|
||||
|
||||
@ -698,9 +668,7 @@ public:
|
||||
MOZ_ASSERT(mChannel->IsOnTargetThread());
|
||||
|
||||
LOG(("WebSocketChannel::CallAcknowledge: Size %u\n", mSize));
|
||||
if (mChannel->mListener) {
|
||||
mChannel->mListener->OnAcknowledge(mChannel->mContext, mSize);
|
||||
}
|
||||
mChannel->mListener->OnAcknowledge(mChannel->mContext, mSize);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1206,7 +1174,17 @@ WebSocketChannel::~WebSocketChannel()
|
||||
NS_ProxyRelease(mainThread, forgettable, false);
|
||||
}
|
||||
|
||||
ReleaseListenerAndContext(mListener, mContext);
|
||||
if (mListener) {
|
||||
nsIWebSocketListener *forgettableListener;
|
||||
mListener.forget(&forgettableListener);
|
||||
NS_ProxyRelease(mainThread, forgettableListener, false);
|
||||
}
|
||||
|
||||
if (mContext) {
|
||||
nsISupports *forgettableContext;
|
||||
mContext.forget(&forgettableContext);
|
||||
NS_ProxyRelease(mainThread, forgettableContext, false);
|
||||
}
|
||||
|
||||
if (mLoadGroup) {
|
||||
nsILoadGroup *forgettableGroup;
|
||||
@ -2287,17 +2265,8 @@ WebSocketChannel::StopSession(nsresult reason)
|
||||
|
||||
if (!mCalledOnStop) {
|
||||
mCalledOnStop = 1;
|
||||
|
||||
nsWSAdmissionManager::OnStopSession(this, reason);
|
||||
|
||||
nsRefPtr<CallOnStop> runnable = new CallOnStop(this, reason);
|
||||
|
||||
// CallOnStop steals mListener and mContext in order to release them on the
|
||||
// main thread when needed.
|
||||
MOZ_ASSERT(!mListener);
|
||||
MOZ_ASSERT(!mContext);
|
||||
|
||||
mTargetThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
||||
mTargetThread->Dispatch(new CallOnStop(this, reason),
|
||||
NS_DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user