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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 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 NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_
6 #define NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_
7
8 #include <memory>
9
10 #include "base/strings/string_piece.h"
11 #include "net/quic/core/quic_buffer_allocator.h"
12 #include "net/quic/core/quic_types.h"
13
14 namespace net {
15
16 // Deleter for stream buffers. Copyable to support platforms where the deleter
17 // of a unique_ptr must be copyable. Otherwise it would be nice for this to be
18 // move-only.
19 class NET_EXPORT_PRIVATE StreamBufferDeleter {
20 public:
21 StreamBufferDeleter() : allocator_(nullptr) {}
22 explicit StreamBufferDeleter(QuicBufferAllocator* allocator)
23 : allocator_(allocator) {}
24
25 // Deletes |buffer| using |allocator_|.
26 void operator()(char* buffer) const;
27
28 private:
29 // Not owned; must be valid so long as the buffer stored in the unique_ptr
30 // that owns |this| is valid.
31 QuicBufferAllocator* allocator_;
32 };
33
34 using UniqueStreamBuffer = std::unique_ptr<char[], StreamBufferDeleter>;
35
36 // Allocates memory of size |size| using |allocator| for a QUIC stream buffer.
37 NET_EXPORT_PRIVATE UniqueStreamBuffer
38 NewStreamBuffer(QuicBufferAllocator* allocator, size_t size);
39
40 struct NET_EXPORT_PRIVATE QuicStreamFrame {
41 QuicStreamFrame();
42 QuicStreamFrame(QuicStreamId stream_id,
43 bool fin,
44 QuicStreamOffset offset,
45 base::StringPiece data);
46 QuicStreamFrame(QuicStreamId stream_id,
47 bool fin,
48 QuicStreamOffset offset,
49 QuicPacketLength data_length,
50 UniqueStreamBuffer buffer);
51 ~QuicStreamFrame();
52
53 friend NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
54 const QuicStreamFrame& s);
55
56 QuicStreamId stream_id;
57 bool fin;
58 QuicPacketLength data_length;
59 const char* data_buffer;
60 QuicStreamOffset offset; // Location of this data in the stream.
61 // nullptr when the QuicStreamFrame is received, and non-null when sent.
62 UniqueStreamBuffer buffer;
63
64 private:
65 QuicStreamFrame(QuicStreamId stream_id,
66 bool fin,
67 QuicStreamOffset offset,
68 const char* data_buffer,
69 QuicPacketLength data_length,
70 UniqueStreamBuffer buffer);
71
72 DISALLOW_COPY_AND_ASSIGN(QuicStreamFrame);
73 };
74 static_assert(sizeof(QuicStreamFrame) <= 64,
75 "Keep the QuicStreamFrame size to a cacheline.");
76
77 } // namespace net
78
79 #endif // NET_QUIC_CORE_QUIC_FRAMES_H_
OLDNEW
« 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