#include "quiche/web_transport/encapsulated/encapsulated_web_transport.h"
#include <stdbool.h>
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <iterator>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/container/node_hash_map.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "quiche/common/capsule.h"
#include "quiche/common/http/http_header_block.h"
#include "quiche/common/platform/api/quiche_bug_tracker.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/quiche_buffer_allocator.h"
#include "quiche/common/quiche_callbacks.h"
#include "quiche/common/quiche_circular_deque.h"
#include "quiche/common/quiche_status_utils.h"
#include "quiche/common/quiche_stream.h"
#include "quiche/web_transport/web_transport.h"
namespace webtransport {
namespace {
Capsule;
CapsuleType;
CloseWebTransportSessionCapsule;
constexpr uint64_t kEncapsulatedMaxDatagramSize = …;
constexpr StreamPriority kDefaultPriority = …;
}
EncapsulatedSession::EncapsulatedSession(
Perspective perspective, FatalErrorCallback fatal_error_callback)
: … { … }
void EncapsulatedSession::InitializeClient(
std::unique_ptr<SessionVisitor> visitor,
quiche::HttpHeaderBlock& , quiche::WriteStream* writer,
quiche::ReadStream* reader) { … }
void EncapsulatedSession::InitializeServer(
std::unique_ptr<SessionVisitor> visitor,
const quiche::HttpHeaderBlock& ,
quiche::HttpHeaderBlock& , quiche::WriteStream* writer,
quiche::ReadStream* reader) { … }
void EncapsulatedSession::ProcessIncomingServerHeaders(
const quiche::HttpHeaderBlock& ) { … }
void EncapsulatedSession::CloseSession(SessionErrorCode error_code,
absl::string_view error_message) { … }
Stream* EncapsulatedSession::AcceptIncomingStream(
quiche::QuicheCircularDeque<StreamId>& queue) { … }
Stream* EncapsulatedSession::AcceptIncomingBidirectionalStream() { … }
Stream* EncapsulatedSession::AcceptIncomingUnidirectionalStream() { … }
bool EncapsulatedSession::CanOpenNextOutgoingBidirectionalStream() { … }
bool EncapsulatedSession::CanOpenNextOutgoingUnidirectionalStream() { … }
Stream* EncapsulatedSession::OpenOutgoingStream(StreamId& counter) { … }
Stream* EncapsulatedSession::OpenOutgoingBidirectionalStream() { … }
Stream* EncapsulatedSession::OpenOutgoingUnidirectionalStream() { … }
Stream* EncapsulatedSession::GetStreamById(StreamId id) { … }
DatagramStats EncapsulatedSession::GetDatagramStats() { … }
SessionStats EncapsulatedSession::GetSessionStats() { … }
void EncapsulatedSession::NotifySessionDraining() { … }
void EncapsulatedSession::SetOnDraining(
quiche::SingleUseCallback<void()> callback) { … }
DatagramStatus EncapsulatedSession::SendOrQueueDatagram(
absl::string_view datagram) { … }
uint64_t EncapsulatedSession::GetMaxDatagramSize() const { … }
void EncapsulatedSession::SetDatagramMaxTimeInQueue(
absl::Duration ) { … }
void EncapsulatedSession::OnCanWrite() { … }
void EncapsulatedSession::OnCanRead() { … }
bool EncapsulatedSession::OnCapsule(const quiche::Capsule& capsule) { … }
void EncapsulatedSession::OnCapsuleParseFailure(
absl::string_view error_message) { … }
void EncapsulatedSession::ProcessStreamCapsule(const quiche::Capsule& capsule,
StreamId stream_id) { … }
void EncapsulatedSession::InnerStream::ProcessCapsule(
const quiche::Capsule& capsule) { … }
void EncapsulatedSession::OpenSession() { … }
absl::Status EncapsulatedSession::SendFin(absl::string_view data) { … }
void EncapsulatedSession::OnSessionClosed(SessionErrorCode error_code,
const std::string& error_message) { … }
void EncapsulatedSession::OnFatalError(absl::string_view error_message) { … }
void EncapsulatedSession::OnWriteError(absl::Status error) { … }
EncapsulatedSession::InnerStream::InnerStream(EncapsulatedSession* session,
StreamId id)
: … { … }
quiche::ReadStream::ReadResult EncapsulatedSession::InnerStream::Read(
absl::Span<char> output) { … }
quiche::ReadStream::ReadResult EncapsulatedSession::InnerStream::Read(
std::string* output) { … }
size_t EncapsulatedSession::InnerStream::ReadableBytes() const { … }
quiche::ReadStream::PeekResult
EncapsulatedSession::InnerStream::PeekNextReadableRegion() const { … }
bool EncapsulatedSession::InnerStream::SkipBytes(size_t bytes) { … }
absl::Status EncapsulatedSession::InnerStream::Writev(
const absl::Span<const absl::string_view> data,
const quiche::StreamWriteOptions& options) { … }
bool EncapsulatedSession::InnerStream::CanWrite() const { … }
void EncapsulatedSession::InnerStream::FlushPendingWrite() { … }
size_t EncapsulatedSession::InnerStream::WriteInner(
absl::Span<const absl::string_view> data, bool fin) { … }
void EncapsulatedSession::InnerStream::AbruptlyTerminate(absl::Status error) { … }
void EncapsulatedSession::InnerStream::ResetWithUserCode(
StreamErrorCode error) { … }
void EncapsulatedSession::InnerStream::SendStopSending(StreamErrorCode error) { … }
void EncapsulatedSession::InnerStream::CloseReadSide(
std::optional<StreamErrorCode> error) { … }
void EncapsulatedSession::InnerStream::CloseWriteSide(
std::optional<StreamErrorCode> error) { … }
void EncapsulatedSession::GarbageCollectStreams() { … }
void EncapsulatedSession::InnerStream::SetPriority(
const StreamPriority& priority) { … }
}