• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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_COMMON_QUICHE_MEM_SLICE_STORAGE_H_
6 #define QUICHE_COMMON_QUICHE_MEM_SLICE_STORAGE_H_
7 
8 #include <vector>
9 
10 #include "absl/types/span.h"
11 #include "quiche/quic/core/quic_types.h"
12 #include "quiche/common/platform/api/quiche_export.h"
13 #include "quiche/common/platform/api/quiche_iovec.h"
14 #include "quiche/common/platform/api/quiche_mem_slice.h"
15 #include "quiche/common/quiche_buffer_allocator.h"
16 
17 namespace quiche {
18 
19 // QuicheMemSliceStorage is a container class that store QuicheMemSlices for
20 // further use cases such as turning into QuicheMemSliceSpan.
21 class QUICHE_EXPORT QuicheMemSliceStorage {
22  public:
23   QuicheMemSliceStorage(const struct iovec* iov, int iov_count,
24                         QuicheBufferAllocator* allocator,
25                         const quic::QuicByteCount max_slice_len);
26 
27   QuicheMemSliceStorage(const QuicheMemSliceStorage& other) = delete;
28   QuicheMemSliceStorage& operator=(const QuicheMemSliceStorage& other) = delete;
29   QuicheMemSliceStorage(QuicheMemSliceStorage&& other) = default;
30   QuicheMemSliceStorage& operator=(QuicheMemSliceStorage&& other) = default;
31 
32   ~QuicheMemSliceStorage() = default;
33 
34   // Return a QuicheMemSliceSpan form of the storage.
ToSpan()35   absl::Span<QuicheMemSlice> ToSpan() { return absl::MakeSpan(storage_); }
36 
37  private:
38   std::vector<QuicheMemSlice> storage_;
39 };
40 
41 }  // namespace quiche
42 
43 #endif  // QUICHE_COMMON_QUICHE_MEM_SLICE_STORAGE_H_
44