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

Side by Side Diff: net/quic/core/frames/quic_stream_frame.h

Issue 2561893002: Add QUIC_EXPORT macros (Closed)
Patch Set: More 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
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_ 5 #ifndef NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_
6 #define NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_ 6 #define NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
11 #include "net/quic/core/quic_buffer_allocator.h" 11 #include "net/quic/core/quic_buffer_allocator.h"
12 #include "net/quic/core/quic_types.h" 12 #include "net/quic/core/quic_types.h"
13 #include "net/quic/platform/api/quic_export.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 // Deleter for stream buffers. Copyable to support platforms where the deleter 17 // 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 // of a unique_ptr must be copyable. Otherwise it would be nice for this to be
18 // move-only. 19 // move-only.
19 class NET_EXPORT_PRIVATE StreamBufferDeleter { 20 class QUIC_EXPORT_PRIVATE StreamBufferDeleter {
20 public: 21 public:
21 StreamBufferDeleter() : allocator_(nullptr) {} 22 StreamBufferDeleter() : allocator_(nullptr) {}
22 explicit StreamBufferDeleter(QuicBufferAllocator* allocator) 23 explicit StreamBufferDeleter(QuicBufferAllocator* allocator)
23 : allocator_(allocator) {} 24 : allocator_(allocator) {}
24 25
25 // Deletes |buffer| using |allocator_|. 26 // Deletes |buffer| using |allocator_|.
26 void operator()(char* buffer) const; 27 void operator()(char* buffer) const;
27 28
28 private: 29 private:
29 // Not owned; must be valid so long as the buffer stored in the unique_ptr 30 // Not owned; must be valid so long as the buffer stored in the unique_ptr
30 // that owns |this| is valid. 31 // that owns |this| is valid.
31 QuicBufferAllocator* allocator_; 32 QuicBufferAllocator* allocator_;
32 }; 33 };
33 34
34 using UniqueStreamBuffer = std::unique_ptr<char[], StreamBufferDeleter>; 35 using UniqueStreamBuffer = std::unique_ptr<char[], StreamBufferDeleter>;
35 36
36 // Allocates memory of size |size| using |allocator| for a QUIC stream buffer. 37 // Allocates memory of size |size| using |allocator| for a QUIC stream buffer.
37 NET_EXPORT_PRIVATE UniqueStreamBuffer 38 QUIC_EXPORT_PRIVATE UniqueStreamBuffer
38 NewStreamBuffer(QuicBufferAllocator* allocator, size_t size); 39 NewStreamBuffer(QuicBufferAllocator* allocator, size_t size);
39 40
40 struct NET_EXPORT_PRIVATE QuicStreamFrame { 41 struct QUIC_EXPORT_PRIVATE QuicStreamFrame {
41 QuicStreamFrame(); 42 QuicStreamFrame();
42 QuicStreamFrame(QuicStreamId stream_id, 43 QuicStreamFrame(QuicStreamId stream_id,
43 bool fin, 44 bool fin,
44 QuicStreamOffset offset, 45 QuicStreamOffset offset,
45 base::StringPiece data); 46 base::StringPiece data);
46 QuicStreamFrame(QuicStreamId stream_id, 47 QuicStreamFrame(QuicStreamId stream_id,
47 bool fin, 48 bool fin,
48 QuicStreamOffset offset, 49 QuicStreamOffset offset,
49 QuicPacketLength data_length, 50 QuicPacketLength data_length,
50 UniqueStreamBuffer buffer); 51 UniqueStreamBuffer buffer);
51 ~QuicStreamFrame(); 52 ~QuicStreamFrame();
52 53
53 friend NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, 54 friend QUIC_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
54 const QuicStreamFrame& s); 55 const QuicStreamFrame& s);
55 56
56 QuicStreamId stream_id; 57 QuicStreamId stream_id;
57 bool fin; 58 bool fin;
58 QuicPacketLength data_length; 59 QuicPacketLength data_length;
59 const char* data_buffer; 60 const char* data_buffer;
60 QuicStreamOffset offset; // Location of this data in the stream. 61 QuicStreamOffset offset; // Location of this data in the stream.
61 // nullptr when the QuicStreamFrame is received, and non-null when sent. 62 // nullptr when the QuicStreamFrame is received, and non-null when sent.
62 UniqueStreamBuffer buffer; 63 UniqueStreamBuffer buffer;
63 64
64 private: 65 private:
65 QuicStreamFrame(QuicStreamId stream_id, 66 QuicStreamFrame(QuicStreamId stream_id,
66 bool fin, 67 bool fin,
67 QuicStreamOffset offset, 68 QuicStreamOffset offset,
68 const char* data_buffer, 69 const char* data_buffer,
69 QuicPacketLength data_length, 70 QuicPacketLength data_length,
70 UniqueStreamBuffer buffer); 71 UniqueStreamBuffer buffer);
71 72
72 DISALLOW_COPY_AND_ASSIGN(QuicStreamFrame); 73 DISALLOW_COPY_AND_ASSIGN(QuicStreamFrame);
73 }; 74 };
74 static_assert(sizeof(QuicStreamFrame) <= 64, 75 static_assert(sizeof(QuicStreamFrame) <= 64,
75 "Keep the QuicStreamFrame size to a cacheline."); 76 "Keep the QuicStreamFrame size to a cacheline.");
76 77
77 } // namespace net 78 } // namespace net
78 79
79 #endif // NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_ 80 #endif // NET_QUIC_CORE_FRAMES_QUIC_STREAM_FRAME_H_
OLDNEW
« no previous file with comments | « net/quic/core/frames/quic_stop_waiting_frame.h ('k') | net/quic/core/frames/quic_window_update_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698