blob: 7ac3dae14c6282372ccdb8bc8f52975e0fe7dc69 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright (c) 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef QUICHE_QUIC_QUARTC_QUARTC_DISPATCHER_H_
6#define QUICHE_QUIC_QUARTC_QUARTC_DISPATCHER_H_
7
8#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h"
9#include "net/third_party/quiche/src/quic/core/quic_alarm_factory.h"
10#include "net/third_party/quiche/src/quic/core/quic_config.h"
11#include "net/third_party/quiche/src/quic/core/quic_connection.h"
12#include "net/third_party/quiche/src/quic/core/quic_connection_id.h"
13#include "net/third_party/quiche/src/quic/core/quic_crypto_server_stream.h"
14#include "net/third_party/quiche/src/quic/core/quic_dispatcher.h"
15#include "net/third_party/quiche/src/quic/core/quic_version_manager.h"
16#include "net/third_party/quiche/src/quic/core/quic_versions.h"
17#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050018#include "net/third_party/quiche/src/quic/quartc/quartc_session.h"
dmcardlec60e87a2019-12-12 09:43:19 -080019#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050020
21namespace quic {
22
23class QuartcDispatcher : public QuicDispatcher,
24 QuartcPacketTransport::Delegate {
25 public:
26 class Delegate {
27 public:
28 virtual ~Delegate() = default;
29 virtual void OnSessionCreated(QuartcSession* session) = 0;
30 };
31
32 QuartcDispatcher(
33 std::unique_ptr<QuicConfig> config,
34 std::unique_ptr<QuicCryptoServerConfig> crypto_config,
QUICHE teama6ef0a62019-03-07 20:34:33 -050035 QuicVersionManager* version_manager,
36 std::unique_ptr<QuicConnectionHelperInterface> helper,
37 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper,
38 std::unique_ptr<QuicAlarmFactory> alarm_factory,
39 std::unique_ptr<QuartcPacketWriter> packet_writer,
40 Delegate* delegate);
41 ~QuartcDispatcher() override;
42
wub89490e02019-12-12 12:45:58 -080043 std::unique_ptr<QuicSession> CreateQuicSession(
44 QuicConnectionId server_connection_id,
45 const QuicSocketAddress& client_address,
46 quiche::QuicheStringPiece alpn,
47 const ParsedQuicVersion& version) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -050048
wub662a3d62019-08-16 14:10:50 -070049 // TODO(b/124399417): Override GenerateNewServerConnectionId and request a
50 // zero-length connection id when the QUIC server perspective supports it.
51
QUICHE teama6ef0a62019-03-07 20:34:33 -050052 // QuartcPacketTransport::Delegate overrides.
53 void OnTransportCanWrite() override;
54 void OnTransportReceived(const char* data, size_t data_len) override;
55
QUICHE teama6ef0a62019-03-07 20:34:33 -050056 private:
57 // Members owned by QuartcDispatcher but not QuicDispatcher.
58 std::unique_ptr<QuicConfig> owned_quic_config_;
59 std::unique_ptr<QuicCryptoServerConfig> owned_crypto_config_;
QUICHE teama6ef0a62019-03-07 20:34:33 -050060
61 // Delegate invoked when the dispatcher creates a new session.
62 Delegate* delegate_;
63
64 // The packet writer used by this dispatcher. Owned by the base class, but
65 // the base class upcasts it to QuicPacketWriter (which prevents detaching the
66 // transport delegate without a downcast).
67 QuartcPacketWriter* packet_writer_;
68};
69
70} // namespace quic
71
72#endif // QUICHE_QUIC_QUARTC_QUARTC_DISPATCHER_H_