blob: 08c4869ab7e94e9f126687263b113c9d68eebd37 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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_INLINED_FRAME_H_
6#define QUICHE_QUIC_CORE_FRAMES_QUIC_INLINED_FRAME_H_
7
8#include "net/third_party/quiche/src/quic/core/quic_types.h"
9#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
10
11namespace quic {
12
13// QuicInlinedFrame is the base class of all frame types that is inlined in the
14// QuicFrame class. It gurantees all inlined frame types contain a 'type' field
15// at offset 0, such that QuicFrame.type can get the correct frame type for both
16// inline and out-of-line frame types.
17template <typename DerivedT>
18struct QUIC_EXPORT_PRIVATE QuicInlinedFrame {
19 QuicInlinedFrame(QuicFrameType type) : type(type) {
20 static_assert(offsetof(DerivedT, type) == 0,
21 "type must be the first field.");
22 static_assert(sizeof(DerivedT) <= 24,
23 "Frames larger than 24 bytes should not be inlined.");
24 }
25 QuicFrameType type;
26};
27
28} // namespace quic
29
30#endif // QUICHE_QUIC_CORE_FRAMES_QUIC_INLINED_FRAME_H_