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

Side by Side Diff: net/quic/quic_packet_creator.h

Issue 1397113003: relnote: Refactor stream buffer allocation out into a scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with TOT Created 5 years, 2 months 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
« no previous file with comments | « no previous file | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Accumulates frames for the next packet until more frames no longer fit or 5 // Accumulates frames for the next packet until more frames no longer fit or
6 // it's time to create a packet from them. Also provides packet creation of 6 // it's time to create a packet from them. Also provides packet creation of
7 // FEC packets based on previously created packets. 7 // FEC packets based on previously created packets.
8 8
9 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_ 9 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_
10 #define NET_QUIC_QUIC_PACKET_CREATOR_H_ 10 #define NET_QUIC_QUIC_PACKET_CREATOR_H_
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Returns the number of bytes consumed from data. 82 // Returns the number of bytes consumed from data.
83 // If data is empty and fin is true, the expected behavior is to consume the 83 // If data is empty and fin is true, the expected behavior is to consume the
84 // fin but return 0. If any data is consumed, it will be copied into a 84 // fin but return 0. If any data is consumed, it will be copied into a
85 // new buffer that |frame| will point to and will be stored in |buffer|. 85 // new buffer that |frame| will point to and will be stored in |buffer|.
86 size_t CreateStreamFrame(QuicStreamId id, 86 size_t CreateStreamFrame(QuicStreamId id,
87 const QuicIOVector& iov, 87 const QuicIOVector& iov,
88 size_t iov_offset, 88 size_t iov_offset,
89 QuicStreamOffset offset, 89 QuicStreamOffset offset,
90 bool fin, 90 bool fin,
91 QuicFrame* frame, 91 QuicFrame* frame,
92 scoped_ptr<char[]>* buffer); 92 UniqueStreamBuffer* buffer);
93 93
94 // Serializes all frames into a single packet. All frames must fit into a 94 // Serializes all frames into a single packet. All frames must fit into a
95 // single packet. Also, sets the entropy hash of the serialized packet to a 95 // single packet. Also, sets the entropy hash of the serialized packet to a
96 // random bool and returns that value as a member of SerializedPacket. 96 // random bool and returns that value as a member of SerializedPacket.
97 // Never returns a RetransmittableFrames in SerializedPacket. 97 // Never returns a RetransmittableFrames in SerializedPacket.
98 SerializedPacket SerializeAllFrames(const QuicFrames& frames, 98 SerializedPacket SerializeAllFrames(const QuicFrames& frames,
99 char* buffer, 99 char* buffer,
100 size_t buffer_len); 100 size_t buffer_len);
101 101
102 // Re-serializes frames with the original packet's packet number length. 102 // Re-serializes frames with the original packet's packet number length.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // in BytesFree. 144 // in BytesFree.
145 size_t PacketSize() const; 145 size_t PacketSize() const;
146 146
147 // TODO(jri): AddSavedFrame calls AddFrame, which only saves the frame 147 // TODO(jri): AddSavedFrame calls AddFrame, which only saves the frame
148 // if it is a stream frame, not other types of frames. Fix this API; 148 // if it is a stream frame, not other types of frames. Fix this API;
149 // add a AddNonSavedFrame method. 149 // add a AddNonSavedFrame method.
150 // Adds |frame| to the packet creator's list of frames to be serialized. 150 // Adds |frame| to the packet creator's list of frames to be serialized.
151 // Returns false if the frame doesn't fit into the current packet. 151 // Returns false if the frame doesn't fit into the current packet.
152 bool AddSavedFrame(const QuicFrame& frame); 152 bool AddSavedFrame(const QuicFrame& frame);
153 153
154 // Identical to AddSavedFrame, but takes ownership of the buffer if it returns 154 // Identical to AddSavedFrame, but takes ownership of the buffer.
155 // true. 155 bool AddSavedFrame(const QuicFrame& frame, UniqueStreamBuffer buffer);
156 bool AddSavedFrame(const QuicFrame& frame, char* buffer);
157 156
158 // Identical to AddSavedFrame, but takes ownership of the buffer if it returns 157 // Identical to AddSavedFrame, but takes ownership of the buffer, and allows
159 // true, and allows to cause the packet to be padded. 158 // to cause the packet to be padded.
160 bool AddPaddedSavedFrame(const QuicFrame& frame, char* buffer); 159 bool AddPaddedSavedFrame(const QuicFrame& frame, UniqueStreamBuffer buffer);
161 160
162 // Serializes all frames which have been added and adds any which should be 161 // Serializes all frames which have been added and adds any which should be
163 // retransmitted to |retransmittable_frames| if it's not nullptr. All frames 162 // retransmitted to |retransmittable_frames| if it's not nullptr. All frames
164 // must fit into a single packet. Sets the entropy hash of the serialized 163 // must fit into a single packet. Sets the entropy hash of the serialized
165 // packet to a random bool and returns that value as a member of 164 // packet to a random bool and returns that value as a member of
166 // SerializedPacket. Also, sets |serialized_frames| in the SerializedPacket to 165 // SerializedPacket. Also, sets |serialized_frames| in the SerializedPacket to
167 // the corresponding RetransmittableFrames if any frames are to be 166 // the corresponding RetransmittableFrames if any frames are to be
168 // retransmitted. 167 // retransmitted.
169 // Fails if |buffer_len| isn't long enough for the encrypted packet. 168 // Fails if |buffer_len| isn't long enough for the encrypted packet.
170 SerializedPacket SerializePacket(char* encrypted_buffer, size_t buffer_len); 169 SerializedPacket SerializePacket(char* encrypted_buffer, size_t buffer_len);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 256
258 void FillPacketHeader(QuicFecGroupNumber fec_group, 257 void FillPacketHeader(QuicFecGroupNumber fec_group,
259 bool fec_flag, 258 bool fec_flag,
260 QuicPacketHeader* header); 259 QuicPacketHeader* header);
261 260
262 // Allows a frame to be added without creating retransmittable frames. 261 // Allows a frame to be added without creating retransmittable frames.
263 // Particularly useful for retransmits using SerializeAllFrames(). 262 // Particularly useful for retransmits using SerializeAllFrames().
264 bool AddFrame(const QuicFrame& frame, 263 bool AddFrame(const QuicFrame& frame,
265 bool save_retransmittable_frames, 264 bool save_retransmittable_frames,
266 bool needs_padding, 265 bool needs_padding,
267 char* buffer); 266 UniqueStreamBuffer buffer);
268 267
269 // Adds a padding frame to the current packet only if the current packet 268 // Adds a padding frame to the current packet only if the current packet
270 // contains a handshake message, and there is sufficient room to fit a 269 // contains a handshake message, and there is sufficient room to fit a
271 // padding frame. 270 // padding frame.
272 void MaybeAddPadding(); 271 void MaybeAddPadding();
273 272
274 QuicConnectionId connection_id_; 273 QuicConnectionId connection_id_;
275 EncryptionLevel encryption_level_; 274 EncryptionLevel encryption_level_;
276 QuicFramer* framer_; 275 QuicFramer* framer_;
277 scoped_ptr<QuicRandomBoolSource> random_bool_source_; 276 scoped_ptr<QuicRandomBoolSource> random_bool_source_;
(...skipping 28 matching lines...) Expand all
306 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; 305 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_;
307 // If true, the packet will be padded up to |max_packet_length_|. 306 // If true, the packet will be padded up to |max_packet_length_|.
308 bool needs_padding_; 307 bool needs_padding_;
309 308
310 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); 309 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator);
311 }; 310 };
312 311
313 } // namespace net 312 } // namespace net
314 313
315 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ 314 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698