LCOV - code coverage report
Current view: top level - source/common/quic - quic_network_connection.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 4 12 33.3 %
Date: 2024-01-05 06:35:25 Functions: 2 6 33.3 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <memory>
       4             : 
       5             : #include "envoy/network/connection.h"
       6             : 
       7             : #include "source/common/common/logger.h"
       8             : 
       9             : namespace Envoy {
      10             : namespace Quic {
      11             : 
      12             : // Read ~32k bytes per connection by default, which is about the same as TCP.
      13             : static const uint32_t DEFAULT_PACKETS_TO_READ_PER_CONNECTION = 32u;
      14             : 
      15             : class QuicWriteEventCallback {
      16             : public:
      17         515 :   virtual ~QuicWriteEventCallback() = default;
      18             :   // Called when QUIC finishes a write.
      19             :   virtual void onWriteEventDone() PURE;
      20             : };
      21             : 
      22             : // A base class of both the client and server connections which keeps stats and
      23             : // connection socket.
      24             : class QuicNetworkConnection : protected Logger::Loggable<Logger::Id::connection> {
      25             : public:
      26             :   QuicNetworkConnection(Network::ConnectionSocketPtr&& connection_socket);
      27             : 
      28             :   virtual ~QuicNetworkConnection();
      29             : 
      30             :   // Called by EnvoyQuicSession::setConnectionStats().
      31           0 :   void setConnectionStats(const Network::Connection::ConnectionStats& stats) {
      32           0 :     connection_stats_ = std::make_unique<Network::Connection::ConnectionStats>(stats);
      33           0 :   }
      34             : 
      35             :   // Called in session Initialize().
      36             :   void setEnvoyConnection(Network::Connection& connection, QuicWriteEventCallback& write_callback);
      37             : 
      38        1545 :   const Network::ConnectionSocketPtr& connectionSocket() const {
      39        1545 :     return connection_sockets_.back();
      40        1545 :   }
      41             : 
      42             :   // Needed for ENVOY_CONN_LOG.
      43             :   uint64_t id() const;
      44             : 
      45             : protected:
      46           0 :   Network::Connection::ConnectionStats& connectionStats() const { return *connection_stats_; }
      47             : 
      48           0 :   void setConnectionSocket(Network::ConnectionSocketPtr&& connection_socket) {
      49           0 :     connection_sockets_.push_back(std::move(connection_socket));
      50           0 :   }
      51             : 
      52             :   void onWriteEventDone();
      53             : 
      54           0 :   Network::Connection* networkConnection() { return envoy_connection_; }
      55             : 
      56             : private:
      57             :   // TODO(danzh): populate stats.
      58             :   std::unique_ptr<Network::Connection::ConnectionStats> connection_stats_;
      59             :   // Hosts a list of active sockets, while only the last one is used for writing data.
      60             :   // Hosts a single default socket upon construction. New sockets can be pushed in later as a result
      61             :   // of QUIC connection migration.
      62             :   std::vector<Network::ConnectionSocketPtr> connection_sockets_;
      63             :   // Points to an instance of EnvoyQuicServerSession or EnvoyQuicClientSession.
      64             :   Network::Connection* envoy_connection_{nullptr};
      65             :   QuicWriteEventCallback* write_callback_{nullptr};
      66             : };
      67             : 
      68             : } // namespace Quic
      69             : } // namespace Envoy

Generated by: LCOV version 1.15