QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // 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 | |
| 21 | namespace quic { |
| 22 | |
| 23 | class 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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 35 | 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 | |
dschinazi | 7b9278c | 2019-05-20 07:36:21 -0700 | [diff] [blame] | 43 | QuartcSession* CreateQuicSession(QuicConnectionId server_connection_id, |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 44 | const QuicSocketAddress& client_address, |
| 45 | QuicStringPiece alpn, |
| 46 | const ParsedQuicVersion& version) override; |
| 47 | |
wub | 662a3d6 | 2019-08-16 14:10:50 -0700 | [diff] [blame] | 48 | // TODO(b/124399417): Override GenerateNewServerConnectionId and request a |
| 49 | // zero-length connection id when the QUIC server perspective supports it. |
| 50 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 51 | // QuartcPacketTransport::Delegate overrides. |
| 52 | void OnTransportCanWrite() override; |
| 53 | void OnTransportReceived(const char* data, size_t data_len) override; |
| 54 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 55 | 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 team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 59 | |
| 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_ |