1 // Copyright (c) 2016 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_FRAMES_QUIC_STREAM_FRAME_H_ 6 #define QUICHE_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_ 7 8 #include <memory> 9 #include <ostream> 10 11 #include "absl/strings/string_view.h" 12 #include "quiche/quic/core/frames/quic_inlined_frame.h" 13 #include "quiche/quic/core/quic_types.h" 14 #include "quiche/quic/platform/api/quic_export.h" 15 16 namespace quic { 17 18 struct QUICHE_EXPORT QuicStreamFrame 19 : public QuicInlinedFrame<QuicStreamFrame> { 20 QuicStreamFrame(); 21 QuicStreamFrame(QuicStreamId stream_id, bool fin, QuicStreamOffset offset, 22 absl::string_view data); 23 QuicStreamFrame(QuicStreamId stream_id, bool fin, QuicStreamOffset offset, 24 QuicPacketLength data_length); 25 26 friend QUICHE_EXPORT std::ostream& operator<<(std::ostream& os, 27 const QuicStreamFrame& s); 28 29 bool operator==(const QuicStreamFrame& rhs) const; 30 31 bool operator!=(const QuicStreamFrame& rhs) const; 32 33 QuicFrameType type; 34 bool fin = false; 35 QuicPacketLength data_length = 0; 36 // TODO(wub): Change to a QuicUtils::GetInvalidStreamId when it is not version 37 // dependent. 38 QuicStreamId stream_id = -1; 39 const char* data_buffer = nullptr; // Not owned. 40 QuicStreamOffset offset = 0; // Location of this data in the stream. 41 42 QuicStreamFrame(QuicStreamId stream_id, bool fin, QuicStreamOffset offset, 43 const char* data_buffer, QuicPacketLength data_length); 44 }; 45 static_assert(sizeof(QuicStreamFrame) <= 64, 46 "Keep the QuicStreamFrame size to a cacheline."); 47 48 } // namespace quic 49 50 #endif // QUICHE_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_ 51