Project import generated by Copybara.
PiperOrigin-RevId: 229942388
Change-Id: Ib5a23c152c95ed4294cece9f902227c21ce531ef
diff --git a/spdy/platform/api/spdy_mem_slice.h b/spdy/platform/api/spdy_mem_slice.h
new file mode 100644
index 0000000..0d67c00
--- /dev/null
+++ b/spdy/platform/api/spdy_mem_slice.h
@@ -0,0 +1,54 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef QUICHE_SPDY_PLATFORM_API_SPDY_MEM_SLICE_H_
+#define QUICHE_SPDY_PLATFORM_API_SPDY_MEM_SLICE_H_
+
+#include <utility>
+
+#include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h"
+#include "net/spdy/platform/impl/spdy_mem_slice_impl.h"
+
+namespace spdy {
+
+// SpdyMemSlice is an internally reference counted data buffer used as the
+// source buffers for write operations. SpdyMemSlice implicitly maintains a
+// reference count and will free the underlying data buffer when the reference
+// count reaches zero.
+class SPDY_EXPORT_PRIVATE SpdyMemSlice {
+ public:
+ // Constructs an empty SpdyMemSlice with no underlying data and 0 reference
+ // count.
+ SpdyMemSlice() = default;
+
+ // Constructs a SpdyMemSlice with reference count 1 to a newly allocated data
+ // buffer of |length| bytes.
+ explicit SpdyMemSlice(size_t length) : impl_(length) {}
+
+ // Constructs a SpdyMemSlice from |impl|. It takes the reference away from
+ // |impl|.
+ explicit SpdyMemSlice(SpdyMemSliceImpl impl) : impl_(std::move(impl)) {}
+
+ SpdyMemSlice(const SpdyMemSlice& other) = delete;
+ SpdyMemSlice& operator=(const SpdyMemSlice& other) = delete;
+
+ // Move constructors. |other| will not hold a reference to the data buffer
+ // after this call completes.
+ SpdyMemSlice(SpdyMemSlice&& other) = default;
+ SpdyMemSlice& operator=(SpdyMemSlice&& other) = default;
+
+ ~SpdyMemSlice() = default;
+
+ // Returns a char pointer to underlying data buffer.
+ const char* data() const { return impl_.data(); }
+ // Returns the length of underlying data buffer.
+ size_t length() const { return impl_.length(); }
+
+ private:
+ SpdyMemSliceImpl impl_;
+};
+
+} // namespace spdy
+
+#endif // QUICHE_SPDY_PLATFORM_API_SPDY_MEM_SLICE_H_