blob: a4c58ffcb352e70cdd9eae7d11fa3ced2a793de4 [file] [log] [blame]
// 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.
#include "base/memory/ref_counted.h"
#include "net/base/io_buffer.h"
#include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h"
namespace spdy {
// SpdyMemSliceImpl wraps a reference counted MemSlice and only provides partial
// interfaces of MemSlice.
class SPDY_EXPORT_PRIVATE SpdyMemSliceImpl {
// Constructs an empty SpdyMemSliceImpl that contains an empty MemSlice.
// Constructs a SpdyMemSliceImpl by adding a reference to the data held in
// |io_buffer|, which should be passed by value.
explicit SpdyMemSliceImpl(scoped_refptr<net::IOBufferWithSize> io_buffer);
// Constructs a SpdyMemSliceImpl with reference count 1 to a newly allocated
// data buffer of |length| bytes.
explicit SpdyMemSliceImpl(size_t length);
SpdyMemSliceImpl(const SpdyMemSliceImpl& other) = delete;
SpdyMemSliceImpl& operator=(const SpdyMemSliceImpl& other) = delete;
// Move constructors. |other| will not hold a reference to the data buffer
// after this call completes.
SpdyMemSliceImpl(SpdyMemSliceImpl&& other);
SpdyMemSliceImpl& operator=(SpdyMemSliceImpl&& other);
// Returns a char pointer to underlying data buffer.
const char* data() const;
// Returns the length of underlying data buffer.
size_t length() const;
scoped_refptr<net::IOBufferWithSize> io_buffer_;
} // namespace spdy