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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
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
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_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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 QuicVersionVector QuicSupportedVersions() { 151 QuicVersionVector QuicSupportedVersions() {
152 QuicVersionVector supported_versions; 152 QuicVersionVector supported_versions;
153 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { 153 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
154 supported_versions.push_back(kSupportedQuicVersions[i]); 154 supported_versions.push_back(kSupportedQuicVersions[i]);
155 } 155 }
156 return supported_versions; 156 return supported_versions;
157 } 157 }
158 158
159 QuicTag QuicVersionToQuicTag(const QuicVersion version) { 159 QuicTag QuicVersionToQuicTag(const QuicVersion version) {
160 switch (version) { 160 switch (version) {
161 case QUIC_VERSION_21:
162 return MakeQuicTag('Q', '0', '2', '1');
163 case QUIC_VERSION_22:
164 return MakeQuicTag('Q', '0', '2', '2');
165 case QUIC_VERSION_23: 161 case QUIC_VERSION_23:
166 return MakeQuicTag('Q', '0', '2', '3'); 162 return MakeQuicTag('Q', '0', '2', '3');
163 case QUIC_VERSION_24:
164 return MakeQuicTag('Q', '0', '2', '4');
167 default: 165 default:
168 // This shold be an ERROR because we should never attempt to convert an 166 // This shold be an ERROR because we should never attempt to convert an
169 // invalid QuicVersion to be written to the wire. 167 // invalid QuicVersion to be written to the wire.
170 LOG(ERROR) << "Unsupported QuicVersion: " << version; 168 LOG(ERROR) << "Unsupported QuicVersion: " << version;
171 return 0; 169 return 0;
172 } 170 }
173 } 171 }
174 172
175 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { 173 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) {
176 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { 174 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
177 if (version_tag == QuicVersionToQuicTag(kSupportedQuicVersions[i])) { 175 if (version_tag == QuicVersionToQuicTag(kSupportedQuicVersions[i])) {
178 return kSupportedQuicVersions[i]; 176 return kSupportedQuicVersions[i];
179 } 177 }
180 } 178 }
181 // Reading from the client so this should not be considered an ERROR. 179 // Reading from the client so this should not be considered an ERROR.
182 DVLOG(1) << "Unsupported QuicTag version: " 180 DVLOG(1) << "Unsupported QuicTag version: "
183 << QuicUtils::TagToString(version_tag); 181 << QuicUtils::TagToString(version_tag);
184 return QUIC_VERSION_UNSUPPORTED; 182 return QUIC_VERSION_UNSUPPORTED;
185 } 183 }
186 184
187 #define RETURN_STRING_LITERAL(x) \ 185 #define RETURN_STRING_LITERAL(x) \
188 case x: \ 186 case x: \
189 return #x 187 return #x
190 188
191 string QuicVersionToString(const QuicVersion version) { 189 string QuicVersionToString(const QuicVersion version) {
192 switch (version) { 190 switch (version) {
193 RETURN_STRING_LITERAL(QUIC_VERSION_21);
194 RETURN_STRING_LITERAL(QUIC_VERSION_22);
195 RETURN_STRING_LITERAL(QUIC_VERSION_23); 191 RETURN_STRING_LITERAL(QUIC_VERSION_23);
192 RETURN_STRING_LITERAL(QUIC_VERSION_24);
196 default: 193 default:
197 return "QUIC_VERSION_UNSUPPORTED"; 194 return "QUIC_VERSION_UNSUPPORTED";
198 } 195 }
199 } 196 }
200 197
201 string QuicVersionVectorToString(const QuicVersionVector& versions) { 198 string QuicVersionVectorToString(const QuicVersionVector& versions) {
202 string result = ""; 199 string result = "";
203 for (size_t i = 0; i < versions.size(); ++i) { 200 for (size_t i = 0; i < versions.size(); ++i) {
204 if (i != 0) { 201 if (i != 0) {
205 result.append(","); 202 result.append(",");
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 QuicStopWaitingFrame::~QuicStopWaitingFrame() {} 250 QuicStopWaitingFrame::~QuicStopWaitingFrame() {}
254 251
255 QuicAckFrame::QuicAckFrame() 252 QuicAckFrame::QuicAckFrame()
256 : entropy_hash(0), 253 : entropy_hash(0),
257 largest_observed(0), 254 largest_observed(0),
258 delta_time_largest_observed(QuicTime::Delta::Infinite()), 255 delta_time_largest_observed(QuicTime::Delta::Infinite()),
259 is_truncated(false) {} 256 is_truncated(false) {}
260 257
261 QuicAckFrame::~QuicAckFrame() {} 258 QuicAckFrame::~QuicAckFrame() {}
262 259
263 CongestionFeedbackMessageTCP::CongestionFeedbackMessageTCP()
264 : receive_window(0) {
265 }
266
267 QuicCongestionFeedbackFrame::QuicCongestionFeedbackFrame() : type(kTCP) {}
268
269 QuicCongestionFeedbackFrame::~QuicCongestionFeedbackFrame() {}
270
271 QuicRstStreamErrorCode AdjustErrorForVersion( 260 QuicRstStreamErrorCode AdjustErrorForVersion(
272 QuicRstStreamErrorCode error_code, 261 QuicRstStreamErrorCode error_code,
273 QuicVersion version) { 262 QuicVersion version) {
274 return error_code; 263 return error_code;
275 } 264 }
276 265
277 QuicRstStreamFrame::QuicRstStreamFrame() 266 QuicRstStreamFrame::QuicRstStreamFrame()
278 : stream_id(0), 267 : stream_id(0),
279 error_code(QUIC_STREAM_NO_ERROR) { 268 error_code(QUIC_STREAM_NO_ERROR) {
280 } 269 }
(...skipping 21 matching lines...) Expand all
302 QuicFrame::QuicFrame(QuicStreamFrame* stream_frame) 291 QuicFrame::QuicFrame(QuicStreamFrame* stream_frame)
303 : type(STREAM_FRAME), 292 : type(STREAM_FRAME),
304 stream_frame(stream_frame) { 293 stream_frame(stream_frame) {
305 } 294 }
306 295
307 QuicFrame::QuicFrame(QuicAckFrame* frame) 296 QuicFrame::QuicFrame(QuicAckFrame* frame)
308 : type(ACK_FRAME), 297 : type(ACK_FRAME),
309 ack_frame(frame) { 298 ack_frame(frame) {
310 } 299 }
311 300
312 QuicFrame::QuicFrame(QuicCongestionFeedbackFrame* frame)
313 : type(CONGESTION_FEEDBACK_FRAME),
314 congestion_feedback_frame(frame) {
315 }
316
317 QuicFrame::QuicFrame(QuicStopWaitingFrame* frame) 301 QuicFrame::QuicFrame(QuicStopWaitingFrame* frame)
318 : type(STOP_WAITING_FRAME), 302 : type(STOP_WAITING_FRAME),
319 stop_waiting_frame(frame) { 303 stop_waiting_frame(frame) {
320 } 304 }
321 305
322 QuicFrame::QuicFrame(QuicPingFrame* frame) 306 QuicFrame::QuicFrame(QuicPingFrame* frame)
323 : type(PING_FRAME), 307 : type(PING_FRAME),
324 ping_frame(frame) { 308 ping_frame(frame) {
325 } 309 }
326 310
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 break; 395 break;
412 } 396 }
413 case STREAM_FRAME: { 397 case STREAM_FRAME: {
414 os << "type { STREAM_FRAME } " << *(frame.stream_frame); 398 os << "type { STREAM_FRAME } " << *(frame.stream_frame);
415 break; 399 break;
416 } 400 }
417 case ACK_FRAME: { 401 case ACK_FRAME: {
418 os << "type { ACK_FRAME } " << *(frame.ack_frame); 402 os << "type { ACK_FRAME } " << *(frame.ack_frame);
419 break; 403 break;
420 } 404 }
421 case CONGESTION_FEEDBACK_FRAME: {
422 os << "type { CONGESTION_FEEDBACK_FRAME } "
423 << *(frame.congestion_feedback_frame);
424 break;
425 }
426 case STOP_WAITING_FRAME: { 405 case STOP_WAITING_FRAME: {
427 os << "type { STOP_WAITING_FRAME } " << *(frame.stop_waiting_frame); 406 os << "type { STOP_WAITING_FRAME } " << *(frame.stop_waiting_frame);
428 break; 407 break;
429 } 408 }
430 case PING_FRAME: { 409 case PING_FRAME: {
431 os << "type { PING_FRAME } "; 410 os << "type { PING_FRAME } ";
432 break; 411 break;
433 } 412 }
434 default: { 413 default: {
435 LOG(ERROR) << "Unknown frame type: " << frame.type; 414 LOG(ERROR) << "Unknown frame type: " << frame.type;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 ostream& operator<<(ostream& os, const QuicStreamFrame& stream_frame) { 454 ostream& operator<<(ostream& os, const QuicStreamFrame& stream_frame) {
476 os << "stream_id { " << stream_frame.stream_id << " } " 455 os << "stream_id { " << stream_frame.stream_id << " } "
477 << "fin { " << stream_frame.fin << " } " 456 << "fin { " << stream_frame.fin << " } "
478 << "offset { " << stream_frame.offset << " } " 457 << "offset { " << stream_frame.offset << " } "
479 << "data { " 458 << "data { "
480 << QuicUtils::StringToHexASCIIDump(*(stream_frame.GetDataAsString())) 459 << QuicUtils::StringToHexASCIIDump(*(stream_frame.GetDataAsString()))
481 << " }\n"; 460 << " }\n";
482 return os; 461 return os;
483 } 462 }
484 463
485 ostream& operator<<(ostream& os,
486 const QuicCongestionFeedbackFrame& congestion_frame) {
487 os << "type: " << congestion_frame.type;
488 switch (congestion_frame.type) {
489 case kTCP: {
490 const CongestionFeedbackMessageTCP& tcp = congestion_frame.tcp;
491 os << " receive_window: " << tcp.receive_window;
492 break;
493 }
494 }
495 return os;
496 }
497
498 QuicGoAwayFrame::QuicGoAwayFrame() 464 QuicGoAwayFrame::QuicGoAwayFrame()
499 : error_code(QUIC_NO_ERROR), 465 : error_code(QUIC_NO_ERROR),
500 last_good_stream_id(0) { 466 last_good_stream_id(0) {
501 } 467 }
502 468
503 QuicGoAwayFrame::QuicGoAwayFrame(QuicErrorCode error_code, 469 QuicGoAwayFrame::QuicGoAwayFrame(QuicErrorCode error_code,
504 QuicStreamId last_good_stream_id, 470 QuicStreamId last_good_stream_id,
505 const string& reason) 471 const string& reason)
506 : error_code(error_code), 472 : error_code(error_code),
507 last_good_stream_id(last_good_stream_id), 473 last_good_stream_id(last_good_stream_id),
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 switch (it->type) { 568 switch (it->type) {
603 case PADDING_FRAME: 569 case PADDING_FRAME:
604 delete it->padding_frame; 570 delete it->padding_frame;
605 break; 571 break;
606 case STREAM_FRAME: 572 case STREAM_FRAME:
607 delete it->stream_frame; 573 delete it->stream_frame;
608 break; 574 break;
609 case ACK_FRAME: 575 case ACK_FRAME:
610 delete it->ack_frame; 576 delete it->ack_frame;
611 break; 577 break;
612 case CONGESTION_FEEDBACK_FRAME:
613 delete it->congestion_feedback_frame;
614 break;
615 case STOP_WAITING_FRAME: 578 case STOP_WAITING_FRAME:
616 delete it->stop_waiting_frame; 579 delete it->stop_waiting_frame;
617 break; 580 break;
618 case PING_FRAME: 581 case PING_FRAME:
619 delete it->ping_frame; 582 delete it->ping_frame;
620 break; 583 break;
621 case RST_STREAM_FRAME: 584 case RST_STREAM_FRAME:
622 delete it->rst_stream_frame; 585 delete it->rst_stream_frame;
623 break; 586 break;
624 case CONNECTION_CLOSE_FRAME: 587 case CONNECTION_CLOSE_FRAME:
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 sent_time(sent_time), 677 sent_time(sent_time),
715 bytes_sent(0), 678 bytes_sent(0),
716 nack_count(0), 679 nack_count(0),
717 transmission_type(transmission_type), 680 transmission_type(transmission_type),
718 all_transmissions(nullptr), 681 all_transmissions(nullptr),
719 in_flight(false), 682 in_flight(false),
720 is_unackable(false), 683 is_unackable(false),
721 is_fec_packet(false) {} 684 is_fec_packet(false) {}
722 685
723 } // namespace net 686 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698