Commit 4243798f authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Introduce QuicTransportClient.OnDatagramReceived

Bug: 1011392
Change-Id: I1a3871505ae836adfbc393dfbe2ab028a0159817
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2000410Reviewed-by: default avatarVictor Vasiliev <vasilvv@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732375}
parent 48b18b5d
......@@ -39,6 +39,9 @@ interface QuicTransport {
// 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
......
......@@ -513,7 +513,15 @@ void QuicTransport::OnIncomingUnidirectionalStreamAvailable() {
}
void QuicTransport::OnIncomingDatagramAvailable() {
// TODO(yhirano): Implement this.
if (torn_down_) {
return;
}
base::Optional<std::string> datagram = transport_->session()->ReadDatagram();
DCHECK(datagram);
client_->OnDatagramReceived(base::make_span(
reinterpret_cast<const uint8_t*>(datagram->data()), datagram->size()));
}
void QuicTransport::OnCanCreateNewOutgoingBidirectionalStream() {
......
......@@ -115,6 +115,7 @@ class TestClient final : public mojom::QuicTransportClient {
}
// mojom::QuicTransportClient implementation.
void OnDatagramReceived(base::span<const uint8_t> data) override {}
void OnIncomingStreamClosed(uint32_t stream_id, bool fin_received) override {
closed_incoming_streams_.insert(std::make_pair(stream_id, fin_received));
if (quit_closure_for_incoming_stream_closure_) {
......@@ -311,6 +312,9 @@ TEST_F(QuicTransportTest, SendDatagram) {
EXPECT_TRUE(result);
}
// TODO(yhirano): Add a test for OnDatagramReceived. It would be difficult due
// to the flaky nature of datagrams.
TEST_F(QuicTransportTest, SendToolargeDatagram) {
base::RunLoop run_loop_for_handshake;
mojo::PendingRemote<mojom::QuicTransportHandshakeClient> handshake_client;
......
......@@ -177,6 +177,12 @@ void QuicTransport::OnHandshakeFailed() {
Dispose();
}
void QuicTransport::OnDatagramReceived(base::span<const uint8_t> data) {
DVLOG(1) << "QuicTransport::OnDatagramReceived(size: " << data.size()
<< ") this =" << this;
// TODO(ricea): Implement this.
}
void QuicTransport::OnIncomingStreamClosed(uint32_t stream_id,
bool fin_received) {
DVLOG(1) << "QuicTransport::OnIncomingStreamClosed(" << stream_id << ", "
......
......@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBTRANSPORT_QUIC_TRANSPORT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBTRANSPORT_QUIC_TRANSPORT_H_
#include "base/containers/span.h"
#include "base/util/type_safety/pass_key.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
......@@ -60,6 +61,7 @@ class MODULES_EXPORT QuicTransport final
void OnHandshakeFailed() override;
// QuicTransportClient implementation
void OnDatagramReceived(base::span<const uint8_t> data) override;
void OnIncomingStreamClosed(uint32_t stream_id, bool fin_received) override;
// Implementation of ContextLifecycleObserver
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment