Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Unified Diff: net/quic/core/frames/quic_stream_frame.h

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/frames/quic_stop_waiting_frame.cc ('k') | net/quic/core/frames/quic_stream_frame.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « net/quic/core/frames/quic_stop_waiting_frame.cc ('k') | net/quic/core/frames/quic_stream_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698