зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 259ad0fe9f08 (bug 1675207) for build bustages on WebSocketChannelChild.h. CLOSED TREE
This commit is contained in:
Родитель
b86715288c
Коммит
63e133ae53
|
@ -860,23 +860,6 @@ 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
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -294,44 +294,22 @@ class MessageEvent : public WebSocketEvent {
|
|||
bool mBinary;
|
||||
};
|
||||
|
||||
bool WebSocketChannelChild::RecvOnMessageAvailableInternal(
|
||||
void WebSocketChannelChild::RecvOnMessageAvailableInternal(
|
||||
const nsDependentCSubstring& aMsg, bool aMoreData, bool aBinary) {
|
||||
if (aMoreData) {
|
||||
return mReceivedMsgBuffer.Append(aMsg, fallible);
|
||||
}
|
||||
|
||||
if (!mReceivedMsgBuffer.Append(aMsg, fallible)) {
|
||||
return false;
|
||||
mReceivedMsgBuffer.Append(aMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
mReceivedMsgBuffer.Append(aMsg);
|
||||
mEventQ->RunOrEnqueue(new EventTargetDispatcher(
|
||||
this, new MessageEvent(mReceivedMsgBuffer, aBinary), mTargetThread));
|
||||
mReceivedMsgBuffer.Truncate();
|
||||
return true;
|
||||
}
|
||||
|
||||
class ErrorEvent : public WebSocketEvent {
|
||||
public:
|
||||
ErrorEvent() = default;
|
||||
|
||||
void Run(WebSocketChannelChild* aChild) override { aChild->OnError(); }
|
||||
};
|
||||
|
||||
void WebSocketChannelChild::OnError() {
|
||||
LOG(("WebSocketChannelChild::OnError() %p", this));
|
||||
if (mListenerMT) {
|
||||
AutoEventEnqueuer ensureSerialDispatch(mEventQ);
|
||||
Unused << mListenerMT->mListener->OnError();
|
||||
}
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult WebSocketChannelChild::RecvOnMessageAvailable(
|
||||
const nsDependentCSubstring& aMsg, const bool& aMoreData) {
|
||||
if (!RecvOnMessageAvailableInternal(aMsg, aMoreData, false)) {
|
||||
LOG(("WebSocketChannelChild %p append message failed", this));
|
||||
mEventQ->RunOrEnqueue(
|
||||
new EventTargetDispatcher(this, new ErrorEvent(), mTargetThread));
|
||||
}
|
||||
RecvOnMessageAvailableInternal(aMsg, aMoreData, false);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -353,11 +331,7 @@ void WebSocketChannelChild::OnMessageAvailable(const nsCString& aMsg) {
|
|||
|
||||
mozilla::ipc::IPCResult WebSocketChannelChild::RecvOnBinaryMessageAvailable(
|
||||
const nsDependentCSubstring& aMsg, const bool& aMoreData) {
|
||||
if (!RecvOnMessageAvailableInternal(aMsg, aMoreData, true)) {
|
||||
LOG(("WebSocketChannelChild %p append message failed", this));
|
||||
mEventQ->RunOrEnqueue(
|
||||
new EventTargetDispatcher(this, new ErrorEvent(), mTargetThread));
|
||||
}
|
||||
RecvOnMessageAvailableInternal(aMsg, aMoreData, true);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -82,11 +82,9 @@ class WebSocketChannelChild final : public BaseWebSocketChannel,
|
|||
// This function tries to get a labeled event target for |mNeckoTarget|.
|
||||
void SetupNeckoTarget();
|
||||
|
||||
bool RecvOnMessageAvailableInternal(const nsDependentCSubstring& aMsg,
|
||||
void RecvOnMessageAvailableInternal(const nsDependentCSubstring& aMsg,
|
||||
bool aMoreData, bool aBinary);
|
||||
|
||||
void OnError();
|
||||
|
||||
RefPtr<ChannelEventQueue> mEventQ;
|
||||
nsString mEffectiveURL;
|
||||
nsCString mReceivedMsgBuffer;
|
||||
|
@ -102,7 +100,6 @@ class WebSocketChannelChild final : public BaseWebSocketChannel,
|
|||
friend class AcknowledgeEvent;
|
||||
friend class ServerCloseEvent;
|
||||
friend class AsyncOpenFailedEvent;
|
||||
friend class ErrorEvent;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -307,9 +307,6 @@ WebSocketChannelParent::OnServerClose(nsISupports* aContext, uint16_t code,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebSocketChannelParent::OnError() { return NS_OK; }
|
||||
|
||||
void WebSocketChannelParent::ActorDestroy(ActorDestroyReason why) {
|
||||
LOG(("WebSocketChannelParent::ActorDestroy() %p\n", this));
|
||||
|
||||
|
|
|
@ -85,12 +85,6 @@ interface nsIWebSocketListener : nsISupports
|
|||
in unsigned short aCode,
|
||||
in AUTF8String aReason);
|
||||
|
||||
/**
|
||||
* Called to inform an error is happened. The connection will be closed
|
||||
* when this is called.
|
||||
*/
|
||||
[must_use] void OnError();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче