Repository: envoyproxy/envoy
File: source/common/quic/envoy_quic_client_session.h (C/C++)

Code before:

  quic::HttpDatagramSupport LocalHttpDatagramSupport() override { return http_datagram_support_; }
  std::vector<std::string> GetAlpnsToOffer() const override;

  // quic::QuicSpdyClientSessionBase
  bool ShouldKeepConnectionAlive() const override;
  // quic::ProofHandler
  void OnProofVerifyDetailsAvailable(const quic::ProofVerifyDetails& verify_details) override;

  // PacketsToReadDelegate
  size_t numPacketsExpectedPerEventLoop() const override {
    // Do one round of reading per active stream, or to see if there's a new
    // active stream.
    return std::max<size_t>(1, GetNumActiveStreams()) * Network::NUM_DATAGRAMS_PER_RECEIVE;
  }

  // QuicFilterManagerConnectionImpl
  void setHttp3Options(const envoy::config::core::v3::Http3ProtocolOptions& http3_options) override;

  // Notify any registered connection pool when new streams are available.
  void OnCanCreateNewOutgoingStream(bool) override;

  void OnServerPreferredAddressAvailable(
      const quic::QuicSocketAddress& server_preferred_address) override;

  // Called when the device switches to a different network.
  void notifyServerGoAway(Http::GoAwayErrorCode error);

  // Register this session to the given registry for receiving network change events.
  void registerNetworkObserver(EnvoyQuicNetworkObserverRegistry& registry);

  using quic::QuicSpdyClientSession::PerformActionOnActiveStreams;

protected:
  // quic::QuicSpdyClientSession
  std::unique_ptr<quic::QuicSpdyClientStream> CreateClientStream() override;
  // quic::QuicSpdySession
  quic::QuicSpdyStream* CreateIncomingStream(quic::QuicStreamId id) override;
  quic::QuicSpdyStream* CreateIncomingStream(quic::PendingStream* pending) override;
  std::unique_ptr<quic::QuicCryptoClientStreamBase> CreateQuicCryptoStream() override;
  bool ShouldCreateOutgoingBidirectionalStream() override {
    ASSERT(quic::QuicSpdyClientSession::ShouldCreateOutgoingBidirectionalStream());
    // Prefer creating an "invalid" stream outside of current stream bounds to
    // crashing when dereferencing a nullptr in QuicHttpClientConnectionImpl::newStream
    return true;
  }
  // QuicFilterManagerConnectionImpl
  bool hasDataToWrite() override;
  // Used by base class to access quic connection after initialization.
  const quic::QuicConnection* quicConnection() const override;
  quic::QuicConnection* quicConnection() override;

Review comment (suggestion):
I think this comment is really explaining the behavior of `QuicNetworkConnectivityObserver::onNetworkChanged()` not the behavior of `notifyServerGoAway()`. How about something like:

Notifies the HTTP connection callbacks that a GOAWAY was received.

(Or some such)

Or alternatively perhaps make the public method something like `onNetworkChanged()` (or something) which takes no args. Then only in the implementation of this method would we need a comment about `Other` vs `NoError`

Code after:
  void OnTlsHandshakeComplete() override;
  void OnRstStream(const quic::QuicRstStreamFrame& frame) override;
  void OnNewEncryptionKeyAvailable(quic::EncryptionLevel level,
                                   std::unique_ptr<quic::QuicEncrypter> encrypter) override;

  quic::HttpDatagramSupport LocalHttpDatagramSupport() override { return http_datagram_support_; }
  std::vector<std::string> GetAlpnsToOffer() const override;

  // quic::QuicSpdyClientSessionBase
  bool ShouldKeepConnectionAlive() const override;
  // quic::ProofHandler
  void OnProofVerifyDetailsAvailable(const quic::ProofVerifyDetails& verify_details) override;

  // PacketsToReadDelegate
  size_t numPacketsExpectedPerEventLoop() const override {
    // Do one round of reading per active stream, or to see if there's a new active stream.
    return std::max<size_t>(1, GetNumActiveStreams()) * Network::NUM_DATAGRAMS_PER_RECEIVE;
  }

  // QuicFilterManagerConnectionImpl
  void setHttp3Options(const envoy::config::core::v3::Http3ProtocolOptions& http3_options) override;

  // Notify any registered connection pool when new streams are available.
  void OnCanCreateNewOutgoingStream(bool) override;

  void OnServerPreferredAddressAvailable(
      const quic::QuicSocketAddress& server_preferred_address) override;

  // Register this session to the given registry for receiving network change events.
  void registerNetworkObserver(EnvoyQuicNetworkObserverRegistry& registry);

  using quic::QuicSpdyClientSession::PerformActionOnActiveStreams;

protected:
  // quic::QuicSpdyClientSession
  std::unique_ptr<quic::QuicSpdyClientStream> CreateClientStream() override;
  // quic::QuicSpdySession
  quic::QuicSpdyStream* CreateIncomingStream(quic::QuicStreamId id) override;
  quic::QuicSpdyStream* CreateIncomingStream(quic::PendingStream* pending) override;
  std::unique_ptr<quic::QuicCryptoClientStreamBase> CreateQuicCryptoStream() override;
  bool ShouldCreateOutgoingBidirectionalStream() override {
    ASSERT(quic::QuicSpdyClientSession::ShouldCreateOutgoingBidirectionalStream());
    // Prefer creating an "invalid" stream outside of current stream bounds to
    // crashing when dereferencing a nullptr in QuicHttpClientConnectionImpl::newStream
    return true;
  }
  // QuicFilterManagerConnectionImpl
  bool hasDataToWrite() override;
  // Used by base class to access quic connection after initialization.
  const quic::QuicConnection* quicConnection() const override;
  quic::QuicConnection* quicConnection() override;