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

Side by Side Diff: net/quic/core/quic_packets.h

Issue 2531163009: Move QuicAckListenerInterface, QuicPendingRetransmission, and QuicTransmissionInfo out of quic_pack… (Closed)
Patch Set: Move QuicAckListenerInterface, QuicPendingRetransmission, and QuicTransmissionInfo out of quic_pack… 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
« no previous file with comments | « net/quic/core/quic_packet_generator.cc ('k') | net/quic/core/quic_packets.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 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_
6 #define NET_QUIC_QUIC_PROTOCOL_H_ 6 #define NET_QUIC_QUIC_PROTOCOL_H_
7 7
8 #include <limits> 8 #include <limits>
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
11 #include <ostream> 11 #include <ostream>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/strings/string_piece.h" 19 #include "base/strings/string_piece.h"
20 #include "net/base/int128.h" 20 #include "net/base/int128.h"
21 #include "net/base/iovec.h" 21 #include "net/base/iovec.h"
22 #include "net/base/net_export.h" 22 #include "net/base/net_export.h"
23 #include "net/quic/core/quic_ack_listener_interface.h"
23 #include "net/quic/core/quic_bandwidth.h" 24 #include "net/quic/core/quic_bandwidth.h"
24 #include "net/quic/core/quic_constants.h" 25 #include "net/quic/core/quic_constants.h"
25 #include "net/quic/core/quic_error_codes.h" 26 #include "net/quic/core/quic_error_codes.h"
26 #include "net/quic/core/quic_frames.h" 27 #include "net/quic/core/quic_frames.h"
27 #include "net/quic/core/quic_time.h" 28 #include "net/quic/core/quic_time.h"
28 #include "net/quic/core/quic_types.h" 29 #include "net/quic/core/quic_types.h"
29 #include "net/quic/core/quic_versions.h" 30 #include "net/quic/core/quic_versions.h"
30 #include "net/quic/platform/api/quic_socket_address.h" 31 #include "net/quic/platform/api/quic_socket_address.h"
31 32
32 namespace net { 33 namespace net {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 std::ostream& os, 212 std::ostream& os,
212 const QuicReceivedPacket& s); 213 const QuicReceivedPacket& s);
213 214
214 private: 215 private:
215 const QuicTime receipt_time_; 216 const QuicTime receipt_time_;
216 int ttl_; 217 int ttl_;
217 218
218 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket); 219 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket);
219 }; 220 };
220 221
221 // Pure virtual class to listen for packet acknowledgements.
222 class NET_EXPORT_PRIVATE QuicAckListenerInterface
223 : public base::RefCounted<QuicAckListenerInterface> {
224 public:
225 QuicAckListenerInterface() {}
226
227 // Called when a packet is acked. Called once per packet.
228 // |acked_bytes| is the number of data bytes acked.
229 virtual void OnPacketAcked(int acked_bytes,
230 QuicTime::Delta ack_delay_time) = 0;
231
232 // Called when a packet is retransmitted. Called once per packet.
233 // |retransmitted_bytes| is the number of data bytes retransmitted.
234 virtual void OnPacketRetransmitted(int retransmitted_bytes) = 0;
235
236 protected:
237 friend class base::RefCounted<QuicAckListenerInterface>;
238
239 // Delegates are ref counted.
240 virtual ~QuicAckListenerInterface() {}
241 };
242
243 struct NET_EXPORT_PRIVATE AckListenerWrapper {
244 AckListenerWrapper(QuicAckListenerInterface* listener,
245 QuicPacketLength data_length);
246 AckListenerWrapper(const AckListenerWrapper& other);
247 ~AckListenerWrapper();
248
249 scoped_refptr<QuicAckListenerInterface> ack_listener;
250 QuicPacketLength length;
251 };
252
253 struct NET_EXPORT_PRIVATE SerializedPacket { 222 struct NET_EXPORT_PRIVATE SerializedPacket {
254 SerializedPacket(QuicPathId path_id, 223 SerializedPacket(QuicPathId path_id,
255 QuicPacketNumber packet_number, 224 QuicPacketNumber packet_number,
256 QuicPacketNumberLength packet_number_length, 225 QuicPacketNumberLength packet_number_length,
257 const char* encrypted_buffer, 226 const char* encrypted_buffer,
258 QuicPacketLength encrypted_length, 227 QuicPacketLength encrypted_length,
259 bool has_ack, 228 bool has_ack,
260 bool has_stop_waiting); 229 bool has_stop_waiting);
261 SerializedPacket(const SerializedPacket& other); 230 SerializedPacket(const SerializedPacket& other);
262 ~SerializedPacket(); 231 ~SerializedPacket();
(...skipping 22 matching lines...) Expand all
285 }; 254 };
286 255
287 // Deletes and clears all the frames and the packet from serialized packet. 256 // Deletes and clears all the frames and the packet from serialized packet.
288 NET_EXPORT_PRIVATE void ClearSerializedPacket( 257 NET_EXPORT_PRIVATE void ClearSerializedPacket(
289 SerializedPacket* serialized_packet); 258 SerializedPacket* serialized_packet);
290 259
291 // Allocates a new char[] of size |packet.encrypted_length| and copies in 260 // Allocates a new char[] of size |packet.encrypted_length| and copies in
292 // |packet.encrypted_buffer|. 261 // |packet.encrypted_buffer|.
293 NET_EXPORT_PRIVATE char* CopyBuffer(const SerializedPacket& packet); 262 NET_EXPORT_PRIVATE char* CopyBuffer(const SerializedPacket& packet);
294 263
295 struct NET_EXPORT_PRIVATE TransmissionInfo {
296 // Used by STL when assigning into a map.
297 TransmissionInfo();
298
299 // Constructs a Transmission with a new all_transmissions set
300 // containing |packet_number|.
301 TransmissionInfo(EncryptionLevel level,
302 QuicPacketNumberLength packet_number_length,
303 TransmissionType transmission_type,
304 QuicTime sent_time,
305 QuicPacketLength bytes_sent,
306 bool has_crypto_handshake,
307 int num_padding_bytes);
308
309 TransmissionInfo(const TransmissionInfo& other);
310
311 ~TransmissionInfo();
312
313 QuicFrames retransmittable_frames;
314 EncryptionLevel encryption_level;
315 QuicPacketNumberLength packet_number_length;
316 QuicPacketLength bytes_sent;
317 QuicTime sent_time;
318 // Reason why this packet was transmitted.
319 TransmissionType transmission_type;
320 // In flight packets have not been abandoned or lost.
321 bool in_flight;
322 // True if the packet can never be acked, so it can be removed. Occurs when
323 // a packet is never sent, after it is acknowledged once, or if it's a crypto
324 // packet we never expect to receive an ack for.
325 bool is_unackable;
326 // True if the packet contains stream data from the crypto stream.
327 bool has_crypto_handshake;
328 // Non-zero if the packet needs padding if it's retransmitted.
329 int16_t num_padding_bytes;
330 // Stores the packet number of the next retransmission of this packet.
331 // Zero if the packet has not been retransmitted.
332 QuicPacketNumber retransmission;
333 // Non-empty if there is a std::listener for this packet.
334 std::list<AckListenerWrapper> ack_listeners;
335 };
336
337 // Struct to store the pending retransmission information.
338 struct PendingRetransmission {
339 PendingRetransmission(QuicPathId path_id,
340 QuicPacketNumber packet_number,
341 TransmissionType transmission_type,
342 const QuicFrames& retransmittable_frames,
343 bool has_crypto_handshake,
344 int num_padding_bytes,
345 EncryptionLevel encryption_level,
346 QuicPacketNumberLength packet_number_length)
347 : packet_number(packet_number),
348 retransmittable_frames(retransmittable_frames),
349 transmission_type(transmission_type),
350 path_id(path_id),
351 has_crypto_handshake(has_crypto_handshake),
352 num_padding_bytes(num_padding_bytes),
353 encryption_level(encryption_level),
354 packet_number_length(packet_number_length) {}
355
356 QuicPacketNumber packet_number;
357 const QuicFrames& retransmittable_frames;
358 TransmissionType transmission_type;
359 QuicPathId path_id;
360 bool has_crypto_handshake;
361 int num_padding_bytes;
362 EncryptionLevel encryption_level;
363 QuicPacketNumberLength packet_number_length;
364 };
365
366 } // namespace net 264 } // namespace net
367 265
368 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 266 #endif // NET_QUIC_QUIC_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_packet_generator.cc ('k') | net/quic/core/quic_packets.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698