blob: 6a629537ba2559506c73e19b6a48b92b7db20992 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module network.mojom;
import "mojo/public/mojom/base/read_only_buffer.mojom";
import "mojo/public/mojom/base/time.mojom";
import "url/mojom/url.mojom";
// Represents a QuicTransport error.
// See also: net/quic/quic_transport_client.h
struct QuicTransportError {
// A net error (see net/base/net_errors.h).
int32 net_error = 0;
// A QUIC error (see
// net/third_party/quiche/src/quic/core/quic_error_codes.h).
int32 quic_error = 0;
// Human-readable error summary.
string details;
// QuicTransport requires that the connection errors have to be
// undistinguishable until the peer is confirmed to be a QuicTransport
// endpoint. See
bool safe_to_report_details = false;
// The fingerprint of a certificate accompanied with the hash algorithm.
struct QuicTransportCertificateFingerprint {
string algorithm;
string fingerprint;
// A mojo interface for
interface QuicTransport {
// A datagram message is sent from the client. The response message represents
// whether the peer has sent or discarded the datagram.
SendDatagram(mojo_base.mojom.ReadOnlyBuffer data) => (bool result);
// Stream creation initiated by the client. |succeeded| represents whether
// the stream is created successfully, and |stream_id| is meaningful only
// when |succeeded| is true. |writable| is nullable, to support both
// unidirectional and bidirectional streams.
CreateStream(handle<data_pipe_consumer> readable,
handle<data_pipe_producer>? writable) =>
(bool succeeded, uint32 stream_id);
// Accepts a bidirectional stream created by the server.
AcceptBidirectionalStream() => (uint32 stream_id,
handle<data_pipe_consumer> readable,
handle<data_pipe_producer> writable);
// Accepts a unidirectional stream created by the server.
AcceptUnidirectionalStream() => (uint32 stream_id,
handle<data_pipe_consumer> readable);
// Expresses that the client will not write data to the stream for
// |stream_id|. After calling this function on a stream, the client will not
// be able to write any data to the stream, but it may be able to use other
// functions such as reading data from the stream.
SendFin(uint32 stream_id);
// Aborts the stream for |stream_id|.
AbortStream(uint32 stream_id, uint64 code);
// Sets the duration which determines whether an outgoing datagram should be
// discarded due to being in the queue for too long.
SetOutgoingDatagramExpirationDuration(mojo_base.mojom.TimeDelta duration);
// A mojo interface for the client of QuicTransport.
interface QuicTransportClient {
// A datagram message is sent from the server.
OnDatagramReceived(mojo_base.mojom.ReadOnlyBuffer data);
// Notifies that the server will not write data to the Stream for |stream_id|.
// |fin_received| is true when FIN is received from the server.
// Note that OnIncomingStreamClosed and OnOutgoingStreamClosed can both be
// dispatched to the same stream, if it is a bidirectional stream.
OnIncomingStreamClosed(uint32 stream_id, bool fin_received);
// Used to create a QuicTransport connection. This is split from QuicTransport
// so that the handshake part can be intercepted, by Chrome extensions for
// example.
// Some parameters may contain information that cannot be handed to the
// initiator renderer due to security and privacy reasons. There should be
// an QuicTransportHandshakeClient implementation in the browser process
// which ensures that a QuicTransportHandshakeClient implemented in renderers
// doesn't see such information.
interface QuicTransportHandshakeClient {
// Called when the handshake succeeds.
OnConnectionEstablished(pending_remote<QuicTransport> transport,
pending_receiver<QuicTransportClient> client);
// Called when the handshake fails.
// |error| contains the error details. The actual error information issued
// by the network service should not be handed to the initiator renderer.
OnHandshakeFailed(QuicTransportError? error);