blob: 06e799ea98a95c0ddf96c7c1e8a2bd529f43618e [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"
18#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
19#include "net/third_party/quiche/src/quic/quartc/quartc_session.h"
20
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
dschinazi7b9278c2019-05-20 07:36:21 -070043 QuartcSession* CreateQuicSession(QuicConnectionId server_connection_id,
QUICHE teama6ef0a62019-03-07 20:34:33 -050044 const QuicSocketAddress& client_address,
45 QuicStringPiece alpn,
46 const ParsedQuicVersion& version) override;
47
wub662a3d62019-08-16 14:10:50 -070048 // TODO(b/124399417): Override GenerateNewServerConnectionId and request a
49 // zero-length connection id when the QUIC server perspective supports it.
50
QUICHE teama6ef0a62019-03-07 20:34:33 -050051 // QuartcPacketTransport::Delegate overrides.
52 void OnTransportCanWrite() override;
53 void OnTransportReceived(const char* data, size_t data_len) override;
54
QUICHE teama6ef0a62019-03-07 20:34:33 -050055 private:
56 // Members owned by QuartcDispatcher but not QuicDispatcher.
57 std::unique_ptr<QuicConfig> owned_quic_config_;
58 std::unique_ptr<QuicCryptoServerConfig> owned_crypto_config_;
QUICHE teama6ef0a62019-03-07 20:34:33 -050059
60 // Delegate invoked when the dispatcher creates a new session.
61 Delegate* delegate_;
62
63 // The packet writer used by this dispatcher. Owned by the base class, but
64 // the base class upcasts it to QuicPacketWriter (which prevents detaching the
65 // transport delegate without a downcast).
66 QuartcPacketWriter* packet_writer_;
67};
68
69} // namespace quic
70
71#endif // QUICHE_QUIC_QUARTC_QUARTC_DISPATCHER_H_