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

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

Issue 413403008: Remove QUIC_VERSION_15 now that Chrome Stable supports QUIC_VERSION_16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0723
Patch Set: Created 6 years, 4 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_connection_test.cc ('k') | net/quic/quic_framer_test.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 #include "net/quic/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/crypto/crypto_framer.h" 9 #include "net/quic/crypto/crypto_framer.h"
10 #include "net/quic/crypto/crypto_handshake_message.h" 10 #include "net/quic/crypto/crypto_handshake_message.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return kQuicFrameTypeSize + GetStreamIdSize(stream_id) + 191 return kQuicFrameTypeSize + GetStreamIdSize(stream_id) +
192 GetStreamOffsetSize(offset) + 192 GetStreamOffsetSize(offset) +
193 (no_stream_frame_length ? 0 : kQuicStreamPayloadLengthSize); 193 (no_stream_frame_length ? 0 : kQuicStreamPayloadLengthSize);
194 } 194 }
195 195
196 // static 196 // static
197 size_t QuicFramer::GetMinAckFrameSize( 197 size_t QuicFramer::GetMinAckFrameSize(
198 QuicVersion version, 198 QuicVersion version,
199 QuicSequenceNumberLength sequence_number_length, 199 QuicSequenceNumberLength sequence_number_length,
200 QuicSequenceNumberLength largest_observed_length) { 200 QuicSequenceNumberLength largest_observed_length) {
201 size_t len = kQuicFrameTypeSize + kQuicEntropyHashSize + 201 return kQuicFrameTypeSize + kQuicEntropyHashSize +
202 largest_observed_length + kQuicDeltaTimeLargestObservedSize; 202 largest_observed_length + kQuicDeltaTimeLargestObservedSize;
203 if (version <= QUIC_VERSION_15) {
204 len += sequence_number_length + kQuicEntropyHashSize;
205 }
206 return len;
207 } 203 }
208 204
209 // static 205 // static
210 size_t QuicFramer::GetStopWaitingFrameSize( 206 size_t QuicFramer::GetStopWaitingFrameSize(
211 QuicSequenceNumberLength sequence_number_length) { 207 QuicSequenceNumberLength sequence_number_length) {
212 return kQuicFrameTypeSize + kQuicEntropyHashSize + 208 return kQuicFrameTypeSize + kQuicEntropyHashSize +
213 sequence_number_length; 209 sequence_number_length;
214 } 210 }
215 211
216 // static 212 // static
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 371 }
376 break; 372 break;
377 case CONGESTION_FEEDBACK_FRAME: 373 case CONGESTION_FEEDBACK_FRAME:
378 if (!AppendCongestionFeedbackFrame( 374 if (!AppendCongestionFeedbackFrame(
379 *frame.congestion_feedback_frame, &writer)) { 375 *frame.congestion_feedback_frame, &writer)) {
380 LOG(DFATAL) << "AppendCongestionFeedbackFrame failed"; 376 LOG(DFATAL) << "AppendCongestionFeedbackFrame failed";
381 return kNoPacket; 377 return kNoPacket;
382 } 378 }
383 break; 379 break;
384 case STOP_WAITING_FRAME: 380 case STOP_WAITING_FRAME:
385 if (quic_version_ <= QUIC_VERSION_15) {
386 LOG(DFATAL) << "Attempt to add a StopWaitingFrame in "
387 << QuicVersionToString(quic_version_);
388 return kNoPacket;
389 }
390 if (!AppendStopWaitingFrame( 381 if (!AppendStopWaitingFrame(
391 header, *frame.stop_waiting_frame, &writer)) { 382 header, *frame.stop_waiting_frame, &writer)) {
392 LOG(DFATAL) << "AppendStopWaitingFrame failed"; 383 LOG(DFATAL) << "AppendStopWaitingFrame failed";
393 return kNoPacket; 384 return kNoPacket;
394 } 385 }
395 break; 386 break;
396 case PING_FRAME: 387 case PING_FRAME:
397 if (quic_version_ <= QUIC_VERSION_16) { 388 if (quic_version_ <= QUIC_VERSION_16) {
398 LOG(DFATAL) << "Attempt to add a PingFrame in " 389 LOG(DFATAL) << "Attempt to add a PingFrame in "
399 << QuicVersionToString(quic_version_); 390 << QuicVersionToString(quic_version_);
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 } 1203 }
1213 if (!visitor_->OnBlockedFrame(blocked_frame)) { 1204 if (!visitor_->OnBlockedFrame(blocked_frame)) {
1214 DVLOG(1) << "Visitor asked to stop further processing."; 1205 DVLOG(1) << "Visitor asked to stop further processing.";
1215 // Returning true since there was no parsing error. 1206 // Returning true since there was no parsing error.
1216 return true; 1207 return true;
1217 } 1208 }
1218 continue; 1209 continue;
1219 } 1210 }
1220 1211
1221 case STOP_WAITING_FRAME: { 1212 case STOP_WAITING_FRAME: {
1222 if (quic_version_ <= QUIC_VERSION_15) {
1223 LOG(DFATAL) << "Trying to read a StopWaiting in "
1224 << QuicVersionToString(quic_version_);
1225 return RaiseError(QUIC_INTERNAL_ERROR);
1226 }
1227 QuicStopWaitingFrame stop_waiting_frame; 1213 QuicStopWaitingFrame stop_waiting_frame;
1228 if (!ProcessStopWaitingFrame(header, &stop_waiting_frame)) { 1214 if (!ProcessStopWaitingFrame(header, &stop_waiting_frame)) {
1229 return RaiseError(QUIC_INVALID_STOP_WAITING_DATA); 1215 return RaiseError(QUIC_INVALID_STOP_WAITING_DATA);
1230 } 1216 }
1231 if (!visitor_->OnStopWaitingFrame(stop_waiting_frame)) { 1217 if (!visitor_->OnStopWaitingFrame(stop_waiting_frame)) {
1232 DVLOG(1) << "Visitor asked to stop further processing."; 1218 DVLOG(1) << "Visitor asked to stop further processing.";
1233 // Returning true since there was no parsing error. 1219 // Returning true since there was no parsing error.
1234 return true; 1220 return true;
1235 } 1221 }
1236 continue; 1222 continue;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 if (!frame_data.empty()) { 1300 if (!frame_data.empty()) {
1315 frame->data.Append(const_cast<char*>(frame_data.data()), frame_data.size()); 1301 frame->data.Append(const_cast<char*>(frame_data.data()), frame_data.size());
1316 } 1302 }
1317 1303
1318 return true; 1304 return true;
1319 } 1305 }
1320 1306
1321 bool QuicFramer::ProcessAckFrame(const QuicPacketHeader& header, 1307 bool QuicFramer::ProcessAckFrame(const QuicPacketHeader& header,
1322 uint8 frame_type, 1308 uint8 frame_type,
1323 QuicAckFrame* frame) { 1309 QuicAckFrame* frame) {
1324 if (quic_version_ <= QUIC_VERSION_15) {
1325 if (!ProcessStopWaitingFrame(header, &frame->sent_info)) {
1326 return false;
1327 }
1328 }
1329 if (!ProcessReceivedInfo(frame_type, &frame->received_info)) { 1310 if (!ProcessReceivedInfo(frame_type, &frame->received_info)) {
1330 return false; 1311 return false;
1331 } 1312 }
1332 return true; 1313 return true;
1333 } 1314 }
1334 1315
1335 bool QuicFramer::ProcessReceivedInfo(uint8 frame_type, 1316 bool QuicFramer::ProcessReceivedInfo(uint8 frame_type,
1336 ReceivedPacketInfo* received_info) { 1317 ReceivedPacketInfo* received_info) {
1337 // Determine the three lengths from the frame type: largest observed length, 1318 // Determine the three lengths from the frame type: largest observed length,
1338 // missing sequence number length, and missing range length. 1319 // missing sequence number length, and missing range length.
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 // Missing sequence number length. 2023 // Missing sequence number length.
2043 type_byte <<= kQuicSequenceNumberLengthShift; 2024 type_byte <<= kQuicSequenceNumberLengthShift;
2044 type_byte |= GetSequenceNumberFlags(missing_sequence_number_length); 2025 type_byte |= GetSequenceNumberFlags(missing_sequence_number_length);
2045 2026
2046 type_byte |= kQuicFrameTypeAckMask; 2027 type_byte |= kQuicFrameTypeAckMask;
2047 2028
2048 if (!writer->WriteUInt8(type_byte)) { 2029 if (!writer->WriteUInt8(type_byte)) {
2049 return false; 2030 return false;
2050 } 2031 }
2051 2032
2052 if (quic_version_ <= QUIC_VERSION_15) {
2053 if (!AppendStopWaitingFrame(header, frame.sent_info, writer)) {
2054 return false;
2055 }
2056 }
2057
2058 const ReceivedPacketInfo& received_info = frame.received_info; 2033 const ReceivedPacketInfo& received_info = frame.received_info;
2059 QuicPacketEntropyHash ack_entropy_hash = received_info.entropy_hash; 2034 QuicPacketEntropyHash ack_entropy_hash = received_info.entropy_hash;
2060 NackRangeMap::reverse_iterator ack_iter = ack_info.nack_ranges.rbegin(); 2035 NackRangeMap::reverse_iterator ack_iter = ack_info.nack_ranges.rbegin();
2061 if (truncated) { 2036 if (truncated) {
2062 // Skip the nack ranges which the truncated ack won't include and set 2037 // Skip the nack ranges which the truncated ack won't include and set
2063 // a correct largest observed for the truncated ack. 2038 // a correct largest observed for the truncated ack.
2064 for (size_t i = 1; i < (ack_info.nack_ranges.size() - max_num_ranges); 2039 for (size_t i = 1; i < (ack_info.nack_ranges.size() - max_num_ranges);
2065 ++i) { 2040 ++i) {
2066 ++ack_iter; 2041 ++ack_iter;
2067 } 2042 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 2312
2338 bool QuicFramer::RaiseError(QuicErrorCode error) { 2313 bool QuicFramer::RaiseError(QuicErrorCode error) {
2339 DVLOG(1) << "Error detail: " << detailed_error_; 2314 DVLOG(1) << "Error detail: " << detailed_error_;
2340 set_error(error); 2315 set_error(error);
2341 visitor_->OnError(this); 2316 visitor_->OnError(this);
2342 reader_.reset(NULL); 2317 reader_.reset(NULL);
2343 return false; 2318 return false;
2344 } 2319 }
2345 2320
2346 } // namespace net 2321 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_test.cc ('k') | net/quic/quic_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698