#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/network/web_transport.h"
#include "base/auto_reset.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "net/base/io_buffer.h"
#include "net/third_party/quiche/src/quiche/common/platform/api/quiche_mem_slice.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_session.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_time.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_types.h"
#include "services/network/network_context.h"
#include "services/network/public/mojom/web_transport.mojom.h"
namespace network {
namespace {
net::WebTransportParameters CreateParameters(
const std::vector<mojom::WebTransportCertificateFingerprintPtr>&
fingerprints) { … }
base::TimeDelta ToTimeDelta(absl::Duration duration) { … }
mojom::WebTransportStatsPtr StatsToMojom(
const webtransport::SessionStats& stats) { … }
}
class WebTransport::Stream final { … };
WebTransport::WebTransport(
const GURL& url,
const url::Origin& origin,
const net::NetworkAnonymizationKey& key,
const std::vector<mojom::WebTransportCertificateFingerprintPtr>&
fingerprints,
NetworkContext* context,
mojo::PendingRemote<mojom::WebTransportHandshakeClient> handshake_client)
: … { … }
WebTransport::~WebTransport() { … }
void WebTransport::SendDatagram(base::span<const uint8_t> data,
base::OnceCallback<void(bool)> callback) { … }
void WebTransport::CreateStream(
mojo::ScopedDataPipeConsumerHandle readable,
mojo::ScopedDataPipeProducerHandle writable,
base::OnceCallback<void(bool, uint32_t)> callback) { … }
void WebTransport::AcceptBidirectionalStream(
BidirectionalStreamAcceptanceCallback acceptance) { … }
void WebTransport::AcceptUnidirectionalStream(
UnidirectionalStreamAcceptanceCallback acceptance) { … }
void WebTransport::SendFin(uint32_t stream) { … }
void WebTransport::AbortStream(uint32_t stream, uint8_t code) { … }
void WebTransport::StopSending(uint32_t stream, uint8_t code) { … }
void WebTransport::SetOutgoingDatagramExpirationDuration(
base::TimeDelta duration) { … }
void WebTransport::Close(mojom::WebTransportCloseInfoPtr close_info) { … }
void WebTransport::OnConnected(
scoped_refptr<net::HttpResponseHeaders> response_headers) { … }
void WebTransport::OnConnectionFailed(const net::WebTransportError& error) { … }
void WebTransport::OnClosed(
const std::optional<net::WebTransportCloseInfo>& close_info) { … }
void WebTransport::OnError(const net::WebTransportError& error) { … }
void WebTransport::OnIncomingBidirectionalStreamAvailable() { … }
void WebTransport::OnIncomingUnidirectionalStreamAvailable() { … }
void WebTransport::OnDatagramReceived(std::string_view datagram) { … }
void WebTransport::OnCanCreateNewOutgoingBidirectionalStream() { … }
void WebTransport::OnCanCreateNewOutgoingUnidirectionalStream() { … }
void WebTransport::OnDatagramProcessed(
std::optional<quic::MessageStatus> status) { … }
void WebTransport::GetStats(GetStatsCallback callback) { … }
void WebTransport::TearDown() { … }
void WebTransport::Dispose() { … }
}