void BroadcastChannel::SetOnmessage(EventHandlerNonNull* aCallback) { if (NS_IsMainThread()) { SetEventHandler(nsGkAtoms::onmessage, EmptyString(), aCallback); } else { SetEventHandler(nullptr, NS_LITERAL_STRING("message"), aCallback); } UpdateMustKeepAlive(); }
void BroadcastChannel::RemoveEventListener(const nsAString& aType, EventListener* aCallback, bool aCapture, ErrorResult& aRv) { DOMEventTargetHelper::RemoveEventListener(aType, aCallback, aCapture, aRv); if (aRv.Failed()) { return; } UpdateMustKeepAlive(); }
void BroadcastChannel::AddEventListener(const nsAString& aType, EventListener* aCallback, bool aCapture, const dom::Nullable<bool>& aWantsUntrusted, ErrorResult& aRv) { DOMEventTargetHelper::AddEventListener(aType, aCallback, aCapture, aWantsUntrusted, aRv); if (aRv.Failed()) { return; } UpdateMustKeepAlive(); }
NS_IMETHODIMP WebSocket::OnStart(nsISupports* aContext) { NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread"); // This is the only function that sets OPEN, and should be called only once MOZ_ASSERT(mReadyState != WebSocket::OPEN, "readyState already OPEN! OnStart called twice?"); // Nothing to do if we've already closed/closing if (mReadyState != WebSocket::CONNECTING) { return NS_OK; } // Attempt to kill "ghost" websocket: but usually too early for check to fail nsresult rv = CheckInnerWindowCorrectness(); if (NS_FAILED(rv)) { CloseConnection(nsIWebSocketChannel::CLOSE_GOING_AWAY); return rv; } if (!mRequestedProtocolList.IsEmpty()) { mChannel->GetProtocol(mEstablishedProtocol); } mChannel->GetExtensions(mEstablishedExtensions); UpdateURI(); mReadyState = WebSocket::OPEN; // Call 'onopen' rv = CreateAndDispatchSimpleEvent(NS_LITERAL_STRING("open")); if (NS_FAILED(rv)) { NS_WARNING("Failed to dispatch the open event"); } UpdateMustKeepAlive(); return NS_OK; }