1 // Copyright (c) 2018 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_MESSAGE_FRAME_H_ 6 #define QUICHE_QUIC_CORE_FRAMES_QUIC_MESSAGE_FRAME_H_ 7 8 #include "absl/container/inlined_vector.h" 9 #include "absl/types/span.h" 10 #include "quiche/quic/core/quic_types.h" 11 #include "quiche/quic/platform/api/quic_export.h" 12 #include "quiche/common/platform/api/quiche_mem_slice.h" 13 14 namespace quic { 15 16 using QuicMessageData = absl::InlinedVector<quiche::QuicheMemSlice, 1>; 17 18 struct QUICHE_EXPORT QuicMessageFrame { 19 QuicMessageFrame() = default; 20 explicit QuicMessageFrame(QuicMessageId message_id); 21 QuicMessageFrame(QuicMessageId message_id, 22 absl::Span<quiche::QuicheMemSlice> span); 23 QuicMessageFrame(QuicMessageId message_id, quiche::QuicheMemSlice slice); 24 QuicMessageFrame(const char* data, QuicPacketLength length); 25 26 QuicMessageFrame(const QuicMessageFrame& other) = delete; 27 QuicMessageFrame& operator=(const QuicMessageFrame& other) = delete; 28 29 QuicMessageFrame(QuicMessageFrame&& other) = default; 30 QuicMessageFrame& operator=(QuicMessageFrame&& other) = default; 31 32 ~QuicMessageFrame(); 33 34 friend QUICHE_EXPORT std::ostream& operator<<(std::ostream& os, 35 const QuicMessageFrame& s); 36 37 // message_id is only used on the sender side and does not get serialized on 38 // wire. 39 QuicMessageId message_id = 0; 40 // Not owned, only used on read path. 41 const char* data = nullptr; 42 // Total length of message_data, must be fit into one packet. 43 QuicPacketLength message_length = 0; 44 45 // The actual message data which is reference counted, used on write path. 46 QuicMessageData message_data; 47 }; 48 49 } // namespace quic 50 51 #endif // QUICHE_QUIC_CORE_FRAMES_QUIC_MESSAGE_FRAME_H_ 52