Bug 1790676: WebTransport DOM API initial framework r=saschanaz,necko-reviewers,emilio,valentin

This includes WebTransport, WebTransportSendStream,
WebTransportReceiveStreams, WebTransportBidirectionalStream and
WebTransportError classes without any actual functionality

Differential Revision: https://phabricator.services.mozilla.com/D162323
This commit is contained in:
Randell Jesup 2022-11-22 13:43:57 +00:00
parent c3dad32348
commit 1b6d10cb7a
20 changed files with 741 additions and 2 deletions

View File

@ -86,6 +86,7 @@ DIRS += [
"webauthn",
"webidl",
"webshare",
"webtransport",
"xml",
"xslt",
"xul",

View File

@ -40,13 +40,13 @@ class BodyStreamHolder;
class UniqueMessagePortId;
class MessagePort;
class ReadableStream final : public nsISupports, public nsWrapperCache {
class ReadableStream : public nsISupports, public nsWrapperCache {
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ReadableStream)
protected:
~ReadableStream();
virtual ~ReadableStream();
nsCOMPtr<nsIGlobalObject> mGlobal;

View File

@ -0,0 +1,94 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* https://w3c.github.io/webtransport */
/* https://w3c.github.io/webtransport/#web-transport-configuration */
dictionary WebTransportHash {
DOMString algorithm;
BufferSource value;
};
dictionary WebTransportOptions {
boolean allowPooling = false;
boolean requireUnreliable = false;
sequence<WebTransportHash> serverCertificateHashes;
WebTransportCongestionControl congestionControl = "default";
};
enum WebTransportCongestionControl {
"default",
"throughput",
"low-latency",
};
/* https://w3c.github.io/webtransport/#web-transport-close-info */
dictionary WebTransportCloseInfo {
unsigned long closeCode = 0;
DOMString reason = "";
};
/* https://w3c.github.io/webtransport/#web-transport-stats */
dictionary WebTransportStats {
DOMHighResTimeStamp timestamp;
unsigned long long bytesSent;
unsigned long long packetsSent;
unsigned long long packetsLost;
unsigned long numOutgoingStreamsCreated;
unsigned long numIncomingStreamsCreated;
unsigned long long bytesReceived;
unsigned long long packetsReceived;
DOMHighResTimeStamp smoothedRtt;
DOMHighResTimeStamp rttVariation;
DOMHighResTimeStamp minRtt;
WebTransportDatagramStats datagrams;
};
/* https://w3c.github.io/webtransport/#web-transport-stats%E2%91%A0 */
dictionary WebTransportDatagramStats {
DOMHighResTimeStamp timestamp;
unsigned long long expiredOutgoing;
unsigned long long droppedIncoming;
unsigned long long lostOutgoing;
};
/* https://w3c.github.io/webtransport/#web-transport */
[Exposed=(Window,Worker), SecureContext, Pref="network.webtransport.enabled"]
interface WebTransport {
constructor(USVString url, optional WebTransportOptions options = {});
[NewObject]
Promise<WebTransportStats> getStats();
readonly attribute Promise<undefined> ready;
readonly attribute WebTransportReliabilityMode reliability;
readonly attribute WebTransportCongestionControl congestionControl;
readonly attribute Promise<WebTransportCloseInfo> closed;
undefined close(optional WebTransportCloseInfo closeInfo = {});
readonly attribute WebTransportDatagramDuplexStream datagrams;
[NewObject]
Promise<WebTransportBidirectionalStream> createBidirectionalStream();
/* a ReadableStream of WebTransportBidirectionalStream objects */
readonly attribute ReadableStream incomingBidirectionalStreams;
/* XXX spec says this should be WebTransportSendStream */
[NewObject]
Promise<WritableStream> createUnidirectionalStream();
/* a ReadableStream of WebTransportReceiveStream objects */
readonly attribute ReadableStream incomingUnidirectionalStreams;
};
enum WebTransportReliabilityMode {
"pending",
"reliable-only",
"supports-unreliable",
};

View File

@ -0,0 +1,18 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* https://w3c.github.io/webtransport/#duplex-stream */
[Exposed=(Window,Worker), SecureContext, Pref="network.webtransport.datagrams.enabled"]
interface WebTransportDatagramDuplexStream {
readonly attribute ReadableStream readable;
readonly attribute WritableStream writable;
readonly attribute unsigned long maxDatagramSize;
attribute double? incomingMaxAge;
attribute double? outgoingMaxAge;
attribute long incomingHighWaterMark;
attribute long outgoingHighWaterMark;
};

View File

@ -0,0 +1,24 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* https://w3c.github.io/webtransport/#web-transport-error-interface */
[Exposed=(Window,Worker), SecureContext, Pref="network.webtransport.enabled"]
interface WebTransportError : DOMException {
constructor(optional WebTransportErrorInit init = {});
readonly attribute WebTransportErrorSource source;
readonly attribute octet? streamErrorCode;
};
dictionary WebTransportErrorInit {
[Clamp] octet streamErrorCode;
DOMString message;
};
enum WebTransportErrorSource {
"stream",
"session",
};

View File

@ -0,0 +1,45 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* https://w3c.github.io/webtransport/#send-stream-stats */
dictionary WebTransportSendStreamStats {
DOMHighResTimeStamp timestamp;
unsigned long long bytesWritten;
unsigned long long bytesSent;
unsigned long long bytesAcknowledged;
};
/* https://w3c.github.io/webtransport/#receive-stream-stats */
dictionary WebTransportReceiveStreamStats {
DOMHighResTimeStamp timestamp;
unsigned long long bytesReceived;
unsigned long long bytesRead;
};
/* https://w3c.github.io/webtransport/#receive-stream */
/* https://w3c.github.io/webtransport/#send-stream */
/*
[Exposed=(Window,Worker), SecureContext, Pref="network.webtransport.enabled"]
interface WebTransportSendStream : WritableStream {
Promise<WebTransportSendStreamStats> getStats();
};
[Exposed=(Window,Worker), SecureContext, Pref="network.webtransport.enabled"]
interface WebTransportReceiveStream : ReadableStream {
Promise<WebTransportReceiveStreamStats> getStats();
};
*/
/* https://w3c.github.io/webtransport/#bidirectional-stream */
[Exposed=(Window,Worker), SecureContext, Pref="network.webtransport.enabled"]
interface WebTransportBidirectionalStream {
// XXX spec says these should be WebTransportReceiveStream and WebTransportSendStream
readonly attribute ReadableStream readable;
readonly attribute WritableStream writable;
};

View File

@ -388,6 +388,9 @@ with Files("Worker*"):
with Files("Extension*"):
BUG_COMPONENT = ("WebExtensions", "General")
with Files("WebTransport*"):
BUG_COMPONENT = ("Core", "Networking")
GENERATED_WEBIDL_FILES = [
"CSS2Properties.webidl",
]
@ -994,6 +997,10 @@ WEBIDL_FILES = [
"WebGPU.webidl",
"WebSocket.webidl",
"WebTaskScheduling.webidl",
"WebTransport.webidl",
"WebTransportDatagramDuplexStream.webidl",
"WebTransportError.webidl",
"WebTransportSendReceiveStream.webidl",
"WebXR.webidl",
"WheelEvent.webidl",
"WidevineCDMManifest.webidl",

View File

@ -0,0 +1,104 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebTransport.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/Promise.h"
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebTransport, mGlobal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebTransport)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebTransport)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebTransport)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
// WebIDL Boilerplate
nsIGlobalObject* WebTransport::GetParentObject() const { return mGlobal; }
JSObject* WebTransport::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return WebTransport_Binding::Wrap(aCx, this, aGivenProto);
}
// WebIDL Interface
/* static */
already_AddRefed<WebTransport> WebTransport::Constructor(
const GlobalObject& aGlobal, const nsAString& aUrl,
const WebTransportOptions& aOptions) {
return nullptr;
}
already_AddRefed<Promise> WebTransport::GetStats(ErrorResult& aError) {
aError.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
}
already_AddRefed<Promise> WebTransport::Ready() {
ErrorResult error;
RefPtr<Promise> promise = Promise::Create(GetParentObject(), error);
if (error.Failed()) {
return nullptr;
}
promise->MaybeRejectWithUndefined();
return promise.forget();
}
WebTransportReliabilityMode WebTransport::Reliability() {
// XXX not implemented
return WebTransportReliabilityMode::Pending;
}
WebTransportCongestionControl WebTransport::CongestionControl() {
// XXX not implemented
return WebTransportCongestionControl::Default;
}
already_AddRefed<Promise> WebTransport::Closed() {
ErrorResult error;
RefPtr<Promise> promise = Promise::Create(GetParentObject(), error);
if (error.Failed()) {
return nullptr;
}
promise->MaybeRejectWithUndefined();
return promise.forget();
}
void WebTransport::Close(const WebTransportCloseInfo& aOptions) {}
already_AddRefed<WebTransportDatagramDuplexStream> WebTransport::Datagrams() {
// XXX not implemented
return nullptr;
}
already_AddRefed<Promise> WebTransport::CreateBidirectionalStream(
ErrorResult& aError) {
aError.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
}
already_AddRefed<ReadableStream> WebTransport::IncomingBidirectionalStreams() {
// XXX not implemented
return nullptr;
}
already_AddRefed<Promise> WebTransport::CreateUnidirectionalStream(
ErrorResult& aError) {
aError.Throw(NS_ERROR_NOT_IMPLEMENTED);
return nullptr;
}
already_AddRefed<ReadableStream> WebTransport::IncomingUnidirectionalStreams() {
// XXX not implemented
return nullptr;
}
} // namespace mozilla::dom

View File

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_WEBTRANSPORT_API_WEBTRANSPORT__H_
#define DOM_WEBTRANSPORT_API_WEBTRANSPORT__H_
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/WebTransportBinding.h"
namespace mozilla::dom {
class WebTransportDatagramDuplexStream;
class ReadableStream;
class WritableStream;
class WebTransport final : public nsISupports, public nsWrapperCache {
public:
explicit WebTransport(nsIGlobalObject* aGlobal) : mGlobal(aGlobal) {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(WebTransport)
// WebIDL Boilerplate
nsIGlobalObject* GetParentObject() const;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
// WebIDL Interface
static already_AddRefed<WebTransport> Constructor(
const GlobalObject& aGlobal, const nsAString& aUrl,
const WebTransportOptions& aOptions);
already_AddRefed<Promise> GetStats(ErrorResult& aError);
already_AddRefed<Promise> Ready();
WebTransportReliabilityMode Reliability();
WebTransportCongestionControl CongestionControl();
already_AddRefed<Promise> Closed();
void Close(const WebTransportCloseInfo& aOptions);
already_AddRefed<WebTransportDatagramDuplexStream> Datagrams();
already_AddRefed<Promise> CreateBidirectionalStream(ErrorResult& aError);
already_AddRefed<ReadableStream> IncomingBidirectionalStreams();
already_AddRefed<Promise> CreateUnidirectionalStream(ErrorResult& aError);
already_AddRefed<ReadableStream> IncomingUnidirectionalStreams();
private:
~WebTransport() = default;
nsCOMPtr<nsIGlobalObject> mGlobal;
// RefPtr<WebTransportChannel> mChannel;
};
} // namespace mozilla::dom
#endif

View File

@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebTransportBidirectionalStream.h"
#include "mozilla/dom/Promise.h"
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebTransportBidirectionalStream, mGlobal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebTransportBidirectionalStream)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebTransportBidirectionalStream)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebTransportBidirectionalStream)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
// WebIDL Boilerplate
nsIGlobalObject* WebTransportBidirectionalStream::GetParentObject() const {
return mGlobal;
}
JSObject* WebTransportBidirectionalStream::WrapObject(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
return WebTransportBidirectionalStream_Binding::Wrap(aCx, this, aGivenProto);
}
// WebIDL Interface
} // namespace mozilla::dom

View File

@ -0,0 +1,52 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_WEBTRANSPORT_API_WEBTRANSPORTBIDIRECTIONALSTREAM__H_
#define DOM_WEBTRANSPORT_API_WEBTRANSPORTBIDIRECTIONALSTREAM__H_
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ReadableStream.h"
#include "mozilla/dom/WritableStream.h"
#include "mozilla/dom/WebTransportSendReceiveStreamBinding.h"
// #include "mozilla/dom/WebTransportReceiveStream.h"
// #include "mozilla/dom/WebTransportSendStream.h"
namespace mozilla::dom {
class WebTransportBidirectionalStream final : public nsISupports,
public nsWrapperCache {
public:
explicit WebTransportBidirectionalStream(nsIGlobalObject* aGlobal)
: mGlobal(aGlobal) {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(WebTransportBidirectionalStream)
// WebIDL Boilerplate
nsIGlobalObject* GetParentObject() const;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
// WebIDL Interface
// XXX spec says these should be WebTransportReceiveStream and
// WebTransportSendStream
// XXX Not implemented
already_AddRefed<ReadableStream> Readable() { return nullptr; }
already_AddRefed<WritableStream> Writable() { return nullptr; }
private:
~WebTransportBidirectionalStream() = default;
nsCOMPtr<nsIGlobalObject> mGlobal;
};
} // namespace mozilla::dom
#endif

View File

@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebTransportDatagramDuplexStream.h"
#include "mozilla/dom/Promise.h"
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebTransportDatagramDuplexStream, mGlobal,
mReadable, mWritable)
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebTransportDatagramDuplexStream)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebTransportDatagramDuplexStream)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebTransportDatagramDuplexStream)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
// WebIDL Boilerplate
nsIGlobalObject* WebTransportDatagramDuplexStream::GetParentObject() const {
return mGlobal;
}
JSObject* WebTransportDatagramDuplexStream::WrapObject(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
return WebTransportDatagramDuplexStream_Binding::Wrap(aCx, this, aGivenProto);
}
// WebIDL Interface
} // namespace mozilla::dom

View File

@ -0,0 +1,78 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_WEBTRANSPORT_API_WEBTRANSPORTDATAGRAMDUPLEXSTREAM__H_
#define DOM_WEBTRANSPORT_API_WEBTRANSPORTDATAGRAMDUPLEXSTREAM__H_
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ReadableStream.h"
#include "mozilla/dom/WritableStream.h"
#include "mozilla/dom/WebTransportDatagramDuplexStreamBinding.h"
namespace mozilla::dom {
class WebTransportDatagramDuplexStream final : public nsISupports,
public nsWrapperCache {
public:
explicit WebTransportDatagramDuplexStream(nsIGlobalObject* aGlobal)
: mGlobal(aGlobal) {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(WebTransportDatagramDuplexStream)
// WebIDL Boilerplate
nsIGlobalObject* GetParentObject() const;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
// WebIDL Interface
already_AddRefed<ReadableStream> Readable() const {
RefPtr<ReadableStream> result(mReadable);
return result.forget();
}
already_AddRefed<WritableStream> Writable() {
RefPtr<WritableStream> result(mWritable);
return result.forget();
}
// XXX not implemented
uint64_t MaxDatagramSize() const { return 1500; }
Nullable<double> GetIncomingMaxAge() const { return mIncomingMaxAge; }
void SetIncomingMaxAge(const Nullable<double>& aMaxAge) {
mIncomingMaxAge = aMaxAge;
}
Nullable<double> GetOutgoingMaxAge() const { return mOutgoingMaxAge; }
void SetOutgoingMaxAge(const Nullable<double>& aMaxAge) {
mOutgoingMaxAge = aMaxAge;
}
int64_t IncomingHighWaterMark() const { return mIncomingHighWaterMark; }
void SetIncomingHighWaterMark(int64_t aWaterMark) {
mIncomingHighWaterMark = aWaterMark;
}
int64_t OutgoingHighWaterMark() const { return mOutgoingHighWaterMark; }
void SetOutgoingHighWaterMark(int64_t aWaterMark) {
mOutgoingHighWaterMark = aWaterMark;
}
private:
~WebTransportDatagramDuplexStream() = default;
nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<ReadableStream> mReadable;
RefPtr<WritableStream> mWritable;
Nullable<double> mIncomingMaxAge;
Nullable<double> mOutgoingMaxAge;
int64_t mIncomingHighWaterMark = 0;
int64_t mOutgoingHighWaterMark = 0;
};
} // namespace mozilla::dom
#endif

View File

@ -0,0 +1,30 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebTransportError.h"
namespace mozilla::dom {
/* static */
already_AddRefed<WebTransportError> WebTransportError::Constructor(
const GlobalObject& aGlobal, const WebTransportErrorInit& aInit) {
nsCString message(""_ns);
if (aInit.mMessage.WasPassed()) {
CopyUTF16toUTF8(aInit.mMessage.Value(), message);
}
RefPtr<WebTransportError> error(new WebTransportError(message));
if (aInit.mStreamErrorCode.WasPassed()) {
error->mStreamErrorCode = aInit.mStreamErrorCode.Value();
}
return error.forget();
}
WebTransportErrorSource WebTransportError::Source() {
// XXX Not implemented
return WebTransportErrorSource::Stream;
}
} // namespace mozilla::dom

View File

@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_WEBTRANSPORT_API_WEBTRANSPORTERROR__H_
#define DOM_WEBTRANSPORT_API_WEBTRANSPORTERROR__H_
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/WebTransportErrorBinding.h"
namespace mozilla::dom {
class WebTransportError final : public DOMException {
protected:
explicit WebTransportError(const nsACString& aMessage)
: DOMException(NS_OK, aMessage, "stream"_ns, 0) {}
public:
static already_AddRefed<WebTransportError> Constructor(
const GlobalObject& aGlobal, const WebTransportErrorInit& aInit);
WebTransportErrorSource Source();
Nullable<uint8_t> GetStreamErrorCode() const {
return Nullable<uint8_t>(mStreamErrorCode);
}
private:
uint8_t mStreamErrorCode = 0;
};
} // namespace mozilla::dom
#endif

View File

@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_WEBTRANSPORT_API_WEBTRANSPORTSENDSTREAM__H_
#define DOM_WEBTRANSPORT_API_WEBTRANSPORTSENDSTREAM__H_
#include "mozilla/dom/ReadableStream.h"
#if WEBTRANSPORT_STREAM_IMPLEMENTED
namespace mozilla::dom {
class WebTransportReceiveStream final : public ReadableStream {
protected:
WebTransportReceiveStream();
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(WebTransportReceiveStream,
ReadableStream)
already_AddRefed<Promise> GetStats();
};
#else
namespace mozilla::dom {
class WebTransportReceiveStream final : public nsISupports {
protected:
WebTransportReceiveStream();
public:
NS_DECL_ISUPPORTS
already_AddRefed<Promise> GetStats();
};
#endif
}
#endif

View File

@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_WEBTRANSPORT_API_WEBTRANSPORTSENDSTREAM__H_
#define DOM_WEBTRANSPORT_API_WEBTRANSPORTSENDSTREAM__H_
#include "mozilla/dom/WritableStream.h"
#if WEBTRANSPORT_STREAM_IMPLEMENTED
namespace mozilla::dom {
class WebTransportSendStream final : public WritableStream {
protected:
WebTransportSendStream();
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(WebTransportSendStream,
WritableStream)
already_AddRefed<Promise> GetStats();
};
#else
namespace mozilla::dom {
class WebTransportSendStream final : public nsISupports {
protected:
WebTransportSendStream();
public:
NS_DECL_ISUPPORTS
already_AddRefed<Promise> GetStats();
};
#endif
}
#endif

View File

@ -0,0 +1,23 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.dom += [
"WebTransport.h",
"WebTransportBidirectionalStream.h",
"WebTransportDatagramDuplexStream.h",
"WebTransportError.h",
"WebTransportReceiveStream.h",
"WebTransportSendStream.h",
]
UNIFIED_SOURCES += [
"WebTransport.cpp",
"WebTransportBidirectionalStream.cpp",
"WebTransportDatagramDuplexStream.cpp",
"WebTransportError.cpp",
]
FINAL_LIBRARY = "xul"

View File

@ -0,0 +1,9 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += [
"api",
]

View File

@ -12012,6 +12012,18 @@
value: true
mirror: always
# WebTransport
- name: network.webtransport.enabled
type: RelaxedAtomicBool
value: false
mirror: always
# WebTransport Datagram support
- name: network.webtransport.datagrams.enabled
type: RelaxedAtomicBool
value: false
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "nglayout."
#---------------------------------------------------------------------------