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 #include "net/quic/quic_packet_generator.h" | 5 #include "net/quic/quic_packet_generator.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "net/quic/quic_ack_notifier.h" | 9 #include "net/quic/quic_ack_notifier.h" |
10 #include "net/quic/quic_fec_group.h" | 10 #include "net/quic/quic_fec_group.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 should_send_ack_(false), | 50 should_send_ack_(false), |
51 should_send_stop_waiting_(false), | 51 should_send_stop_waiting_(false), |
52 ack_queued_(false), | 52 ack_queued_(false), |
53 stop_waiting_queued_(false), | 53 stop_waiting_queued_(false), |
54 max_packet_length_(kDefaultMaxPacketSize) {} | 54 max_packet_length_(kDefaultMaxPacketSize) {} |
55 | 55 |
56 QuicPacketGenerator::~QuicPacketGenerator() { | 56 QuicPacketGenerator::~QuicPacketGenerator() { |
57 for (QuicFrame& frame : queued_control_frames_) { | 57 for (QuicFrame& frame : queued_control_frames_) { |
58 switch (frame.type) { | 58 switch (frame.type) { |
59 case PADDING_FRAME: | 59 case PADDING_FRAME: |
60 delete frame.padding_frame; | 60 case MTU_DISCOVERY_FRAME: |
| 61 case PING_FRAME: |
| 62 case BLOCKED_FRAME: |
61 break; | 63 break; |
62 case STREAM_FRAME: | 64 case STREAM_FRAME: |
63 delete frame.stream_frame; | 65 delete frame.stream_frame; |
64 break; | 66 break; |
65 case ACK_FRAME: | 67 case ACK_FRAME: |
66 delete frame.ack_frame; | 68 delete frame.ack_frame; |
67 break; | 69 break; |
68 case MTU_DISCOVERY_FRAME: | |
69 delete frame.mtu_discovery_frame; | |
70 break; | |
71 case RST_STREAM_FRAME: | 70 case RST_STREAM_FRAME: |
72 delete frame.rst_stream_frame; | 71 delete frame.rst_stream_frame; |
73 break; | 72 break; |
74 case CONNECTION_CLOSE_FRAME: | 73 case CONNECTION_CLOSE_FRAME: |
75 delete frame.connection_close_frame; | 74 delete frame.connection_close_frame; |
76 break; | 75 break; |
77 case GOAWAY_FRAME: | 76 case GOAWAY_FRAME: |
78 delete frame.goaway_frame; | 77 delete frame.goaway_frame; |
79 break; | 78 break; |
80 case WINDOW_UPDATE_FRAME: | 79 case WINDOW_UPDATE_FRAME: |
81 delete frame.window_update_frame; | 80 delete frame.window_update_frame; |
82 break; | 81 break; |
83 case BLOCKED_FRAME: | |
84 delete frame.blocked_frame; | |
85 break; | |
86 case STOP_WAITING_FRAME: | 82 case STOP_WAITING_FRAME: |
87 delete frame.stop_waiting_frame; | 83 delete frame.stop_waiting_frame; |
88 break; | 84 break; |
89 case PING_FRAME: | |
90 delete frame.ping_frame; | |
91 break; | |
92 case NUM_FRAME_TYPES: | 85 case NUM_FRAME_TYPES: |
93 DCHECK(false) << "Cannot delete type: " << frame.type; | 86 DCHECK(false) << "Cannot delete type: " << frame.type; |
94 } | 87 } |
95 } | 88 } |
96 } | 89 } |
97 | 90 |
98 void QuicPacketGenerator::OnCongestionWindowChange( | 91 void QuicPacketGenerator::OnCongestionWindowChange( |
99 QuicPacketCount max_packets_in_flight) { | 92 QuicPacketCount max_packets_in_flight) { |
100 packet_creator_.set_max_packets_per_fec_group( | 93 packet_creator_.set_max_packets_per_fec_group( |
101 static_cast<size_t>(kMaxPacketsInFlightMultiplierForFecGroupSize * | 94 static_cast<size_t>(kMaxPacketsInFlightMultiplierForFecGroupSize * |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // The notifier manager will take the ownership of the notifier after the | 236 // The notifier manager will take the ownership of the notifier after the |
244 // packet is sent. | 237 // packet is sent. |
245 ack_notifiers_.push_back(ack_notifier); | 238 ack_notifiers_.push_back(ack_notifier); |
246 } | 239 } |
247 | 240 |
248 const QuicByteCount current_mtu = GetMaxPacketLength(); | 241 const QuicByteCount current_mtu = GetMaxPacketLength(); |
249 | 242 |
250 // The MTU discovery frame is allocated on the stack, since it is going to be | 243 // The MTU discovery frame is allocated on the stack, since it is going to be |
251 // serialized within this function. | 244 // serialized within this function. |
252 QuicMtuDiscoveryFrame mtu_discovery_frame; | 245 QuicMtuDiscoveryFrame mtu_discovery_frame; |
253 QuicFrame frame(&mtu_discovery_frame); | 246 QuicFrame frame(mtu_discovery_frame); |
254 | 247 |
255 // Send the probe packet with the new length. | 248 // Send the probe packet with the new length. |
256 SetMaxPacketLength(target_mtu, /*force=*/true); | 249 SetMaxPacketLength(target_mtu, /*force=*/true); |
257 const bool success = AddFrame(frame, nullptr, /*needs_padding=*/true); | 250 const bool success = AddFrame(frame, nullptr, /*needs_padding=*/true); |
258 SerializeAndSendPacket(); | 251 SerializeAndSendPacket(); |
259 // The only reason AddFrame can fail is that the packet is too full to fit in | 252 // The only reason AddFrame can fail is that the packet is too full to fit in |
260 // a ping. This is not possible for any sane MTU. | 253 // a ping. This is not possible for any sane MTU. |
261 DCHECK(success); | 254 DCHECK(success); |
262 | 255 |
263 // Reset the packet length back. | 256 // Reset the packet length back. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { | 546 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { |
554 packet_creator_.set_encryption_level(level); | 547 packet_creator_.set_encryption_level(level); |
555 } | 548 } |
556 | 549 |
557 void QuicPacketGenerator::SetEncrypter(EncryptionLevel level, | 550 void QuicPacketGenerator::SetEncrypter(EncryptionLevel level, |
558 QuicEncrypter* encrypter) { | 551 QuicEncrypter* encrypter) { |
559 packet_creator_.SetEncrypter(level, encrypter); | 552 packet_creator_.SetEncrypter(level, encrypter); |
560 } | 553 } |
561 | 554 |
562 } // namespace net | 555 } // namespace net |
OLD | NEW |