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

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

Issue 1979633003: Clean up the pretty-printing of QUIC frames to be internally consistent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@121705514
Patch Set: Created 4 years, 7 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_protocol.h ('k') | net/quic/quic_protocol_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_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 "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "net/quic/quic_flags.h" 9 #include "net/quic/quic_flags.h"
10 #include "net/quic/quic_utils.h" 10 #include "net/quic/quic_utils.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (s == Perspective::IS_SERVER) { 261 if (s == Perspective::IS_SERVER) {
262 os << "IS_SERVER"; 262 os << "IS_SERVER";
263 } else { 263 } else {
264 os << "IS_CLIENT"; 264 os << "IS_CLIENT";
265 } 265 }
266 return os; 266 return os;
267 } 267 }
268 268
269 ostream& operator<<(ostream& os, const QuicPacketHeader& header) { 269 ostream& operator<<(ostream& os, const QuicPacketHeader& header) {
270 os << "{ connection_id: " << header.public_header.connection_id 270 os << "{ connection_id: " << header.public_header.connection_id
271 << ", connection_id_length:" << header.public_header.connection_id_length 271 << ", connection_id_length: " << header.public_header.connection_id_length
272 << ", packet_number_length:" << header.public_header.packet_number_length 272 << ", packet_number_length: " << header.public_header.packet_number_length
273 << ", multipath_flag: " << header.public_header.multipath_flag 273 << ", multipath_flag: " << header.public_header.multipath_flag
274 << ", reset_flag: " << header.public_header.reset_flag 274 << ", reset_flag: " << header.public_header.reset_flag
275 << ", version_flag: " << header.public_header.version_flag; 275 << ", version_flag: " << header.public_header.version_flag;
276 if (header.public_header.version_flag) { 276 if (header.public_header.version_flag) {
277 os << " version: "; 277 os << ", version:";
278 for (size_t i = 0; i < header.public_header.versions.size(); ++i) { 278 for (size_t i = 0; i < header.public_header.versions.size(); ++i) {
279 os << header.public_header.versions[i] << " "; 279 os << " ";
280 os << header.public_header.versions[i];
280 } 281 }
281 } 282 }
282 if (header.public_header.nonce != nullptr) { 283 if (header.public_header.nonce != nullptr) {
283 os << ", diversification_nonce: " 284 os << ", diversification_nonce: "
284 << QuicUtils::HexEncode(*header.public_header.nonce); 285 << net::QuicUtils::HexDecode(*header.public_header.nonce);
285 } 286 }
286 os << ", fec_flag: " << header.fec_flag 287 os << ", fec_flag: " << header.fec_flag
287 << ", entropy_flag: " << header.entropy_flag 288 << ", entropy_flag: " << header.entropy_flag
288 << ", entropy hash: " << static_cast<int>(header.entropy_hash) 289 << ", entropy hash: " << static_cast<int>(header.entropy_hash)
289 << ", path_id: " << header.path_id 290 << ", path_id: " << static_cast<int>(header.path_id)
290 << ", packet_number: " << header.packet_number 291 << ", packet_number: " << header.packet_number
291 << ", is_in_fec_group:" << header.is_in_fec_group 292 << ", is_in_fec_group: " << header.is_in_fec_group
292 << ", fec_group: " << header.fec_group << "}\n"; 293 << ", fec_group: " << header.fec_group << " }\n";
293 return os; 294 return os;
294 } 295 }
295 296
296 bool IsAwaitingPacket(const QuicAckFrame& ack_frame, 297 bool IsAwaitingPacket(const QuicAckFrame& ack_frame,
297 QuicPacketNumber packet_number, 298 QuicPacketNumber packet_number,
298 QuicPacketNumber peer_least_packet_awaiting_ack) { 299 QuicPacketNumber peer_least_packet_awaiting_ack) {
299 if (ack_frame.missing) { 300 if (ack_frame.missing) {
300 return packet_number > ack_frame.largest_observed || 301 return packet_number > ack_frame.largest_observed ||
301 ack_frame.packets.Contains(packet_number); 302 ack_frame.packets.Contains(packet_number);
302 } 303 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 QuicFrame::QuicFrame(QuicWindowUpdateFrame* frame) 371 QuicFrame::QuicFrame(QuicWindowUpdateFrame* frame)
371 : type(WINDOW_UPDATE_FRAME), window_update_frame(frame) {} 372 : type(WINDOW_UPDATE_FRAME), window_update_frame(frame) {}
372 373
373 QuicFrame::QuicFrame(QuicBlockedFrame* frame) 374 QuicFrame::QuicFrame(QuicBlockedFrame* frame)
374 : type(BLOCKED_FRAME), blocked_frame(frame) {} 375 : type(BLOCKED_FRAME), blocked_frame(frame) {}
375 376
376 QuicFrame::QuicFrame(QuicPathCloseFrame* frame) 377 QuicFrame::QuicFrame(QuicPathCloseFrame* frame)
377 : type(PATH_CLOSE_FRAME), path_close_frame(frame) {} 378 : type(PATH_CLOSE_FRAME), path_close_frame(frame) {}
378 379
379 ostream& operator<<(ostream& os, const QuicStopWaitingFrame& sent_info) { 380 ostream& operator<<(ostream& os, const QuicStopWaitingFrame& sent_info) {
380 os << "entropy_hash: " << static_cast<int>(sent_info.entropy_hash) 381 os << "{ entropy_hash: " << static_cast<int>(sent_info.entropy_hash)
381 << " least_unacked: " << sent_info.least_unacked << "\n"; 382 << ", least_unacked: " << sent_info.least_unacked << " }\n";
382 return os; 383 return os;
383 } 384 }
384 385
385 PacketNumberQueue::const_iterator::const_iterator( 386 PacketNumberQueue::const_iterator::const_iterator(
386 IntervalSet<QuicPacketNumber>::const_iterator interval_set_iter, 387 IntervalSet<QuicPacketNumber>::const_iterator interval_set_iter,
387 QuicPacketNumber first, 388 QuicPacketNumber first,
388 QuicPacketNumber last) 389 QuicPacketNumber last)
389 : interval_set_iter_(std::move(interval_set_iter)), 390 : interval_set_iter_(std::move(interval_set_iter)),
390 current_(first), 391 current_(first),
391 last_(last) {} 392 last_(last) {}
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 554 }
554 555
555 ostream& operator<<(ostream& os, const PacketNumberQueue& q) { 556 ostream& operator<<(ostream& os, const PacketNumberQueue& q) {
556 for (QuicPacketNumber packet_number : q) { 557 for (QuicPacketNumber packet_number : q) {
557 os << packet_number << " "; 558 os << packet_number << " ";
558 } 559 }
559 return os; 560 return os;
560 } 561 }
561 562
562 ostream& operator<<(ostream& os, const QuicAckFrame& ack_frame) { 563 ostream& operator<<(ostream& os, const QuicAckFrame& ack_frame) {
563 os << "entropy_hash: " << static_cast<int>(ack_frame.entropy_hash) 564 os << "{ entropy_hash: " << static_cast<int>(ack_frame.entropy_hash)
564 << " largest_observed: " << ack_frame.largest_observed 565 << ", largest_observed: " << ack_frame.largest_observed
565 << " ack_delay_time: " << ack_frame.ack_delay_time.ToMicroseconds() 566 << ", ack_delay_time: " << ack_frame.ack_delay_time.ToMicroseconds()
566 << " packets: [ " << ack_frame.packets 567 << ", packets: [ " << ack_frame.packets << " ]"
567 << " ] is_truncated: " << ack_frame.is_truncated 568 << ", is_truncated: " << ack_frame.is_truncated
568 << " received_packets: [ "; 569 << ", received_packets: [ ";
569 for (const std::pair<QuicPacketNumber, QuicTime>& p : 570 for (const std::pair<QuicPacketNumber, QuicTime>& p :
570 ack_frame.received_packet_times) { 571 ack_frame.received_packet_times) {
571 os << p.first << " at " << p.second.ToDebuggingValue() << " "; 572 os << p.first << " at " << p.second.ToDebuggingValue() << " ";
572 } 573 }
573 os << " ]\n"; 574 os << " ] }\n";
574 return os; 575 return os;
575 } 576 }
576 577
577 ostream& operator<<(ostream& os, const QuicFrame& frame) { 578 ostream& operator<<(ostream& os, const QuicFrame& frame) {
578 switch (frame.type) { 579 switch (frame.type) {
579 case PADDING_FRAME: { 580 case PADDING_FRAME: {
580 os << "type { PADDING_FRAME } "; 581 os << "type { PADDING_FRAME } " << frame.padding_frame;
581 break; 582 break;
582 } 583 }
583 case RST_STREAM_FRAME: { 584 case RST_STREAM_FRAME: {
584 os << "type { RST_STREAM_FRAME } " << *(frame.rst_stream_frame); 585 os << "type { RST_STREAM_FRAME } " << *(frame.rst_stream_frame);
585 break; 586 break;
586 } 587 }
587 case CONNECTION_CLOSE_FRAME: { 588 case CONNECTION_CLOSE_FRAME: {
588 os << "type { CONNECTION_CLOSE_FRAME } " 589 os << "type { CONNECTION_CLOSE_FRAME } "
589 << *(frame.connection_close_frame); 590 << *(frame.connection_close_frame);
590 break; 591 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 break; 627 break;
627 } 628 }
628 default: { 629 default: {
629 LOG(ERROR) << "Unknown frame type: " << frame.type; 630 LOG(ERROR) << "Unknown frame type: " << frame.type;
630 break; 631 break;
631 } 632 }
632 } 633 }
633 return os; 634 return os;
634 } 635 }
635 636
637 ostream& operator<<(ostream& os, const QuicPaddingFrame& padding_frame) {
638 os << "{ num_padding_bytes: " << padding_frame.num_padding_bytes << " }\n";
639 return os;
640 }
641
636 ostream& operator<<(ostream& os, const QuicRstStreamFrame& rst_frame) { 642 ostream& operator<<(ostream& os, const QuicRstStreamFrame& rst_frame) {
637 os << "stream_id { " << rst_frame.stream_id << " } " 643 os << "{ stream_id: " << rst_frame.stream_id
638 << "error_code { " << rst_frame.error_code << " }\n"; 644 << ", error_code: " << rst_frame.error_code << " }\n";
639 return os; 645 return os;
640 } 646 }
641 647
642 ostream& operator<<(ostream& os, 648 ostream& operator<<(ostream& os,
643 const QuicConnectionCloseFrame& connection_close_frame) { 649 const QuicConnectionCloseFrame& connection_close_frame) {
644 os << "error_code { " << connection_close_frame.error_code << " } " 650 os << "{ error_code: " << connection_close_frame.error_code
645 << "error_details { " << connection_close_frame.error_details << " }\n"; 651 << ", error_details: '" << connection_close_frame.error_details << "' }\n";
646 return os; 652 return os;
647 } 653 }
648 654
649 ostream& operator<<(ostream& os, const QuicGoAwayFrame& goaway_frame) { 655 ostream& operator<<(ostream& os, const QuicGoAwayFrame& goaway_frame) {
650 os << "error_code { " << goaway_frame.error_code << " } " 656 os << "{ error_code: " << goaway_frame.error_code
651 << "last_good_stream_id { " << goaway_frame.last_good_stream_id << " } " 657 << ", last_good_stream_id: " << goaway_frame.last_good_stream_id
652 << "reason_phrase { " << goaway_frame.reason_phrase << " }\n"; 658 << ", reason_phrase: '" << goaway_frame.reason_phrase << "' }\n";
653 return os; 659 return os;
654 } 660 }
655 661
656 ostream& operator<<(ostream& os, 662 ostream& operator<<(ostream& os,
657 const QuicWindowUpdateFrame& window_update_frame) { 663 const QuicWindowUpdateFrame& window_update_frame) {
658 os << "stream_id { " << window_update_frame.stream_id << " } " 664 os << "{ stream_id: " << window_update_frame.stream_id
659 << "byte_offset { " << window_update_frame.byte_offset << " }\n"; 665 << ", byte_offset: " << window_update_frame.byte_offset << " }\n";
660 return os; 666 return os;
661 } 667 }
662 668
663 ostream& operator<<(ostream& os, const QuicBlockedFrame& blocked_frame) { 669 ostream& operator<<(ostream& os, const QuicBlockedFrame& blocked_frame) {
664 os << "stream_id { " << blocked_frame.stream_id << " }\n"; 670 os << "{ stream_id: " << blocked_frame.stream_id << " }\n";
665 return os; 671 return os;
666 } 672 }
667 673
668 ostream& operator<<(ostream& os, const QuicPathCloseFrame& path_close_frame) { 674 ostream& operator<<(ostream& os, const QuicPathCloseFrame& path_close_frame) {
669 os << "path_id { " << path_close_frame.path_id << " }\n"; 675 os << "{ path_id: " << static_cast<int>(path_close_frame.path_id) << " }\n";
670 return os; 676 return os;
671 } 677 }
672 678
673 ostream& operator<<(ostream& os, const QuicStreamFrame& stream_frame) { 679 ostream& operator<<(ostream& os, const QuicStreamFrame& stream_frame) {
674 os << "stream_id { " << stream_frame.stream_id << " } " 680 os << "{ stream_id: " << stream_frame.stream_id
675 << "fin { " << stream_frame.fin << " } " 681 << ", fin: " << stream_frame.fin << ", offset: " << stream_frame.offset
676 << "offset { " << stream_frame.offset << " } " 682 << ", length: " << stream_frame.data_length << " }\n";
677 << "length { " << stream_frame.data_length << " }\n";
678 return os; 683 return os;
679 } 684 }
680 685
681 QuicGoAwayFrame::QuicGoAwayFrame() 686 QuicGoAwayFrame::QuicGoAwayFrame()
682 : error_code(QUIC_NO_ERROR), last_good_stream_id(0) {} 687 : error_code(QUIC_NO_ERROR), last_good_stream_id(0) {}
683 688
684 QuicGoAwayFrame::QuicGoAwayFrame(QuicErrorCode error_code, 689 QuicGoAwayFrame::QuicGoAwayFrame(QuicErrorCode error_code,
685 QuicStreamId last_good_stream_id, 690 QuicStreamId last_good_stream_id,
686 const string& reason) 691 const string& reason)
687 : error_code(error_code), 692 : error_code(error_code),
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 is_unackable(false), 856 is_unackable(false),
852 has_crypto_handshake(has_crypto_handshake), 857 has_crypto_handshake(has_crypto_handshake),
853 num_padding_bytes(num_padding_bytes), 858 num_padding_bytes(num_padding_bytes),
854 retransmission(0) {} 859 retransmission(0) {}
855 860
856 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default; 861 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default;
857 862
858 TransmissionInfo::~TransmissionInfo() {} 863 TransmissionInfo::~TransmissionInfo() {}
859 864
860 } // namespace net 865 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.h ('k') | net/quic/quic_protocol_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698