xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/core/stream_delegate_interface.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2019 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_CORE_STREAM_DELEGATE_INTERFACE_H_
6 #define QUICHE_QUIC_CORE_STREAM_DELEGATE_INTERFACE_H_
7 
8 #include <cstddef>
9 #include <optional>
10 
11 #include "quiche/quic/core/quic_stream_priority.h"
12 #include "quiche/quic/core/quic_types.h"
13 
14 namespace quic {
15 
16 class QuicStream;
17 
18 // Pure virtual class to get notified when particular QuicStream events
19 // occurred.
20 class QUICHE_EXPORT StreamDelegateInterface {
21  public:
~StreamDelegateInterface()22   virtual ~StreamDelegateInterface() {}
23 
24   // Called when the stream has encountered errors that it can't handle.
25   virtual void OnStreamError(QuicErrorCode error_code,
26                              std::string error_details) = 0;
27   // Called when the stream has encountered errors that it can't handle,
28   // specifying the wire error code |ietf_error| explicitly.
29   virtual void OnStreamError(QuicErrorCode error_code,
30                              QuicIetfTransportErrorCodes ietf_error,
31                              std::string error_details) = 0;
32   // Called when the stream needs to write data at specified |level| and
33   // transmission |type|.
34   virtual QuicConsumedData WritevData(QuicStreamId id, size_t write_length,
35                                       QuicStreamOffset offset,
36                                       StreamSendingState state,
37                                       TransmissionType type,
38                                       EncryptionLevel level) = 0;
39   // Called to write crypto data.
40   virtual size_t SendCryptoData(EncryptionLevel level, size_t write_length,
41                                 QuicStreamOffset offset,
42                                 TransmissionType type) = 0;
43   // Called on stream creation.
44   virtual void RegisterStreamPriority(QuicStreamId id, bool is_static,
45                                       const QuicStreamPriority& priority) = 0;
46   // Called on stream destruction to clear priority.
47   virtual void UnregisterStreamPriority(QuicStreamId id) = 0;
48   // Called by the stream on SetPriority to update priority.
49   virtual void UpdateStreamPriority(QuicStreamId id,
50                                     const QuicStreamPriority& new_priority) = 0;
51 };
52 
53 }  // namespace quic
54 
55 #endif  // QUICHE_QUIC_CORE_STREAM_DELEGATE_INTERFACE_H_
56