diff --git a/dom/network/UDPSocket.cpp b/dom/network/UDPSocket.cpp index e275e3902936..e460428c7120 100644 --- a/dom/network/UDPSocket.cpp +++ b/dom/network/UDPSocket.cpp @@ -498,6 +498,11 @@ UDPSocket::InitRemote(const nsAString& aLocalAddress, return NS_ERROR_FAILURE; } + nsCOMPtr target; + if (nsCOMPtr global = GetOwnerGlobal()) { + target = global->EventTargetFor(TaskCategory::Other); + } + rv = sock->Bind(mListenerProxy, principal, NS_ConvertUTF16toUTF8(aLocalAddress), @@ -505,7 +510,8 @@ UDPSocket::InitRemote(const nsAString& aLocalAddress, mAddressReuse, mLoopback, 0, - 0); + 0, + target); if (NS_FAILED(rv)) { return rv; diff --git a/dom/network/UDPSocketChild.cpp b/dom/network/UDPSocketChild.cpp index bade0f7dd26b..208ce7bcf645 100644 --- a/dom/network/UDPSocketChild.cpp +++ b/dom/network/UDPSocketChild.cpp @@ -165,7 +165,8 @@ UDPSocketChild::Bind(nsIUDPSocketInternal* aSocket, bool aAddressReuse, bool aLoopback, uint32_t recvBufferSize, - uint32_t sendBufferSize) + uint32_t sendBufferSize, + nsIEventTarget* aMainThreadEventTarget) { UDPSOCKET_LOG(("%s: %s:%u", __FUNCTION__, PromiseFlatCString(aHost).get(), aPort)); @@ -180,6 +181,9 @@ UDPSocketChild::Bind(nsIUDPSocketInternal* aSocket, MOZ_ASSERT(!aPrincipal); mBackgroundManager->SendPUDPSocketConstructor(this, void_t(), mFilterName); } else { + if (aMainThreadEventTarget) { + gNeckoChild->SetEventTargetForActor(this, aMainThreadEventTarget); + } gNeckoChild->SendPUDPSocketConstructor(this, IPC::Principal(aPrincipal), mFilterName); } diff --git a/dom/network/interfaces/nsIUDPSocketChild.idl b/dom/network/interfaces/nsIUDPSocketChild.idl index 3a07fae66533..61d80d42b835 100644 --- a/dom/network/interfaces/nsIUDPSocketChild.idl +++ b/dom/network/interfaces/nsIUDPSocketChild.idl @@ -8,6 +8,7 @@ interface nsIUDPSocketInternal; interface nsIInputStream; interface nsIPrincipal; +interface nsIEventTarget; %{ C++ namespace mozilla { @@ -33,7 +34,8 @@ interface nsIUDPSocketChild : nsISupports void bind(in nsIUDPSocketInternal socket, in nsIPrincipal principal, in AUTF8String host, in unsigned short port, in bool addressReuse, in bool loopback, in uint32_t recvBufferSize, - in uint32_t sendBufferSize); + in uint32_t sendBufferSize, + [optional] in nsIEventTarget mainThreadTarget); // Tell the chrome process to connect the UDP socket to a given remote host and port void connect(in nsIUDPSocketInternal socket, in AUTF8String host, in unsigned short port); diff --git a/media/mtransport/nr_socket_prsock.cpp b/media/mtransport/nr_socket_prsock.cpp index d43280ce67d9..5ec26cc53421 100644 --- a/media/mtransport/nr_socket_prsock.cpp +++ b/media/mtransport/nr_socket_prsock.cpp @@ -1580,7 +1580,8 @@ void NrUdpSocketIpc::create_i(const nsACString &host, const uint16_t port) { /* reuse = */ false, /* loopback = */ false, /* recv buffer size */ minBuffSize, - /* send buffer size */ minBuffSize))) { + /* send buffer size */ minBuffSize, + /* mainThreadEventTarget */ nullptr))) { err_ = true; MOZ_ASSERT(false, "Failed to create UDP socket"); mon.NotifyAll();