mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Backed out changeset 6ac3819ddc53 (bug 1853444) for causing wpt failures on sendorder.https.any.js. CLOSED TREE
This commit is contained in:
parent
dece16cb33
commit
ab0ad23e9c
@ -8,7 +8,6 @@
|
||||
|
||||
[Exposed=(Window,Worker), SecureContext, Pref="network.webtransport.enabled"]
|
||||
interface WebTransportSendStream : WritableStream {
|
||||
attribute long long? sendOrder;
|
||||
Promise<WebTransportSendStreamStats> getStats();
|
||||
};
|
||||
|
||||
|
@ -662,7 +662,7 @@ already_AddRefed<Promise> WebTransport::CreateBidirectionalStream(
|
||||
// pair
|
||||
mChild->SendCreateBidirectionalStream(
|
||||
sendOrder,
|
||||
[self = RefPtr{this}, sendOrder, promise](
|
||||
[self = RefPtr{this}, promise](
|
||||
BidirectionalStreamResponse&& aPipes) MOZ_CAN_RUN_SCRIPT_BOUNDARY {
|
||||
LOG(("CreateBidirectionalStream response"));
|
||||
if (BidirectionalStreamResponse::Tnsresult == aPipes.type()) {
|
||||
@ -688,7 +688,7 @@ already_AddRefed<Promise> WebTransport::CreateBidirectionalStream(
|
||||
WebTransportBidirectionalStream::Create(
|
||||
self, self->mGlobal, id,
|
||||
aPipes.get_BidirectionalStream().inStream(),
|
||||
aPipes.get_BidirectionalStream().outStream(), sendOrder, error);
|
||||
aPipes.get_BidirectionalStream().outStream(), error);
|
||||
LOG(("Returning a bidirectionalStream"));
|
||||
promise->MaybeResolve(newStream);
|
||||
},
|
||||
@ -733,8 +733,7 @@ already_AddRefed<Promise> WebTransport::CreateUnidirectionalStream(
|
||||
// Ask the parent to create the stream and send us the DataPipeSender
|
||||
mChild->SendCreateUnidirectionalStream(
|
||||
sendOrder,
|
||||
[self = RefPtr{this}, sendOrder,
|
||||
promise](UnidirectionalStreamResponse&& aResponse)
|
||||
[self = RefPtr{this}, promise](UnidirectionalStreamResponse&& aResponse)
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY {
|
||||
LOG(("CreateUnidirectionalStream response"));
|
||||
if (UnidirectionalStreamResponse::Tnsresult == aResponse.type()) {
|
||||
@ -765,8 +764,7 @@ already_AddRefed<Promise> WebTransport::CreateUnidirectionalStream(
|
||||
RefPtr<WebTransportSendStream> writableStream =
|
||||
WebTransportSendStream::Create(
|
||||
self, self->mGlobal, id,
|
||||
aResponse.get_UnidirectionalStream().outStream(), sendOrder,
|
||||
error);
|
||||
aResponse.get_UnidirectionalStream().outStream(), error);
|
||||
if (!writableStream) {
|
||||
promise->MaybeReject(std::move(error));
|
||||
return;
|
||||
@ -872,11 +870,6 @@ void WebTransport::Cleanup(WebTransportError* aError,
|
||||
NotifyToWindow(false);
|
||||
}
|
||||
|
||||
void WebTransport::SendSetSendOrder(uint64_t aStreamId,
|
||||
Maybe<int64_t> aSendOrder) {
|
||||
mChild->SendSetSendOrder(aStreamId, aSendOrder);
|
||||
}
|
||||
|
||||
void WebTransport::NotifyBFCacheOnMainThread(nsPIDOMWindowInner* aInner,
|
||||
bool aCreated) {
|
||||
AssertIsOnMainThread();
|
||||
|
@ -118,8 +118,6 @@ class WebTransport final : public nsISupports, public nsWrapperCache {
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY already_AddRefed<ReadableStream>
|
||||
IncomingUnidirectionalStreams();
|
||||
|
||||
void SendSetSendOrder(uint64_t aStreamId, Maybe<int64_t> aSendOrder);
|
||||
|
||||
void Shutdown() {}
|
||||
|
||||
private:
|
||||
|
@ -36,8 +36,7 @@ JSObject* WebTransportBidirectionalStream::WrapObject(
|
||||
already_AddRefed<WebTransportBidirectionalStream>
|
||||
WebTransportBidirectionalStream::Create(
|
||||
WebTransport* aWebTransport, nsIGlobalObject* aGlobal, uint64_t aStreamId,
|
||||
DataPipeReceiver* receiver, DataPipeSender* aSender,
|
||||
Maybe<int64_t> aSendOrder, ErrorResult& aRv) {
|
||||
DataPipeReceiver* receiver, DataPipeSender* sender, ErrorResult& aRv) {
|
||||
// https://w3c.github.io/webtransport/#pullbidirectionalstream (and
|
||||
// createBidirectionalStream)
|
||||
|
||||
@ -50,8 +49,8 @@ WebTransportBidirectionalStream::Create(
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<WebTransportSendStream> writableStream =
|
||||
WebTransportSendStream::Create(aWebTransport, aGlobal, aStreamId, aSender,
|
||||
aSendOrder, aRv);
|
||||
WebTransportSendStream::Create(aWebTransport, aGlobal, aStreamId, sender,
|
||||
aRv);
|
||||
if (!writableStream) {
|
||||
return nullptr;
|
||||
;
|
||||
|
@ -35,8 +35,7 @@ class WebTransportBidirectionalStream final : public nsISupports,
|
||||
static already_AddRefed<WebTransportBidirectionalStream> Create(
|
||||
WebTransport* aWebTransport, nsIGlobalObject* aGlobal, uint64_t aStreamId,
|
||||
::mozilla::ipc::DataPipeReceiver* receiver,
|
||||
::mozilla::ipc::DataPipeSender* aSender, Maybe<int64_t> aSendOrder,
|
||||
ErrorResult& aRv);
|
||||
::mozilla::ipc::DataPipeSender* sender, ErrorResult& aRv);
|
||||
|
||||
// WebIDL Boilerplate
|
||||
nsIGlobalObject* GetParentObject() const;
|
||||
|
@ -40,7 +40,7 @@ JSObject* WebTransportSendStream::WrapObject(
|
||||
/* static */
|
||||
already_AddRefed<WebTransportSendStream> WebTransportSendStream::Create(
|
||||
WebTransport* aWebTransport, nsIGlobalObject* aGlobal, uint64_t aStreamId,
|
||||
DataPipeSender* aSender, Maybe<int64_t> aSendOrder, ErrorResult& aRv) {
|
||||
DataPipeSender* sender, ErrorResult& aRv) {
|
||||
// https://w3c.github.io/webtransport/#webtransportsendstream-create
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(aGlobal)) {
|
||||
@ -50,16 +50,10 @@ already_AddRefed<WebTransportSendStream> WebTransportSendStream::Create(
|
||||
|
||||
auto stream = MakeRefPtr<WebTransportSendStream>(aGlobal, aWebTransport);
|
||||
|
||||
nsCOMPtr<nsIAsyncOutputStream> outputStream = aSender;
|
||||
nsCOMPtr<nsIAsyncOutputStream> outputStream = sender;
|
||||
auto algorithms = MakeRefPtr<WritableStreamToOutput>(
|
||||
stream->GetParentObject(), outputStream);
|
||||
|
||||
stream->mStreamId = aStreamId;
|
||||
|
||||
if (aSendOrder.isSome()) {
|
||||
stream->mSendOrder.SetValue(aSendOrder.value());
|
||||
}
|
||||
|
||||
// Steps 2-5
|
||||
RefPtr<QueuingStrategySize> writableSizeAlgorithm;
|
||||
stream->SetUpNative(cx, *algorithms, Nothing(), writableSizeAlgorithm, aRv);
|
||||
@ -80,12 +74,6 @@ already_AddRefed<WebTransportSendStream> WebTransportSendStream::Create(
|
||||
return stream.forget();
|
||||
}
|
||||
|
||||
void WebTransportSendStream::SetSendOrder(Nullable<int64_t> aSendOrder) {
|
||||
mSendOrder = aSendOrder;
|
||||
mTransport->SendSetSendOrder(
|
||||
mStreamId, aSendOrder.IsNull() ? Nothing() : Some(aSendOrder.Value()));
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> WebTransportSendStream::GetStats() {
|
||||
RefPtr<Promise> promise = Promise::CreateInfallible(WritableStream::mGlobal);
|
||||
promise->MaybeRejectWithNotSupportedError("GetStats isn't supported yet");
|
||||
|
@ -27,18 +27,13 @@ class WebTransportSendStream final : public WritableStream {
|
||||
|
||||
static already_AddRefed<WebTransportSendStream> Create(
|
||||
WebTransport* aWebTransport, nsIGlobalObject* aGlobal, uint64_t aStreamId,
|
||||
mozilla::ipc::DataPipeSender* aSender, Maybe<int64_t> aSendOrder,
|
||||
ErrorResult& aRv);
|
||||
mozilla::ipc::DataPipeSender* sender, ErrorResult& aRv);
|
||||
|
||||
// WebIDL Boilerplate
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// WebIDL Interface
|
||||
Nullable<int64_t> GetSendOrder() { return mSendOrder; }
|
||||
|
||||
void SetSendOrder(Nullable<int64_t> aSendOrder);
|
||||
|
||||
already_AddRefed<Promise> GetStats();
|
||||
|
||||
private:
|
||||
@ -49,8 +44,6 @@ class WebTransportSendStream final : public WritableStream {
|
||||
// CC runs. WebTransport::CleanUp() will destroy all the send and receive
|
||||
// streams, breaking the cycle.
|
||||
RefPtr<WebTransport> mTransport;
|
||||
uint64_t mStreamId;
|
||||
Nullable<int64_t> mSendOrder;
|
||||
};
|
||||
} // namespace mozilla::dom
|
||||
|
||||
|
@ -140,7 +140,7 @@ void WebTransportIncomingStreamsAlgorithms::BuildStream(JSContext* aCx,
|
||||
RefPtr<WebTransportBidirectionalStream> stream =
|
||||
WebTransportBidirectionalStream::Create(mTransport, mTransport->mGlobal,
|
||||
std::get<0>(tuple), input,
|
||||
output, Nothing(), aRv);
|
||||
output, aRv);
|
||||
|
||||
// Step 7.2 Enqueue stream to transport.[[IncomingBidirectionalStreams]].
|
||||
JS::Rooted<JS::Value> jsStream(aCx);
|
||||
|
@ -165,78 +165,61 @@ IPCResult WebTransportParent::RecvClose(const uint32_t& aCode,
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
class BidiReceiveStream : public nsIWebTransportStreamCallback {
|
||||
class ReceiveStream final : public nsIWebTransportStreamCallback {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIWEBTRANSPORTSTREAMCALLBACK
|
||||
|
||||
BidiReceiveStream(
|
||||
WebTransportParent::CreateBidirectionalStreamResolver&& aResolver,
|
||||
std::function<
|
||||
void(uint64_t, WebTransportParent::OnResetOrStopSendingCallback&&,
|
||||
nsIWebTransportBidirectionalStream* aStream)>&& aStreamCallback,
|
||||
Maybe<int64_t> aSendOrder, nsCOMPtr<nsISerialEventTarget>& aSocketThread)
|
||||
: mResolver(aResolver),
|
||||
mStreamCallback(std::move(aStreamCallback)),
|
||||
mSendOrder(aSendOrder),
|
||||
mSocketThread(aSocketThread) {}
|
||||
|
||||
private:
|
||||
virtual ~BidiReceiveStream() = default;
|
||||
WebTransportParent::CreateBidirectionalStreamResolver mResolver;
|
||||
std::function<void(uint64_t,
|
||||
WebTransportParent::OnResetOrStopSendingCallback&&,
|
||||
nsIWebTransportBidirectionalStream* aStream)>
|
||||
mStreamCallback;
|
||||
Maybe<int64_t> mSendOrder;
|
||||
nsCOMPtr<nsISerialEventTarget> mSocketThread;
|
||||
};
|
||||
|
||||
class UniReceiveStream : public nsIWebTransportStreamCallback {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIWEBTRANSPORTSTREAMCALLBACK
|
||||
|
||||
UniReceiveStream(
|
||||
ReceiveStream(
|
||||
WebTransportParent::CreateUnidirectionalStreamResolver&& aResolver,
|
||||
std::function<void(uint64_t,
|
||||
WebTransportParent::OnResetOrStopSendingCallback&&,
|
||||
nsIWebTransportSendStream* aStream)>&& aStreamCallback,
|
||||
WebTransportParent::OnResetOrStopSendingCallback&&)>&&
|
||||
aStreamCallback,
|
||||
Maybe<int64_t> aSendOrder, nsCOMPtr<nsISerialEventTarget>& aSocketThread)
|
||||
: mResolver(aResolver),
|
||||
: mUniResolver(aResolver),
|
||||
mStreamCallback(std::move(aStreamCallback)),
|
||||
mSendOrder(aSendOrder),
|
||||
mSocketThread(aSocketThread) {}
|
||||
ReceiveStream(
|
||||
WebTransportParent::CreateBidirectionalStreamResolver&& aResolver,
|
||||
std::function<void(uint64_t,
|
||||
WebTransportParent::OnResetOrStopSendingCallback&&)>&&
|
||||
aStreamCallback,
|
||||
Maybe<int64_t> aSendOrder, nsCOMPtr<nsISerialEventTarget>& aSocketThread)
|
||||
: mBiResolver(aResolver),
|
||||
mStreamCallback(std::move(aStreamCallback)),
|
||||
mSendOrder(aSendOrder),
|
||||
mSocketThread(aSocketThread) {}
|
||||
|
||||
private:
|
||||
virtual ~UniReceiveStream() = default;
|
||||
WebTransportParent::CreateUnidirectionalStreamResolver mResolver;
|
||||
~ReceiveStream() = default;
|
||||
WebTransportParent::CreateUnidirectionalStreamResolver mUniResolver;
|
||||
WebTransportParent::CreateBidirectionalStreamResolver mBiResolver;
|
||||
std::function<void(uint64_t,
|
||||
WebTransportParent::OnResetOrStopSendingCallback&&,
|
||||
nsIWebTransportSendStream* aStream)>
|
||||
WebTransportParent::OnResetOrStopSendingCallback&&)>
|
||||
mStreamCallback;
|
||||
Maybe<int64_t> mSendOrder;
|
||||
nsCOMPtr<nsISerialEventTarget> mSocketThread;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(BidiReceiveStream, nsIWebTransportStreamCallback)
|
||||
NS_IMPL_ISUPPORTS(UniReceiveStream, nsIWebTransportStreamCallback)
|
||||
NS_IMPL_ISUPPORTS(ReceiveStream, nsIWebTransportStreamCallback)
|
||||
|
||||
// nsIWebTransportStreamCallback:
|
||||
NS_IMETHODIMP BidiReceiveStream::OnBidirectionalStreamReady(
|
||||
NS_IMETHODIMP ReceiveStream::OnBidirectionalStreamReady(
|
||||
nsIWebTransportBidirectionalStream* aStream) {
|
||||
LOG(("Bidirectional stream ready!"));
|
||||
MOZ_ASSERT(mSocketThread->IsOnCurrentThread());
|
||||
|
||||
aStream->SetSendOrder(mSendOrder);
|
||||
|
||||
if (mSendOrder.isSome()) {
|
||||
aStream->SetSendOrder(mSendOrder.value());
|
||||
}
|
||||
RefPtr<mozilla::ipc::DataPipeSender> inputsender;
|
||||
RefPtr<mozilla::ipc::DataPipeReceiver> inputreceiver;
|
||||
nsresult rv =
|
||||
NewDataPipe(mozilla::ipc::kDefaultDataPipeCapacity,
|
||||
getter_AddRefs(inputsender), getter_AddRefs(inputreceiver));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mResolver(rv);
|
||||
mBiResolver(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -251,7 +234,7 @@ NS_IMETHODIMP BidiReceiveStream::OnBidirectionalStreamReady(
|
||||
mozilla::ipc::kDefaultDataPipeCapacity, nullptr, nullptr,
|
||||
true, true, getter_AddRefs(inputCopyContext));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mResolver(rv);
|
||||
mBiResolver(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -261,7 +244,7 @@ NS_IMETHODIMP BidiReceiveStream::OnBidirectionalStreamReady(
|
||||
NewDataPipe(mozilla::ipc::kDefaultDataPipeCapacity,
|
||||
getter_AddRefs(outputsender), getter_AddRefs(outputreceiver));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mResolver(rv);
|
||||
mBiResolver(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -274,12 +257,12 @@ NS_IMETHODIMP BidiReceiveStream::OnBidirectionalStreamReady(
|
||||
mozilla::ipc::kDefaultDataPipeCapacity, nullptr, nullptr,
|
||||
true, true, getter_AddRefs(outputCopyContext));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mResolver(rv);
|
||||
mBiResolver(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
LOG(("Returning BidirectionalStream pipe to content"));
|
||||
mResolver(BidirectionalStream(id, inputreceiver, outputsender));
|
||||
mBiResolver(BidirectionalStream(id, inputreceiver, outputsender));
|
||||
|
||||
auto onResetOrStopSending =
|
||||
[inputCopyContext(inputCopyContext), outputCopyContext(outputCopyContext),
|
||||
@ -292,36 +275,29 @@ NS_IMETHODIMP BidiReceiveStream::OnBidirectionalStreamReady(
|
||||
outputreceiver->CloseWithStatus(aError);
|
||||
};
|
||||
|
||||
// Store onResetOrStopSending in WebTransportParent::mBidiStreamCallbackMap
|
||||
// and onResetOrStopSending will be called when a stream receives STOP_SENDING
|
||||
// or RESET.
|
||||
mStreamCallback(id,
|
||||
WebTransportParent::OnResetOrStopSendingCallback(
|
||||
std::move(onResetOrStopSending)),
|
||||
aStream);
|
||||
// Store onResetOrStopSending in WebTransportParent::mStreamCallbackMap and
|
||||
// onResetOrStopSending will be called when a stream receives STOP_SENDING or
|
||||
// RESET.
|
||||
mStreamCallback(id, WebTransportParent::OnResetOrStopSendingCallback(
|
||||
std::move(onResetOrStopSending)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP UniReceiveStream::OnBidirectionalStreamReady(
|
||||
nsIWebTransportBidirectionalStream* aStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UniReceiveStream::OnUnidirectionalStreamReady(
|
||||
nsIWebTransportSendStream* aStream) {
|
||||
ReceiveStream::OnUnidirectionalStreamReady(nsIWebTransportSendStream* aStream) {
|
||||
LOG(("Unidirectional stream ready!"));
|
||||
// We should be on the Socket Thread
|
||||
MOZ_ASSERT(mSocketThread->IsOnCurrentThread());
|
||||
|
||||
aStream->SetSendOrder(mSendOrder);
|
||||
|
||||
if (mSendOrder.isSome()) {
|
||||
aStream->SetSendOrder(mSendOrder.value());
|
||||
}
|
||||
RefPtr<::mozilla::ipc::DataPipeSender> sender;
|
||||
RefPtr<::mozilla::ipc::DataPipeReceiver> receiver;
|
||||
nsresult rv = NewDataPipe(mozilla::ipc::kDefaultDataPipeCapacity,
|
||||
getter_AddRefs(sender), getter_AddRefs(receiver));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mResolver(rv);
|
||||
mUniResolver(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -336,13 +312,13 @@ UniReceiveStream::OnUnidirectionalStreamReady(
|
||||
mozilla::ipc::kDefaultDataPipeCapacity, nullptr, nullptr,
|
||||
true, true, getter_AddRefs(copyContext));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mResolver(rv);
|
||||
mUniResolver(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
LOG(("Returning UnidirectionalStream pipe to content"));
|
||||
// pass the DataPipeSender to the content process
|
||||
mResolver(UnidirectionalStream(id, sender));
|
||||
mUniResolver(UnidirectionalStream(id, sender));
|
||||
|
||||
auto onResetOrStopSending = [copyContext(copyContext),
|
||||
receiver(receiver)](nsresult aError) {
|
||||
@ -353,52 +329,22 @@ UniReceiveStream::OnUnidirectionalStreamReady(
|
||||
|
||||
// Store onResetOrStopSending in WebTransportParent::mStreamCallbackMap and
|
||||
// onResetOrStopSending will be called when a stream receives STOP_SENDING.
|
||||
mStreamCallback(id,
|
||||
WebTransportParent::OnResetOrStopSendingCallback(
|
||||
std::move(onResetOrStopSending)),
|
||||
aStream);
|
||||
|
||||
mStreamCallback(id, WebTransportParent::OnResetOrStopSendingCallback(
|
||||
std::move(onResetOrStopSending)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BidiReceiveStream::OnUnidirectionalStreamReady(
|
||||
nsIWebTransportSendStream* aStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JS_HAZ_CAN_RUN_SCRIPT NS_IMETHODIMP UniReceiveStream::OnError(uint8_t aError) {
|
||||
JS_HAZ_CAN_RUN_SCRIPT NS_IMETHODIMP ReceiveStream::OnError(uint8_t aError) {
|
||||
nsresult rv = aError == nsIWebTransport::INVALID_STATE_ERROR
|
||||
? NS_ERROR_DOM_INVALID_STATE_ERR
|
||||
: NS_ERROR_FAILURE;
|
||||
LOG(("CreateStream OnError: %u", aError));
|
||||
mResolver(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS_HAZ_CAN_RUN_SCRIPT NS_IMETHODIMP BidiReceiveStream::OnError(uint8_t aError) {
|
||||
nsresult rv = aError == nsIWebTransport::INVALID_STATE_ERROR
|
||||
? NS_ERROR_DOM_INVALID_STATE_ERR
|
||||
: NS_ERROR_FAILURE;
|
||||
LOG(("CreateStream OnError: %u", aError));
|
||||
mResolver(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
IPCResult WebTransportParent::RecvSetSendOrder(uint64_t aStreamId,
|
||||
Maybe<int64_t> aSendOrder) {
|
||||
if (aSendOrder) {
|
||||
LOG(("Set sendOrder=%" PRIi64 " for streamId %" PRIu64, aSendOrder.value(),
|
||||
aStreamId));
|
||||
} else {
|
||||
LOG(("Set sendOrder=null for streamId %" PRIu64, aStreamId));
|
||||
if (mUniResolver) {
|
||||
mUniResolver(rv);
|
||||
} else if (mBiResolver) {
|
||||
mBiResolver(rv);
|
||||
}
|
||||
if (auto entry = mUniStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->mStream->SetSendOrder(aSendOrder);
|
||||
} else if (auto entry = mBidiStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->mStream->SetSendOrder(aSendOrder);
|
||||
}
|
||||
return IPC_OK();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
IPCResult WebTransportParent::RecvCreateUnidirectionalStream(
|
||||
@ -410,13 +356,11 @@ IPCResult WebTransportParent::RecvCreateUnidirectionalStream(
|
||||
auto streamCb =
|
||||
[self = RefPtr{this}](
|
||||
uint64_t aStreamId,
|
||||
WebTransportParent::OnResetOrStopSendingCallback&& aCallback,
|
||||
nsIWebTransportSendStream* aStream) {
|
||||
self->mUniStreamCallbackMap.InsertOrUpdate(
|
||||
aStreamId, StreamHash<nsIWebTransportSendStream>{
|
||||
std::move(aCallback), aStream});
|
||||
WebTransportParent::OnResetOrStopSendingCallback&& aCallback) {
|
||||
self->mStreamCallbackMap.InsertOrUpdate(aStreamId,
|
||||
std::move(aCallback));
|
||||
};
|
||||
RefPtr<UniReceiveStream> callback = new UniReceiveStream(
|
||||
RefPtr<ReceiveStream> callback = new ReceiveStream(
|
||||
std::move(aResolver), std::move(streamCb), aSendOrder, mSocketThread);
|
||||
nsresult rv;
|
||||
rv = mWebTransport->CreateOutgoingUnidirectionalStream(callback);
|
||||
@ -435,13 +379,11 @@ IPCResult WebTransportParent::RecvCreateBidirectionalStream(
|
||||
auto streamCb =
|
||||
[self = RefPtr{this}](
|
||||
uint64_t aStreamId,
|
||||
WebTransportParent::OnResetOrStopSendingCallback&& aCallback,
|
||||
nsIWebTransportBidirectionalStream* aStream) {
|
||||
self->mBidiStreamCallbackMap.InsertOrUpdate(
|
||||
aStreamId, StreamHash<nsIWebTransportBidirectionalStream>{
|
||||
std::move(aCallback), aStream});
|
||||
WebTransportParent::OnResetOrStopSendingCallback&& aCallback) {
|
||||
self->mStreamCallbackMap.InsertOrUpdate(aStreamId,
|
||||
std::move(aCallback));
|
||||
};
|
||||
RefPtr<BidiReceiveStream> callback = new BidiReceiveStream(
|
||||
RefPtr<ReceiveStream> callback = new ReceiveStream(
|
||||
std::move(aResolver), std::move(streamCb), aSendOrder, mSocketThread);
|
||||
nsresult rv;
|
||||
rv = mWebTransport->CreateOutgoingBidirectionalStream(callback);
|
||||
@ -569,12 +511,9 @@ NS_IMETHODIMP WebTransportParent::OnStopSending(uint64_t aStreamId,
|
||||
MOZ_ASSERT(mSocketThread->IsOnCurrentThread());
|
||||
LOG(("WebTransportParent::OnStopSending %p stream id=%" PRIx64, this,
|
||||
aStreamId));
|
||||
if (auto entry = mUniStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->mCallback.OnResetOrStopSending(aError);
|
||||
mUniStreamCallbackMap.Remove(aStreamId);
|
||||
} else if (auto entry = mBidiStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->mCallback.OnResetOrStopSending(aError);
|
||||
mBidiStreamCallbackMap.Remove(aStreamId);
|
||||
if (auto entry = mStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->OnResetOrStopSending(aError);
|
||||
mStreamCallbackMap.Remove(aStreamId);
|
||||
}
|
||||
if (CanSend()) {
|
||||
Unused << SendOnStreamResetOrStopSending(aStreamId,
|
||||
@ -588,12 +527,9 @@ NS_IMETHODIMP WebTransportParent::OnResetReceived(uint64_t aStreamId,
|
||||
MOZ_ASSERT(mSocketThread->IsOnCurrentThread());
|
||||
LOG(("WebTransportParent::OnResetReceived %p stream id=%" PRIx64, this,
|
||||
aStreamId));
|
||||
if (auto entry = mUniStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->mCallback.OnResetOrStopSending(aError);
|
||||
mUniStreamCallbackMap.Remove(aStreamId);
|
||||
} else if (auto entry = mBidiStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->mCallback.OnResetOrStopSending(aError);
|
||||
mBidiStreamCallbackMap.Remove(aStreamId);
|
||||
if (auto entry = mStreamCallbackMap.Lookup(aStreamId)) {
|
||||
entry->OnResetOrStopSending(aError);
|
||||
mStreamCallbackMap.Remove(aStreamId);
|
||||
}
|
||||
if (CanSend()) {
|
||||
Unused << SendOnStreamResetOrStopSending(aStreamId, ResetError(aError));
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIWebTransport.h"
|
||||
#include "nsIWebTransportStream.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
@ -44,8 +43,6 @@ class WebTransportParent : public PWebTransportParent,
|
||||
|
||||
IPCResult RecvClose(const uint32_t& aCode, const nsACString& aReason);
|
||||
|
||||
IPCResult RecvSetSendOrder(uint64_t aStreamId, Maybe<int64_t> aSendOrder);
|
||||
|
||||
IPCResult RecvCreateUnidirectionalStream(
|
||||
Maybe<int64_t> aSendOrder,
|
||||
CreateUnidirectionalStreamResolver&& aResolver);
|
||||
@ -96,17 +93,7 @@ class WebTransportParent : public PWebTransportParent,
|
||||
|
||||
nsCOMPtr<nsIWebTransport> mWebTransport;
|
||||
nsCOMPtr<nsIEventTarget> mOwningEventTarget;
|
||||
|
||||
// What we need to be able to lookup by streamId
|
||||
template <typename T>
|
||||
struct StreamHash {
|
||||
OnResetOrStopSendingCallback mCallback;
|
||||
nsCOMPtr<T> mStream;
|
||||
};
|
||||
nsTHashMap<nsUint64HashKey, StreamHash<nsIWebTransportBidirectionalStream>>
|
||||
mBidiStreamCallbackMap;
|
||||
nsTHashMap<nsUint64HashKey, StreamHash<nsIWebTransportSendStream>>
|
||||
mUniStreamCallbackMap;
|
||||
nsTHashMap<nsUint64HashKey, OnResetOrStopSendingCallback> mStreamCallbackMap;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -71,11 +71,6 @@ async protocol PWebTransport
|
||||
async GetMaxDatagramSize()
|
||||
returns(uint64_t maxDatagramSize);
|
||||
|
||||
/**
|
||||
* Set the sendOrder for an existing stream
|
||||
*/
|
||||
async SetSendOrder(uint64_t streamId, int64_t? sendOrder);
|
||||
|
||||
child:
|
||||
|
||||
async IncomingUnidirectionalStream(uint64_t streamId, nullable DataPipeReceiver receive);
|
||||
|
@ -2502,8 +2502,7 @@ uint64_t Http3Session::MaxDatagramSize(uint64_t aSessionId) {
|
||||
return size;
|
||||
}
|
||||
|
||||
void Http3Session::SetSendOrder(Http3StreamBase* aStream,
|
||||
Maybe<int64_t> aSendOrder) {
|
||||
void Http3Session::SetSendOrder(Http3StreamBase* aStream, int64_t aSendOrder) {
|
||||
if (!IsClosing()) {
|
||||
nsresult rv = mHttp3Connection->WebTransportSetSendOrder(
|
||||
aStream->StreamId(), aSendOrder);
|
||||
|
@ -215,7 +215,7 @@ class Http3Session final : public nsAHttpTransaction, public nsAHttpConnection {
|
||||
|
||||
uint64_t MaxDatagramSize(uint64_t aSessionId);
|
||||
|
||||
void SetSendOrder(Http3StreamBase* aStream, Maybe<int64_t> aSendOrder);
|
||||
void SetSendOrder(Http3StreamBase* aStream, int64_t aSendOrder);
|
||||
|
||||
void CloseWebTransportConn();
|
||||
|
||||
|
@ -660,7 +660,7 @@ void Http3WebTransportStream::SendStopSending(uint8_t aErrorCode) {
|
||||
mSession->StreamHasDataToWrite(this);
|
||||
}
|
||||
|
||||
void Http3WebTransportStream::SetSendOrder(Maybe<int64_t> aSendOrder) {
|
||||
void Http3WebTransportStream::SetSendOrder(int64_t aSendOrder) {
|
||||
mSession->SetSendOrder(this, aSendOrder);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class Http3WebTransportStream final : public Http3StreamBase,
|
||||
}
|
||||
Http3Stream* GetHttp3Stream() override { return nullptr; }
|
||||
|
||||
void SetSendOrder(Maybe<int64_t> aSendOrder);
|
||||
void SetSendOrder(int64_t aSendOrder);
|
||||
|
||||
[[nodiscard]] nsresult ReadSegments() override;
|
||||
[[nodiscard]] nsresult WriteSegments() override;
|
||||
|
@ -223,13 +223,7 @@ NS_IMETHODIMP WebTransportStreamProxy::GetStreamId(uint64_t* aId) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WebTransportStreamProxy::SetSendOrder(Maybe<int64_t> aSendOrder) {
|
||||
if (!OnSocketThread()) {
|
||||
return gSocketTransportService->Dispatch(NS_NewRunnableFunction(
|
||||
"SetSendOrder", [stream = mWebTransportStream, aSendOrder]() {
|
||||
stream->SetSendOrder(aSendOrder);
|
||||
}));
|
||||
}
|
||||
NS_IMETHODIMP WebTransportStreamProxy::SetSendOrder(int64_t aSendOrder) {
|
||||
mWebTransportStream->SetSendOrder(aSendOrder);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class WebTransportStreamProxy final
|
||||
NS_IMETHOD GetOutputStream(nsIAsyncOutputStream** aOut) override;
|
||||
|
||||
NS_IMETHOD GetStreamId(uint64_t* aId) override;
|
||||
NS_IMETHOD SetSendOrder(Maybe<int64_t> aSendOrder) override;
|
||||
NS_IMETHOD SetSendOrder(int64_t aSendOrder) override;
|
||||
|
||||
private:
|
||||
virtual ~WebTransportStreamProxy();
|
||||
|
@ -47,7 +47,7 @@ interface nsIWebTransport : nsISupports {
|
||||
in WebTransportSessionEventListener aListener,
|
||||
in const_MaybeClientInfoRef aClientInfo);
|
||||
|
||||
// Asynchronously get stats.
|
||||
// Asynchronously get states.
|
||||
void getStats();
|
||||
|
||||
// Close the session.
|
||||
|
@ -11,15 +11,12 @@ interface nsIInputStreamCallback;
|
||||
interface nsIEventTarget;
|
||||
|
||||
%{C++
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
namespace mozilla {
|
||||
class TimeStamp;
|
||||
}
|
||||
%}
|
||||
|
||||
native TimeStamp(mozilla::TimeStamp);
|
||||
native MaybeInt64(mozilla::Maybe<int64_t>);
|
||||
|
||||
[builtinclass, scriptable, uuid(ccc3e685-8411-48f0-8b3e-ff6d1fae4809)]
|
||||
interface nsIWebTransportSendStreamStats : nsISupports {
|
||||
@ -65,7 +62,7 @@ interface nsIWebTransportSendStream : nsISupports {
|
||||
void getSendStreamStats(in nsIWebTransportStreamStatsCallback aCallback);
|
||||
readonly attribute nsIAsyncOutputStream outputStream;
|
||||
readonly attribute uint64_t streamId;
|
||||
[noscript] void setSendOrder(in MaybeInt64 aSendOrder);
|
||||
void setSendOrder(in int64_t aSendOrder);
|
||||
};
|
||||
|
||||
[builtinclass, scriptable, uuid(f9ecb509-36db-4689-97d6-137639a08750)]
|
||||
@ -85,5 +82,5 @@ interface nsIWebTransportBidirectionalStream : nsISupports {
|
||||
readonly attribute nsIAsyncInputStream inputStream;
|
||||
readonly attribute nsIAsyncOutputStream outputStream;
|
||||
readonly attribute uint64_t streamId;
|
||||
[noscript] void setSendOrder(in MaybeInt64 aSendOrder);
|
||||
void setSendOrder(in int64_t aSendOrder);
|
||||
};
|
||||
|
@ -149,10 +149,9 @@ class NeqoHttp3Conn final {
|
||||
aResult);
|
||||
}
|
||||
|
||||
nsresult WebTransportSetSendOrder(uint64_t aSessionId,
|
||||
Maybe<int64_t> aSendOrder) {
|
||||
nsresult WebTransportSetSendOrder(uint64_t aSessionId, int64_t aSendOrder) {
|
||||
return neqo_http3conn_webtransport_set_sendorder(this, aSessionId,
|
||||
aSendOrder.ptrOr(nullptr));
|
||||
aSendOrder);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1346,15 +1346,13 @@ pub extern "C" fn neqo_http3conn_webtransport_max_datagram_size(
|
||||
pub extern "C" fn neqo_http3conn_webtransport_set_sendorder(
|
||||
conn: &mut NeqoHttp3Conn,
|
||||
stream_id: u64,
|
||||
sendorder: *const i64,
|
||||
_sendorder: i64,
|
||||
) -> nsresult {
|
||||
unsafe {
|
||||
match conn
|
||||
.conn
|
||||
.webtransport_set_sendorder(StreamId::from(stream_id), sendorder.as_ref().copied())
|
||||
{
|
||||
Ok(()) => NS_OK,
|
||||
Err(_) => NS_ERROR_UNEXPECTED,
|
||||
}
|
||||
match conn
|
||||
.conn
|
||||
.webtransport_set_sendorder(StreamId::from(stream_id), None)
|
||||
{
|
||||
Ok(()) => NS_OK,
|
||||
Err(_) => NS_ERROR_UNEXPECTED,
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@
|
||||
[WebTransport interface: webTransport must inherit property "draining" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransportSendStream interface: attribute sendOrder]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[idlharness.https.any.serviceworker.html]
|
||||
[WebTransport interface: attribute draining]
|
||||
@ -13,6 +16,9 @@
|
||||
[WebTransport interface: webTransport must inherit property "draining" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransportSendStream interface: attribute sendOrder]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[idlharness.https.any.sharedworker.html]
|
||||
[WebTransport interface: attribute draining]
|
||||
@ -21,6 +27,9 @@
|
||||
[WebTransport interface: webTransport must inherit property "draining" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransportSendStream interface: attribute sendOrder]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[idlharness.https.any.worker.html]
|
||||
[WebTransport interface: attribute draining]
|
||||
@ -28,3 +37,6 @@
|
||||
|
||||
[WebTransport interface: webTransport must inherit property "draining" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransportSendStream interface: attribute sendOrder]
|
||||
expected: FAIL
|
||||
|
@ -0,0 +1,79 @@
|
||||
[sendorder.https.any.html]
|
||||
[WebTransport client should be able to create and handle a bidirectional stream with sendOrder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify unset sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify existing sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should not starve a stream without sendorder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream, variant 2]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[sendorder.https.any.worker.html]
|
||||
[WebTransport client should be able to create and handle a bidirectional stream with sendOrder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify unset sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify existing sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should not starve a stream without sendorder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream, variant 2]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[sendorder.https.any.sharedworker.html]
|
||||
[WebTransport client should be able to create and handle a bidirectional stream with sendOrder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify unset sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify existing sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should not starve a stream without sendorder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream, variant 2]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[sendorder.https.any.serviceworker.html]
|
||||
[WebTransport client should be able to create and handle a bidirectional stream with sendOrder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify unset sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport client should be able to modify existing sendOrder after stream creation]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should not starve a stream without sendorder]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream]
|
||||
expected: FAIL
|
||||
|
||||
[WebTransport sendorder should starve a lower priority stream, variant 2]
|
||||
expected: FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user