blob: 9164e9af74b16c7b56395f82e9bd39cac2d9b7d1 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright 2017 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_PLATFORM_API_QUIC_MEM_SLICE_STORAGE_H_
6#define QUICHE_QUIC_PLATFORM_API_QUIC_MEM_SLICE_STORAGE_H_
7
8#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
9#include "net/quic/platform/impl/quic_mem_slice_storage_impl.h"
10
11namespace quic {
12
13// QuicMemSliceStorage is a container class that store QuicMemSlices for further
14// use cases such as turning into QuicMemSliceSpan.
15class QUIC_EXPORT_PRIVATE QuicMemSliceStorage {
16 public:
17 QuicMemSliceStorage(const struct iovec* iov,
18 int iov_count,
19 QuicBufferAllocator* allocator,
20 const QuicByteCount max_slice_len)
21 : impl_(iov, iov_count, allocator, max_slice_len) {}
22
23 QuicMemSliceStorage(const QuicMemSliceStorage& other) = default;
24 QuicMemSliceStorage& operator=(const QuicMemSliceStorage& other) = default;
25 QuicMemSliceStorage(QuicMemSliceStorage&& other) = default;
26 QuicMemSliceStorage& operator=(QuicMemSliceStorage&& other) = default;
27
28 ~QuicMemSliceStorage() = default;
29
30 // Return a QuicMemSliceSpan form of the storage.
31 QuicMemSliceSpan ToSpan() { return impl_.ToSpan(); }
32
QUICHE teamea197352019-07-16 16:54:52 -070033 void Append(QuicMemSlice slice) { impl_.Append(std::move(*slice.impl())); }
34
QUICHE teama6ef0a62019-03-07 20:34:33 -050035 private:
36 QuicMemSliceStorageImpl impl_;
37};
38
39} // namespace quic
40
41#endif // QUICHE_QUIC_PLATFORM_API_QUIC_MEM_SLICE_STORAGE_H_