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

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

Issue 15937012: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small bug fixes Created 7 years, 6 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 | Annotate | Revision Log
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 14 matching lines...) Expand all
25 25
26 class QuicRandom; 26 class QuicRandom;
27 27
28 class NET_EXPORT_PRIVATE QuicPacketCreator : public QuicFecBuilderInterface { 28 class NET_EXPORT_PRIVATE QuicPacketCreator : public QuicFecBuilderInterface {
29 public: 29 public:
30 // Options for controlling how packets are created. 30 // Options for controlling how packets are created.
31 struct Options { 31 struct Options {
32 Options() 32 Options()
33 : max_packet_length(kMaxPacketSize), 33 : max_packet_length(kMaxPacketSize),
34 random_reorder(false), 34 random_reorder(false),
35 max_packets_per_fec_group(0) { 35 max_packets_per_fec_group(0),
36 send_guid_length(PACKET_8BYTE_GUID) {
36 } 37 }
37 38
38 size_t max_packet_length; 39 size_t max_packet_length;
39 bool random_reorder; // Inefficient: rewrite if used at scale. 40 bool random_reorder; // Inefficient: rewrite if used at scale.
40 // 0 indicates fec is disabled. 41 // 0 indicates fec is disabled.
41 size_t max_packets_per_fec_group; 42 size_t max_packets_per_fec_group;
43 // Length of guid to send over the wire.
44 QuicGuidLength send_guid_length;
42 }; 45 };
43 46
44 // QuicRandom* required for packet entropy. 47 // QuicRandom* required for packet entropy.
45 QuicPacketCreator(QuicGuid guid, 48 QuicPacketCreator(QuicGuid guid,
46 QuicFramer* framer, 49 QuicFramer* framer,
47 QuicRandom* random_generator, 50 QuicRandom* random_generator,
48 bool is_server); 51 bool is_server);
49 52
50 virtual ~QuicPacketCreator(); 53 virtual ~QuicPacketCreator();
51 54
52 // QuicFecBuilderInterface 55 // QuicFecBuilderInterface
53 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header, 56 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header,
54 base::StringPiece payload) OVERRIDE; 57 base::StringPiece payload) OVERRIDE;
55 58
56 // Checks if it's time to send an FEC packet. |force_close| forces this to 59 // Checks if it's time to send an FEC packet. |force_close| forces this to
57 // return true if an fec group is open. 60 // return true if an fec group is open.
58 bool ShouldSendFec(bool force_close) const; 61 bool ShouldSendFec(bool force_close) const;
59 62
60 // Starts a new FEC group with the next serialized packet, if FEC is enabled 63 // Starts a new FEC group with the next serialized packet, if FEC is enabled
61 // and there is not already an FEC group open. 64 // and there is not already an FEC group open.
62 void MaybeStartFEC(); 65 void MaybeStartFEC();
63 66
64 // Makes the framer not serialize the protocol version in sent packets. 67 // Makes the framer not serialize the protocol version in sent packets.
65 void StopSendingVersion(); 68 void StopSendingVersion();
66 69
67 // The overhead the framing will add for a packet with num_frames frames. 70 // The overhead the framing will add for a packet with num_frames frames.
68 static size_t StreamFramePacketOverhead(int num_frames, bool include_version); 71 static size_t StreamFramePacketOverhead(int num_frames,
72 QuicGuidLength guid_length,
73 bool include_version,
74 InFecGroup is_in_fec_group);
69 75
70 bool HasRoomForStreamFrame() const; 76 bool HasRoomForStreamFrame() const;
71 77
72 // Converts a raw payload to a frame which fits into the currently open 78 // Converts a raw payload to a frame which fits into the currently open
73 // packet if there is one. Returns the number of bytes consumed from data. 79 // packet if there is one. Returns the number of bytes consumed from data.
74 // If data is empty and fin is true, the expected behavior is to consume the 80 // If data is empty and fin is true, the expected behavior is to consume the
75 // fin but return 0. 81 // fin but return 0.
76 size_t CreateStreamFrame(QuicStreamId id, 82 size_t CreateStreamFrame(QuicStreamId id,
77 base::StringPiece data, 83 base::StringPiece data,
78 QuicStreamOffset offset, 84 QuicStreamOffset offset,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 size_t packet_size_; 169 size_t packet_size_;
164 QuicFrames queued_frames_; 170 QuicFrames queued_frames_;
165 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; 171 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_;
166 172
167 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); 173 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator);
168 }; 174 };
169 175
170 } // namespace net 176 } // namespace net
171 177
172 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ 178 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698