xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/tools/quic_simple_dispatcher.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2012 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_TOOLS_QUIC_SIMPLE_DISPATCHER_H_
6 #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_DISPATCHER_H_
7 
8 #include "absl/strings/string_view.h"
9 #include "quiche/quic/core/connection_id_generator.h"
10 #include "quiche/quic/core/http/quic_server_session_base.h"
11 #include "quiche/quic/core/quic_dispatcher.h"
12 #include "quiche/quic/core/quic_types.h"
13 #include "quiche/quic/core/quic_versions.h"
14 #include "quiche/quic/tools/quic_simple_server_backend.h"
15 
16 namespace quic {
17 
18 class QuicSimpleDispatcher : public QuicDispatcher {
19  public:
20   QuicSimpleDispatcher(
21       const QuicConfig* config, const QuicCryptoServerConfig* crypto_config,
22       QuicVersionManager* version_manager,
23       std::unique_ptr<QuicConnectionHelperInterface> helper,
24       std::unique_ptr<QuicCryptoServerStreamBase::Helper> session_helper,
25       std::unique_ptr<QuicAlarmFactory> alarm_factory,
26       QuicSimpleServerBackend* quic_simple_server_backend,
27       uint8_t expected_server_connection_id_length,
28       ConnectionIdGeneratorInterface& generator);
29 
30   ~QuicSimpleDispatcher() override;
31 
32   int GetRstErrorCount(QuicRstStreamErrorCode rst_error_code) const;
33 
34   void OnRstStreamReceived(const QuicRstStreamFrame& frame) override;
35 
36  protected:
37   std::unique_ptr<QuicSession> CreateQuicSession(
38       QuicConnectionId connection_id, const QuicSocketAddress& self_address,
39       const QuicSocketAddress& peer_address, absl::string_view alpn,
40       const ParsedQuicVersion& version, const ParsedClientHello& parsed_chlo,
41       ConnectionIdGeneratorInterface& connection_id_generator) override;
42 
server_backend()43   QuicSimpleServerBackend* server_backend() {
44     return quic_simple_server_backend_;
45   }
46 
47  private:
48   QuicSimpleServerBackend* quic_simple_server_backend_;  // Unowned.
49 
50   // The map of the reset error code with its counter.
51   std::map<QuicRstStreamErrorCode, int> rst_error_map_;
52 };
53 
54 }  // namespace quic
55 
56 #endif  // QUICHE_QUIC_TOOLS_QUIC_SIMPLE_DISPATCHER_H_
57