| OLD | NEW |
| 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. If multipath enabled, only creates | 6 // it's time to create a packet from them. If multipath enabled, only creates |
| 7 // packets on one path at the same time. Currently, next packet number is | 7 // packets on one path at the same time. Currently, next packet number is |
| 8 // tracked per-path. | 8 // tracked per-path. |
| 9 | 9 |
| 10 #ifndef NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_ | 10 #ifndef NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_ |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 size_t buffer_len); | 112 size_t buffer_len); |
| 113 | 113 |
| 114 // Serializes all added frames into a single packet and invokes the delegate_ | 114 // Serializes all added frames into a single packet and invokes the delegate_ |
| 115 // to further process the SerializedPacket. | 115 // to further process the SerializedPacket. |
| 116 void Flush(); | 116 void Flush(); |
| 117 | 117 |
| 118 // Optimized method to create a QuicStreamFrame and serialize it. Adds the | 118 // Optimized method to create a QuicStreamFrame and serialize it. Adds the |
| 119 // QuicStreamFrame to the returned SerializedPacket. Sets | 119 // QuicStreamFrame to the returned SerializedPacket. Sets |
| 120 // |num_bytes_consumed| to the number of bytes consumed to create the | 120 // |num_bytes_consumed| to the number of bytes consumed to create the |
| 121 // QuicStreamFrame. | 121 // QuicStreamFrame. |
| 122 void CreateAndSerializeStreamFrame(QuicStreamId id, | 122 void CreateAndSerializeStreamFrame( |
| 123 const QuicIOVector& iov, | 123 QuicStreamId id, |
| 124 QuicStreamOffset iov_offset, | 124 const QuicIOVector& iov, |
| 125 QuicStreamOffset stream_offset, | 125 QuicStreamOffset iov_offset, |
| 126 bool fin, | 126 QuicStreamOffset stream_offset, |
| 127 QuicAckListenerInterface* listener, | 127 bool fin, |
| 128 size_t* num_bytes_consumed); | 128 const scoped_refptr<QuicAckListenerInterface>& listener, |
| 129 size_t* num_bytes_consumed); |
| 129 | 130 |
| 130 // Returns true if there are frames pending to be serialized. | 131 // Returns true if there are frames pending to be serialized. |
| 131 bool HasPendingFrames() const; | 132 bool HasPendingFrames() const; |
| 132 | 133 |
| 133 // Returns true if there are retransmittable frames pending to be serialized. | 134 // Returns true if there are retransmittable frames pending to be serialized. |
| 134 bool HasPendingRetransmittableFrames() const; | 135 bool HasPendingRetransmittableFrames() const; |
| 135 | 136 |
| 136 // Returns the number of bytes which are available to be used by additional | 137 // Returns the number of bytes which are available to be used by additional |
| 137 // frames in the packet. Since stream frames are slightly smaller when they | 138 // frames in the packet. Since stream frames are slightly smaller when they |
| 138 // are the last frame in a packet, this method will return a different | 139 // are the last frame in a packet, this method will return a different |
| (...skipping 15 matching lines...) Expand all Loading... |
| 154 // Tries to add |frame| to the packet creator's list of frames to be | 155 // Tries to add |frame| to the packet creator's list of frames to be |
| 155 // serialized. If the frame does not fit into the current packet, flushes the | 156 // serialized. If the frame does not fit into the current packet, flushes the |
| 156 // packet and returns false. | 157 // packet and returns false. |
| 157 bool AddSavedFrame(const QuicFrame& frame); | 158 bool AddSavedFrame(const QuicFrame& frame); |
| 158 | 159 |
| 159 // Identical to AddSavedFrame, but allows the frame to be padded. | 160 // Identical to AddSavedFrame, but allows the frame to be padded. |
| 160 bool AddPaddedSavedFrame(const QuicFrame& frame); | 161 bool AddPaddedSavedFrame(const QuicFrame& frame); |
| 161 | 162 |
| 162 // Adds |listener| to the next serialized packet and notifies the | 163 // Adds |listener| to the next serialized packet and notifies the |
| 163 // std::listener with |length| as the number of acked bytes. | 164 // std::listener with |length| as the number of acked bytes. |
| 164 void AddAckListener(QuicAckListenerInterface* listener, | 165 void AddAckListener(const scoped_refptr<QuicAckListenerInterface>& listener, |
| 165 QuicPacketLength length); | 166 QuicPacketLength length); |
| 166 | 167 |
| 167 // Creates a version negotiation packet which supports |supported_versions|. | 168 // Creates a version negotiation packet which supports |supported_versions|. |
| 168 std::unique_ptr<QuicEncryptedPacket> SerializeVersionNegotiationPacket( | 169 std::unique_ptr<QuicEncryptedPacket> SerializeVersionNegotiationPacket( |
| 169 const QuicVersionVector& supported_versions); | 170 const QuicVersionVector& supported_versions); |
| 170 | 171 |
| 171 // Returns a dummy packet that is valid but contains no useful information. | 172 // Returns a dummy packet that is valid but contains no useful information. |
| 172 static SerializedPacket NoPacket(); | 173 static SerializedPacket NoPacket(); |
| 173 | 174 |
| 174 // Sets the encryption level that will be applied to new packets. | 175 // Sets the encryption level that will be applied to new packets. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 312 |
| 312 // Map mapping path_id to last sent packet number on the path. | 313 // Map mapping path_id to last sent packet number on the path. |
| 313 std::unordered_map<QuicPathId, QuicPacketNumber> multipath_packet_number_; | 314 std::unordered_map<QuicPathId, QuicPacketNumber> multipath_packet_number_; |
| 314 | 315 |
| 315 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); | 316 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); |
| 316 }; | 317 }; |
| 317 | 318 |
| 318 } // namespace net | 319 } // namespace net |
| 319 | 320 |
| 320 #endif // NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_ | 321 #endif // NET_QUIC_CORE_QUIC_PACKET_CREATOR_H_ |
| OLD | NEW |