Index: net/quic/quic_packet_creator.h |
diff --git a/net/quic/quic_packet_creator.h b/net/quic/quic_packet_creator.h |
index 4b5e5b258752f86dfdcf3bb678bfc2333f3abfbe..32ca2bc63211e8e1ea0303f69461230dae9ea000 100644 |
--- a/net/quic/quic_packet_creator.h |
+++ b/net/quic/quic_packet_creator.h |
@@ -14,6 +14,7 @@ |
#include <stddef.h> |
#include <string> |
+#include <unordered_map> |
#include <utility> |
#include <vector> |
@@ -127,15 +128,7 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
// Returns true if current open packet can accommodate more stream frames of |
// stream |id| at |offset|, false otherwise. |
- bool HasRoomForStreamFrame(QuicStreamId id, QuicStreamOffset offset) const; |
- |
- // Serializes all frames into a single packet. All frames must fit into a |
- // single packet. Also, sets the entropy hash of the serialized packet to a |
- // random bool and returns that value as a member of SerializedPacket. |
- // Never returns a RetransmittableFrames in SerializedPacket. |
- SerializedPacket SerializeAllFrames(const QuicFrames& frames, |
- char* buffer, |
- size_t buffer_len); |
+ bool HasRoomForStreamFrame(QuicStreamId id, QuicStreamOffset offset); |
// Re-serializes frames with the original packet's packet number length. |
// Used for retransmitting packets to ensure they aren't too long. |
@@ -160,7 +153,7 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
// frames in the packet. Since stream frames are slightly smaller when they |
// are the last frame in a packet, this method will return a different |
// value than max_packet_size - PacketSize(), in this case. |
- size_t BytesFree() const; |
+ size_t BytesFree(); |
// Returns the number of bytes that the packet will expand by if a new frame |
// is added to the packet. If the last frame was a stream frame, it will |
@@ -173,7 +166,7 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
// if serialized with the current frames. Adding a frame to the packet |
// may change the serialized length of existing frames, as per the comment |
// in BytesFree. |
- size_t PacketSize() const; |
+ size_t PacketSize(); |
// Tries to add |frame| to the packet creator's list of frames to be |
// serialized. If the frame does not fit into the current packet, flushes the |
@@ -207,12 +200,12 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
// Sets the encryption level that will be applied to new packets. |
void set_encryption_level(EncryptionLevel level) { |
- encryption_level_ = level; |
+ packet_.encryption_level = level; |
} |
// packet number of the last created packet, or 0 if no packets have been |
// created. |
- QuicPacketNumber packet_number() const { return packet_number_; } |
+ QuicPacketNumber packet_number() const { return packet_.packet_number; } |
QuicConnectionIdLength connection_id_length() const { |
return connection_id_length_; |
@@ -224,9 +217,9 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
QuicByteCount max_packet_length() const { return max_packet_length_; } |
- bool has_ack() const { return has_ack_; } |
+ bool has_ack() const { return packet_.has_ack; } |
- bool has_stop_waiting() const { return has_stop_waiting_; } |
+ bool has_stop_waiting() const { return packet_.has_stop_waiting; } |
// Sets the encrypter to use for the encryption level and updates the max |
// plaintext size. |
@@ -324,18 +317,18 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
void MaybeAddPadding(); |
// Serializes all frames which have been added and adds any which should be |
- // retransmitted to queued_retransmittable_frames_ if it's not nullptr. All |
- // frames must fit into a single packet. Sets the entropy hash of the |
- // serialized packet to a random bool and returns that value as a member of |
- // SerializedPacket. Also, sets |serialized_frames| in the SerializedPacket to |
- // the corresponding RetransmittableFrames if any frames are to be |
- // retransmitted. |
+ // retransmitted to packet_.retransmittable_frames. All frames must fit into |
+ // a single packet. Sets the entropy hash of the serialized packet to a |
+ // random bool. |
// Fails if |buffer_len| isn't long enough for the encrypted packet. |
- SerializedPacket SerializePacket(char* encrypted_buffer, size_t buffer_len); |
+ void SerializePacket(char* encrypted_buffer, size_t buffer_len); |
// Called after a new SerialiedPacket is created to call the delegate's |
// OnSerializedPacket, reset state, and potentially flush FEC groups. |
- void OnSerializedPacket(SerializedPacket* packet); |
+ void OnSerializedPacket(); |
+ |
+ // Clears all fields of packet_ that should be cleared between serializations. |
+ void ClearPacket(); |
// Turn on FEC protection for subsequent packets. If no FEC group is currently |
// open, this method flushes current open packet and then turns FEC on. |
@@ -356,11 +349,10 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
// packet boundary. |
void ResetFecGroup(); |
- // Packetize FEC data. All frames must fit into a single packet. Also, sets |
- // the entropy hash of the serialized packet to a random bool and returns |
- // that value as a member of SerializedPacket. |
+ // Packetize FEC data. Sets the entropy hash of the serialized packet to a |
+ // random bool. |
// Fails if |buffer_len| isn't long enough for the encrypted packet. |
- SerializedPacket SerializeFec(char* buffer, size_t buffer_len); |
+ void SerializeFec(char* buffer, size_t buffer_len); |
// Does not own these delegates or the framer. |
DelegateInterface* delegate_; |
@@ -381,39 +373,24 @@ class NET_EXPORT_PRIVATE QuicPacketCreator { |
QuicPacketNumberLength next_packet_number_length_; |
// Maximum length including headers and encryption (UDP payload length.) |
QuicByteCount max_packet_length_; |
- mutable size_t max_plaintext_size_; |
+ size_t max_plaintext_size_; |
+ // Length of connection_id to send over the wire. |
+ QuicConnectionIdLength connection_id_length_; |
// Frames to be added to the next SerializedPacket |
QuicFrames queued_frames_; |
- // Fields used to populate SerializedPacket. |
- QuicConnectionId connection_id_; |
- EncryptionLevel encryption_level_; |
- // True if an ack is queued in queued_frames_. |
- bool has_ack_; |
- // True if a stop waiting frame is queued in queued_frames_. |
- bool has_stop_waiting_; |
- // The path which current constructed packet will be sent on. |
- QuicPathId current_path_; |
- QuicPacketNumber packet_number_; |
- // Length of connection_id to send over the wire. |
- QuicConnectionIdLength connection_id_length_; |
- // packet number length for the current packet and for the current FEC group |
- // when FEC is enabled. Mutable so PacketSize() can adjust it when the packet |
- // is empty. |
- mutable QuicPacketNumberLength packet_number_length_; |
- // packet_size_ is mutable because it's just a cache of the current size. |
// packet_size should never be read directly, use PacketSize() instead. |
- mutable size_t packet_size_; |
- scoped_ptr<QuicFrames> queued_retransmittable_frames_; |
- // If true, the packet will be padded up to |max_packet_length_|. |
- bool needs_padding_; |
- IsHandshake has_crypto_handshake_; |
- // Stores ack std::listeners that should be attached to the next packet. |
- std::list<AckListenerWrapper> ack_listeners_; |
+ // TODO(ianswett): Move packet_size_ into SerializedPacket once |
+ // QuicEncryptedPacket has been flattened into SerializedPacket. |
+ size_t packet_size_; |
+ QuicConnectionId connection_id_; |
+ |
+ // Packet used to invoke OnSerializedPacket. |
+ SerializedPacket packet_; |
// Map mapping path_id to last sent packet number on the path. |
- hash_map<QuicPathId, QuicPacketNumber> multipath_packet_number_; |
+ std::unordered_map<QuicPathId, QuicPacketNumber> multipath_packet_number_; |
// FEC related fields. |
// True when creator is requested to turn on FEC protection. False otherwise. |