Chromium Code Reviews| 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_protocol.h" | 5 #include "net/quic/quic_protocol.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "net/quic/quic_utils.h" | 8 #include "net/quic/quic_utils.h" |
| 9 | 9 |
| 10 using base::StringPiece; | 10 using base::StringPiece; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 case QUIC_VERSION_18: | 164 case QUIC_VERSION_18: |
| 165 return MakeQuicTag('Q', '0', '1', '8'); | 165 return MakeQuicTag('Q', '0', '1', '8'); |
| 166 case QUIC_VERSION_19: | 166 case QUIC_VERSION_19: |
| 167 return MakeQuicTag('Q', '0', '1', '9'); | 167 return MakeQuicTag('Q', '0', '1', '9'); |
| 168 case QUIC_VERSION_20: | 168 case QUIC_VERSION_20: |
| 169 return MakeQuicTag('Q', '0', '2', '0'); | 169 return MakeQuicTag('Q', '0', '2', '0'); |
| 170 case QUIC_VERSION_21: | 170 case QUIC_VERSION_21: |
| 171 return MakeQuicTag('Q', '0', '2', '1'); | 171 return MakeQuicTag('Q', '0', '2', '1'); |
| 172 case QUIC_VERSION_22: | 172 case QUIC_VERSION_22: |
| 173 return MakeQuicTag('Q', '0', '2', '2'); | 173 return MakeQuicTag('Q', '0', '2', '2'); |
| 174 case QUIC_VERSION_23: | |
| 175 return MakeQuicTag('Q', '0', '2', '3'); | |
| 174 default: | 176 default: |
| 175 // This shold be an ERROR because we should never attempt to convert an | 177 // This shold be an ERROR because we should never attempt to convert an |
| 176 // invalid QuicVersion to be written to the wire. | 178 // invalid QuicVersion to be written to the wire. |
| 177 LOG(ERROR) << "Unsupported QuicVersion: " << version; | 179 LOG(ERROR) << "Unsupported QuicVersion: " << version; |
| 178 return 0; | 180 return 0; |
| 179 } | 181 } |
| 180 } | 182 } |
| 181 | 183 |
| 182 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { | 184 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { |
| 183 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { | 185 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 196 return #x | 198 return #x |
| 197 | 199 |
| 198 string QuicVersionToString(const QuicVersion version) { | 200 string QuicVersionToString(const QuicVersion version) { |
| 199 switch (version) { | 201 switch (version) { |
| 200 RETURN_STRING_LITERAL(QUIC_VERSION_16); | 202 RETURN_STRING_LITERAL(QUIC_VERSION_16); |
| 201 RETURN_STRING_LITERAL(QUIC_VERSION_18); | 203 RETURN_STRING_LITERAL(QUIC_VERSION_18); |
| 202 RETURN_STRING_LITERAL(QUIC_VERSION_19); | 204 RETURN_STRING_LITERAL(QUIC_VERSION_19); |
| 203 RETURN_STRING_LITERAL(QUIC_VERSION_20); | 205 RETURN_STRING_LITERAL(QUIC_VERSION_20); |
| 204 RETURN_STRING_LITERAL(QUIC_VERSION_21); | 206 RETURN_STRING_LITERAL(QUIC_VERSION_21); |
| 205 RETURN_STRING_LITERAL(QUIC_VERSION_22); | 207 RETURN_STRING_LITERAL(QUIC_VERSION_22); |
| 208 RETURN_STRING_LITERAL(QUIC_VERSION_23); | |
| 206 default: | 209 default: |
| 207 return "QUIC_VERSION_UNSUPPORTED"; | 210 return "QUIC_VERSION_UNSUPPORTED"; |
| 208 } | 211 } |
| 209 } | 212 } |
| 210 | 213 |
| 211 string QuicVersionVectorToString(const QuicVersionVector& versions) { | 214 string QuicVersionVectorToString(const QuicVersionVector& versions) { |
| 212 string result = ""; | 215 string result = ""; |
| 213 for (size_t i = 0; i < versions.size(); ++i) { | 216 for (size_t i = 0; i < versions.size(); ++i) { |
| 214 if (i != 0) { | 217 if (i != 0) { |
| 215 result.append(","); | 218 result.append(","); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 largest_observed(0), | 270 largest_observed(0), |
| 268 delta_time_largest_observed(QuicTime::Delta::Infinite()), | 271 delta_time_largest_observed(QuicTime::Delta::Infinite()), |
| 269 is_truncated(false) {} | 272 is_truncated(false) {} |
| 270 | 273 |
| 271 QuicAckFrame::~QuicAckFrame() {} | 274 QuicAckFrame::~QuicAckFrame() {} |
| 272 | 275 |
| 273 CongestionFeedbackMessageTCP::CongestionFeedbackMessageTCP() | 276 CongestionFeedbackMessageTCP::CongestionFeedbackMessageTCP() |
| 274 : receive_window(0) { | 277 : receive_window(0) { |
| 275 } | 278 } |
| 276 | 279 |
| 277 CongestionFeedbackMessageTimestamp::CongestionFeedbackMessageTimestamp() { | |
| 278 } | |
| 279 | |
| 280 CongestionFeedbackMessageTimestamp::~CongestionFeedbackMessageTimestamp() {} | |
| 281 | |
| 282 QuicCongestionFeedbackFrame::QuicCongestionFeedbackFrame() : type(kTCP) {} | 280 QuicCongestionFeedbackFrame::QuicCongestionFeedbackFrame() : type(kTCP) {} |
| 283 | 281 |
| 284 QuicCongestionFeedbackFrame::~QuicCongestionFeedbackFrame() {} | 282 QuicCongestionFeedbackFrame::~QuicCongestionFeedbackFrame() {} |
| 285 | 283 |
| 286 QuicRstStreamErrorCode AdjustErrorForVersion( | 284 QuicRstStreamErrorCode AdjustErrorForVersion( |
| 287 QuicRstStreamErrorCode error_code, | 285 QuicRstStreamErrorCode error_code, |
| 288 QuicVersion version) { | 286 QuicVersion version) { |
| 289 switch (error_code) { | 287 switch (error_code) { |
| 290 case QUIC_RST_FLOW_CONTROL_ACCOUNTING: | 288 case QUIC_RST_FLOW_CONTROL_ACCOUNTING: |
| 291 if (version < QUIC_VERSION_18) { | 289 if (version < QUIC_VERSION_18) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 QuicFecData::QuicFecData() : fec_group(0) {} | 374 QuicFecData::QuicFecData() : fec_group(0) {} |
| 377 | 375 |
| 378 ostream& operator<<(ostream& os, const QuicStopWaitingFrame& sent_info) { | 376 ostream& operator<<(ostream& os, const QuicStopWaitingFrame& sent_info) { |
| 379 os << "entropy_hash: " << static_cast<int>(sent_info.entropy_hash) | 377 os << "entropy_hash: " << static_cast<int>(sent_info.entropy_hash) |
| 380 << " least_unacked: " << sent_info.least_unacked; | 378 << " least_unacked: " << sent_info.least_unacked; |
| 381 return os; | 379 return os; |
| 382 } | 380 } |
| 383 | 381 |
| 384 ostream& operator<<(ostream& os, const QuicAckFrame& ack_frame) { | 382 ostream& operator<<(ostream& os, const QuicAckFrame& ack_frame) { |
| 385 os << "entropy_hash: " << static_cast<int>(ack_frame.entropy_hash) | 383 os << "entropy_hash: " << static_cast<int>(ack_frame.entropy_hash) |
| 386 << " is_truncated: " << ack_frame.is_truncated | |
| 387 << " largest_observed: " << ack_frame.largest_observed | 384 << " largest_observed: " << ack_frame.largest_observed |
| 388 << " delta_time_largest_observed: " | 385 << " delta_time_largest_observed: " |
| 389 << ack_frame.delta_time_largest_observed.ToMicroseconds() | 386 << ack_frame.delta_time_largest_observed.ToMicroseconds() |
| 390 << " missing_packets: [ "; | 387 << " missing_packets: [ "; |
| 391 for (SequenceNumberSet::const_iterator it = ack_frame.missing_packets.begin(); | 388 for (SequenceNumberSet::const_iterator it = ack_frame.missing_packets.begin(); |
| 392 it != ack_frame.missing_packets.end(); ++it) { | 389 it != ack_frame.missing_packets.end(); ++it) { |
| 393 os << *it << " "; | 390 os << *it << " "; |
| 394 } | 391 } |
| 395 os << " ] revived_packets: [ "; | 392 os << " ] is_truncated: " << ack_frame.is_truncated; |
|
ramant (doing other things)
2014/08/23 23:55:29
minor change to print the data in the same order a
| |
| 393 os << " revived_packets: [ "; | |
| 396 for (SequenceNumberSet::const_iterator it = ack_frame.revived_packets.begin(); | 394 for (SequenceNumberSet::const_iterator it = ack_frame.revived_packets.begin(); |
| 397 it != ack_frame.revived_packets.end(); ++it) { | 395 it != ack_frame.revived_packets.end(); ++it) { |
| 398 os << *it << " "; | 396 os << *it << " "; |
| 399 } | 397 } |
| 398 os << " ] received_packets: [ "; | |
| 399 for (PacketTimeList::const_iterator it = | |
| 400 ack_frame.received_packet_times.begin(); | |
| 401 it != ack_frame.received_packet_times.end(); ++it) { | |
| 402 os << it->first << " at " << it->second.ToDebuggingValue() << " "; | |
| 403 } | |
| 400 os << " ]"; | 404 os << " ]"; |
| 401 return os; | 405 return os; |
| 402 } | 406 } |
| 403 | 407 |
| 404 ostream& operator<<(ostream& os, const QuicFrame& frame) { | 408 ostream& operator<<(ostream& os, const QuicFrame& frame) { |
| 405 switch (frame.type) { | 409 switch (frame.type) { |
| 406 case PADDING_FRAME: { | 410 case PADDING_FRAME: { |
| 407 os << "type { PADDING_FRAME } "; | 411 os << "type { PADDING_FRAME } "; |
| 408 break; | 412 break; |
| 409 } | 413 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 << "data { " | 501 << "data { " |
| 498 << QuicUtils::StringToHexASCIIDump(*(stream_frame.GetDataAsString())) | 502 << QuicUtils::StringToHexASCIIDump(*(stream_frame.GetDataAsString())) |
| 499 << " }\n"; | 503 << " }\n"; |
| 500 return os; | 504 return os; |
| 501 } | 505 } |
| 502 | 506 |
| 503 ostream& operator<<(ostream& os, | 507 ostream& operator<<(ostream& os, |
| 504 const QuicCongestionFeedbackFrame& congestion_frame) { | 508 const QuicCongestionFeedbackFrame& congestion_frame) { |
| 505 os << "type: " << congestion_frame.type; | 509 os << "type: " << congestion_frame.type; |
| 506 switch (congestion_frame.type) { | 510 switch (congestion_frame.type) { |
| 507 case kTimestamp: { | |
| 508 const CongestionFeedbackMessageTimestamp& timestamp = | |
| 509 congestion_frame.timestamp; | |
| 510 os << " received packets: [ "; | |
| 511 for (TimeMap::const_iterator it = timestamp.received_packet_times.begin(); | |
| 512 it != timestamp.received_packet_times.end(); ++it) { | |
| 513 os << it->first << "@" << it->second.ToDebuggingValue() << " "; | |
| 514 } | |
| 515 os << "]"; | |
| 516 break; | |
| 517 } | |
| 518 case kTCP: { | 511 case kTCP: { |
| 519 const CongestionFeedbackMessageTCP& tcp = congestion_frame.tcp; | 512 const CongestionFeedbackMessageTCP& tcp = congestion_frame.tcp; |
| 520 os << " receive_window: " << tcp.receive_window; | 513 os << " receive_window: " << tcp.receive_window; |
| 521 break; | 514 break; |
| 522 } | 515 } |
| 523 } | 516 } |
| 524 return os; | 517 return os; |
| 525 } | 518 } |
| 526 | 519 |
| 527 QuicGoAwayFrame::QuicGoAwayFrame() | 520 QuicGoAwayFrame::QuicGoAwayFrame() |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 sent_time(QuicTime::Zero()), | 750 sent_time(QuicTime::Zero()), |
| 758 bytes_sent(0), | 751 bytes_sent(0), |
| 759 nack_count(0), | 752 nack_count(0), |
| 760 transmission_type(transmission_type), | 753 transmission_type(transmission_type), |
| 761 all_transmissions(all_transmissions), | 754 all_transmissions(all_transmissions), |
| 762 in_flight(false) { | 755 in_flight(false) { |
| 763 all_transmissions->insert(sequence_number); | 756 all_transmissions->insert(sequence_number); |
| 764 } | 757 } |
| 765 | 758 |
| 766 } // namespace net | 759 } // namespace net |
| OLD | NEW |