| Index: net/quic/core/frames/quic_stream_frame.h
|
| diff --git a/net/quic/core/frames/quic_stream_frame.h b/net/quic/core/frames/quic_stream_frame.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9efbd97cd24d65f6b77488d054217cb06acaa9fe
|
| --- /dev/null
|
| +++ b/net/quic/core/frames/quic_stream_frame.h
|
| @@ -0,0 +1,79 @@
|
| +// Copyright (c) 2016 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 NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_
|
| +#define NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/strings/string_piece.h"
|
| +#include "net/quic/core/quic_buffer_allocator.h"
|
| +#include "net/quic/core/quic_types.h"
|
| +
|
| +namespace net {
|
| +
|
| +// Deleter for stream buffers. Copyable to support platforms where the deleter
|
| +// of a unique_ptr must be copyable. Otherwise it would be nice for this to be
|
| +// move-only.
|
| +class NET_EXPORT_PRIVATE StreamBufferDeleter {
|
| + public:
|
| + StreamBufferDeleter() : allocator_(nullptr) {}
|
| + explicit StreamBufferDeleter(QuicBufferAllocator* allocator)
|
| + : allocator_(allocator) {}
|
| +
|
| + // Deletes |buffer| using |allocator_|.
|
| + void operator()(char* buffer) const;
|
| +
|
| + private:
|
| + // Not owned; must be valid so long as the buffer stored in the unique_ptr
|
| + // that owns |this| is valid.
|
| + QuicBufferAllocator* allocator_;
|
| +};
|
| +
|
| +using UniqueStreamBuffer = std::unique_ptr<char[], StreamBufferDeleter>;
|
| +
|
| +// Allocates memory of size |size| using |allocator| for a QUIC stream buffer.
|
| +NET_EXPORT_PRIVATE UniqueStreamBuffer
|
| +NewStreamBuffer(QuicBufferAllocator* allocator, size_t size);
|
| +
|
| +struct NET_EXPORT_PRIVATE QuicStreamFrame {
|
| + QuicStreamFrame();
|
| + QuicStreamFrame(QuicStreamId stream_id,
|
| + bool fin,
|
| + QuicStreamOffset offset,
|
| + base::StringPiece data);
|
| + QuicStreamFrame(QuicStreamId stream_id,
|
| + bool fin,
|
| + QuicStreamOffset offset,
|
| + QuicPacketLength data_length,
|
| + UniqueStreamBuffer buffer);
|
| + ~QuicStreamFrame();
|
| +
|
| + friend NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
|
| + const QuicStreamFrame& s);
|
| +
|
| + QuicStreamId stream_id;
|
| + bool fin;
|
| + QuicPacketLength data_length;
|
| + const char* data_buffer;
|
| + QuicStreamOffset offset; // Location of this data in the stream.
|
| + // nullptr when the QuicStreamFrame is received, and non-null when sent.
|
| + UniqueStreamBuffer buffer;
|
| +
|
| + private:
|
| + QuicStreamFrame(QuicStreamId stream_id,
|
| + bool fin,
|
| + QuicStreamOffset offset,
|
| + const char* data_buffer,
|
| + QuicPacketLength data_length,
|
| + UniqueStreamBuffer buffer);
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(QuicStreamFrame);
|
| +};
|
| +static_assert(sizeof(QuicStreamFrame) <= 64,
|
| + "Keep the QuicStreamFrame size to a cacheline.");
|
| +
|
| +} // namespace net
|
| +
|
| +#endif // NET_QUIC_CORE_QUIC_FRAMES_H_
|
|
|