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_QUIC_PLATFORM_API_QUIC_TEST_MEM_SLICE_VECTOR_H_ 6 #define QUICHE_QUIC_PLATFORM_API_QUIC_TEST_MEM_SLICE_VECTOR_H_ 7 8 #include <utility> 9 10 #include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" 11 #include "net/quic/platform/impl/quic_test_mem_slice_vector_impl.h" 12 13 namespace quic { 14 namespace test { 15 // QuicTestMemSliceVector is a test only class which creates a vector of 16 // platform-specific data structure (used as QuicMemSlice) from an array of data 17 // buffers. QuicTestMemSliceVector does not own the underlying data buffer. 18 // Tests using QuicTestMemSliceVector need to make sure the actual data buffers 19 // outlive QuicTestMemSliceVector, and QuicTestMemSliceVector outlive the 20 // returned QuicMemSliceSpan. 21 class QUIC_NO_EXPORT QuicTestMemSliceVector { 22 public: QuicTestMemSliceVector(std::vector<std::pair<char *,size_t>> buffers)23 explicit QuicTestMemSliceVector(std::vector<std::pair<char*, size_t>> buffers) 24 : impl_(std::move(buffers)) {} 25 span()26 QuicMemSliceSpan span() { return QuicMemSliceSpan(impl_.span()); } 27 28 private: 29 QuicTestMemSliceVectorImpl impl_; 30 }; 31 32 } // namespace test 33 } // namespace quic 34 35 #endif // QUICHE_QUIC_PLATFORM_API_QUIC_TEST_MEM_SLICE_VECTOR_H_ 36