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

Side by Side Diff: net/quic/quic_ack_notifier_manager.cc

Issue 819653006: Attach QuicAckNotifiers to the serialized packet, instead of individual (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removing_deprecated_flag_83439062
Patch Set: Created 5 years, 11 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 | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_flags.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "net/quic/quic_ack_notifier_manager.h" 5 #include "net/quic/quic_ack_notifier_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "net/quic/quic_ack_notifier.h" 14 #include "net/quic/quic_ack_notifier.h"
15 #include "net/quic/quic_flags.h"
15 #include "net/quic/quic_protocol.h" 16 #include "net/quic/quic_protocol.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 AckNotifierManager::AckNotifierManager() {} 20 AckNotifierManager::AckNotifierManager() {}
20 21
21 AckNotifierManager::~AckNotifierManager() { 22 AckNotifierManager::~AckNotifierManager() {
22 STLDeleteElements(&ack_notifiers_); 23 STLDeleteElements(&ack_notifiers_);
23 } 24 }
24 25
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 67 }
67 68
68 // The old sequence number is no longer of interest, copy the updated 69 // The old sequence number is no longer of interest, copy the updated
69 // AckNotifiers to the new sequence number before deleting the old. 70 // AckNotifiers to the new sequence number before deleting the old.
70 ack_notifier_map_[new_sequence_number] = ack_notifier_set; 71 ack_notifier_map_[new_sequence_number] = ack_notifier_set;
71 ack_notifier_map_.erase(map_it); 72 ack_notifier_map_.erase(map_it);
72 } 73 }
73 74
74 void AckNotifierManager::OnSerializedPacket( 75 void AckNotifierManager::OnSerializedPacket(
75 const SerializedPacket& serialized_packet) { 76 const SerializedPacket& serialized_packet) {
76 // AckNotifiers can only be attached to retransmittable frames. 77 if (FLAGS_quic_attach_ack_notifiers_to_packets) {
77 RetransmittableFrames* frames = serialized_packet.retransmittable_frames; 78 // Inform each attached AckNotifier of the packet's sequence number.
78 if (frames == nullptr) { 79 for (QuicAckNotifier* notifier : serialized_packet.notifiers) {
79 return; 80 if (notifier == nullptr) {
80 } 81 LOG(DFATAL) << "AckNotifier should not be nullptr.";
82 continue;
83 }
84 notifier->AddSequenceNumber(serialized_packet.sequence_number,
85 serialized_packet.packet->length());
81 86
82 // For each frame in |serialized_packet|, inform any attached AckNotifiers of 87 // Update the mapping in the other direction, from sequence number to
83 // the packet's sequence number. 88 // AckNotifier.
84 for (const QuicFrame& quic_frame : frames->frames()) { 89 ack_notifier_map_[serialized_packet.sequence_number].insert(notifier);
85 if (quic_frame.type != STREAM_FRAME || 90
86 quic_frame.stream_frame->notifier == nullptr) { 91 // Take ownership of the AckNotifier.
87 continue; 92 ack_notifiers_.insert(notifier);
93 }
94 } else {
95 // AckNotifiers can only be attached to retransmittable frames.
96 RetransmittableFrames* frames = serialized_packet.retransmittable_frames;
97 if (frames == nullptr) {
98 return;
88 } 99 }
89 100
90 QuicAckNotifier* notifier = quic_frame.stream_frame->notifier; 101 // For each frame in |serialized_packet|, inform any attached AckNotifiers
91 notifier->AddSequenceNumber(serialized_packet.sequence_number, 102 // of the packet's sequence number.
92 serialized_packet.packet->length()); 103 for (const QuicFrame& quic_frame : frames->frames()) {
104 if (quic_frame.type != STREAM_FRAME ||
105 quic_frame.stream_frame->notifier == nullptr) {
106 continue;
107 }
93 108
94 // Update the mapping in the other direction, from sequence number to 109 QuicAckNotifier* notifier = quic_frame.stream_frame->notifier;
95 // AckNotifier. 110 notifier->AddSequenceNumber(serialized_packet.sequence_number,
96 ack_notifier_map_[serialized_packet.sequence_number].insert(notifier); 111 serialized_packet.packet->length());
97 112
98 // Take ownership of the AckNotifier. 113 // Update the mapping in the other direction, from sequence number to
99 ack_notifiers_.insert(notifier); 114 // AckNotifier.
115 ack_notifier_map_[serialized_packet.sequence_number].insert(notifier);
116
117 // Take ownership of the AckNotifier.
118 ack_notifiers_.insert(notifier);
119 }
100 } 120 }
101 } 121 }
102 122
103 } // namespace net 123 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698