| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_connection_logger.h" | 5 #include "net/quic/quic_connection_logger.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "net/base/net_log.h" | 11 #include "net/base/net_log.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 Value* NetLogQuicPacketCallback(const IPEndPoint* self_address, | 17 base::Value* NetLogQuicPacketCallback(const IPEndPoint* self_address, |
| 18 const IPEndPoint* peer_address, | 18 const IPEndPoint* peer_address, |
| 19 size_t packet_size, | 19 size_t packet_size, |
| 20 NetLog::LogLevel /* log_level */) { | 20 NetLog::LogLevel /* log_level */) { |
| 21 DictionaryValue* dict = new DictionaryValue(); | 21 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 22 dict->SetString("self_address", self_address->ToString()); | 22 dict->SetString("self_address", self_address->ToString()); |
| 23 dict->SetString("peer_address", peer_address->ToString()); | 23 dict->SetString("peer_address", peer_address->ToString()); |
| 24 dict->SetInteger("size", packet_size); | 24 dict->SetInteger("size", packet_size); |
| 25 return dict; | 25 return dict; |
| 26 } | 26 } |
| 27 | 27 |
| 28 Value* NetLogQuicPacketHeaderCallback(const QuicPacketHeader* header, | 28 base::Value* NetLogQuicPacketHeaderCallback(const QuicPacketHeader* header, |
| 29 NetLog::LogLevel /* log_level */) { | 29 NetLog::LogLevel /* log_level */) { |
| 30 DictionaryValue* dict = new DictionaryValue(); | 30 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 31 dict->SetString("guid", | 31 dict->SetString("guid", |
| 32 base::Uint64ToString(header->public_header.guid)); | 32 base::Uint64ToString(header->public_header.guid)); |
| 33 dict->SetInteger("reset_flag", header->public_header.reset_flag); | 33 dict->SetInteger("reset_flag", header->public_header.reset_flag); |
| 34 dict->SetInteger("version_flag", header->public_header.version_flag); | 34 dict->SetInteger("version_flag", header->public_header.version_flag); |
| 35 dict->SetString("packet_sequence_number", | 35 dict->SetString("packet_sequence_number", |
| 36 base::Uint64ToString(header->packet_sequence_number)); | 36 base::Uint64ToString(header->packet_sequence_number)); |
| 37 dict->SetInteger("entropy_flag", header->entropy_flag); | 37 dict->SetInteger("entropy_flag", header->entropy_flag); |
| 38 dict->SetInteger("fec_flag", header->fec_flag); | 38 dict->SetInteger("fec_flag", header->fec_flag); |
| 39 dict->SetInteger("fec_group", header->fec_group); | 39 dict->SetInteger("fec_group", header->fec_group); |
| 40 return dict; | 40 return dict; |
| 41 } | 41 } |
| 42 | 42 |
| 43 Value* NetLogQuicStreamFrameCallback(const QuicStreamFrame* frame, | 43 base::Value* NetLogQuicStreamFrameCallback(const QuicStreamFrame* frame, |
| 44 NetLog::LogLevel /* log_level */) { | 44 NetLog::LogLevel /* log_level */) { |
| 45 DictionaryValue* dict = new DictionaryValue(); | 45 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 46 dict->SetInteger("stream_id", frame->stream_id); | 46 dict->SetInteger("stream_id", frame->stream_id); |
| 47 dict->SetBoolean("fin", frame->fin); | 47 dict->SetBoolean("fin", frame->fin); |
| 48 dict->SetString("offset", base::Uint64ToString(frame->offset)); | 48 dict->SetString("offset", base::Uint64ToString(frame->offset)); |
| 49 dict->SetInteger("length", frame->data.length()); | 49 dict->SetInteger("length", frame->data.length()); |
| 50 return dict; | 50 return dict; |
| 51 } | 51 } |
| 52 | 52 |
| 53 Value* NetLogQuicAckFrameCallback(const QuicAckFrame* frame, | 53 base::Value* NetLogQuicAckFrameCallback(const QuicAckFrame* frame, |
| 54 NetLog::LogLevel /* log_level */) { | 54 NetLog::LogLevel /* log_level */) { |
| 55 DictionaryValue* dict = new DictionaryValue(); | 55 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 56 DictionaryValue* sent_info = new DictionaryValue(); | 56 base::DictionaryValue* sent_info = new base::DictionaryValue(); |
| 57 dict->Set("sent_info", sent_info); | 57 dict->Set("sent_info", sent_info); |
| 58 sent_info->SetString("least_unacked", | 58 sent_info->SetString("least_unacked", |
| 59 base::Uint64ToString(frame->sent_info.least_unacked)); | 59 base::Uint64ToString(frame->sent_info.least_unacked)); |
| 60 DictionaryValue* received_info = new DictionaryValue(); | 60 base::DictionaryValue* received_info = new base::DictionaryValue(); |
| 61 dict->Set("received_info", received_info); | 61 dict->Set("received_info", received_info); |
| 62 received_info->SetString( | 62 received_info->SetString( |
| 63 "largest_observed", | 63 "largest_observed", |
| 64 base::Uint64ToString(frame->received_info.largest_observed)); | 64 base::Uint64ToString(frame->received_info.largest_observed)); |
| 65 ListValue* missing = new ListValue(); | 65 base::ListValue* missing = new base::ListValue(); |
| 66 received_info->Set("missing_packets", missing); | 66 received_info->Set("missing_packets", missing); |
| 67 const SequenceNumberSet& missing_packets = | 67 const SequenceNumberSet& missing_packets = |
| 68 frame->received_info.missing_packets; | 68 frame->received_info.missing_packets; |
| 69 for (SequenceNumberSet::const_iterator it = missing_packets.begin(); | 69 for (SequenceNumberSet::const_iterator it = missing_packets.begin(); |
| 70 it != missing_packets.end(); ++it) { | 70 it != missing_packets.end(); ++it) { |
| 71 missing->Append(new base::StringValue(base::Uint64ToString(*it))); | 71 missing->Append(new base::StringValue(base::Uint64ToString(*it))); |
| 72 } | 72 } |
| 73 return dict; | 73 return dict; |
| 74 } | 74 } |
| 75 | 75 |
| 76 Value* NetLogQuicCongestionFeedbackFrameCallback( | 76 base::Value* NetLogQuicCongestionFeedbackFrameCallback( |
| 77 const QuicCongestionFeedbackFrame* frame, | 77 const QuicCongestionFeedbackFrame* frame, |
| 78 NetLog::LogLevel /* log_level */) { | 78 NetLog::LogLevel /* log_level */) { |
| 79 DictionaryValue* dict = new DictionaryValue(); | 79 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 80 switch (frame->type) { | 80 switch (frame->type) { |
| 81 case kInterArrival: { | 81 case kInterArrival: { |
| 82 dict->SetString("type", "InterArrival"); | 82 dict->SetString("type", "InterArrival"); |
| 83 dict->SetInteger("accumulated_number_of_lost_packets", | 83 dict->SetInteger("accumulated_number_of_lost_packets", |
| 84 frame->inter_arrival.accumulated_number_of_lost_packets); | 84 frame->inter_arrival.accumulated_number_of_lost_packets); |
| 85 ListValue* received = new ListValue(); | 85 base::ListValue* received = new base::ListValue(); |
| 86 dict->Set("received_packets", received); | 86 dict->Set("received_packets", received); |
| 87 for (TimeMap::const_iterator it = | 87 for (TimeMap::const_iterator it = |
| 88 frame->inter_arrival.received_packet_times.begin(); | 88 frame->inter_arrival.received_packet_times.begin(); |
| 89 it != frame->inter_arrival.received_packet_times.end(); ++it) { | 89 it != frame->inter_arrival.received_packet_times.end(); ++it) { |
| 90 std::string value = base::Uint64ToString(it->first) + "@" + | 90 std::string value = base::Uint64ToString(it->first) + "@" + |
| 91 base::Uint64ToString(it->second.ToDebuggingValue()); | 91 base::Uint64ToString(it->second.ToDebuggingValue()); |
| 92 received->Append(new base::StringValue(value)); | 92 received->Append(new base::StringValue(value)); |
| 93 } | 93 } |
| 94 break; | 94 break; |
| 95 } | 95 } |
| 96 case kFixRate: | 96 case kFixRate: |
| 97 dict->SetString("type", "FixRate"); | 97 dict->SetString("type", "FixRate"); |
| 98 dict->SetInteger("bitrate_in_bytes_per_second", | 98 dict->SetInteger("bitrate_in_bytes_per_second", |
| 99 frame->fix_rate.bitrate.ToBytesPerSecond()); | 99 frame->fix_rate.bitrate.ToBytesPerSecond()); |
| 100 break; | 100 break; |
| 101 case kTCP: | 101 case kTCP: |
| 102 dict->SetString("type", "TCP"); | 102 dict->SetString("type", "TCP"); |
| 103 dict->SetInteger("accumulated_number_of_lost_packets", | 103 dict->SetInteger("accumulated_number_of_lost_packets", |
| 104 frame->tcp.accumulated_number_of_lost_packets); | 104 frame->tcp.accumulated_number_of_lost_packets); |
| 105 dict->SetInteger("receive_window", frame->tcp.receive_window); | 105 dict->SetInteger("receive_window", frame->tcp.receive_window); |
| 106 break; | 106 break; |
| 107 } | 107 } |
| 108 | 108 |
| 109 return dict; | 109 return dict; |
| 110 } | 110 } |
| 111 | 111 |
| 112 Value* NetLogQuicRstStreamFrameCallback(const QuicRstStreamFrame* frame, | 112 base::Value* NetLogQuicRstStreamFrameCallback( |
| 113 NetLog::LogLevel /* log_level */) { | 113 const QuicRstStreamFrame* frame, |
| 114 DictionaryValue* dict = new DictionaryValue(); | 114 NetLog::LogLevel /* log_level */) { |
| 115 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 115 dict->SetInteger("stream_id", frame->stream_id); | 116 dict->SetInteger("stream_id", frame->stream_id); |
| 116 dict->SetInteger("error_code", frame->error_code); | 117 dict->SetInteger("error_code", frame->error_code); |
| 117 dict->SetString("details", frame->error_details); | 118 dict->SetString("details", frame->error_details); |
| 118 return dict; | 119 return dict; |
| 119 } | 120 } |
| 120 | 121 |
| 121 Value* NetLogQuicConnectionCloseFrameCallback( | 122 base::Value* NetLogQuicConnectionCloseFrameCallback( |
| 122 const QuicConnectionCloseFrame* frame, | 123 const QuicConnectionCloseFrame* frame, |
| 123 NetLog::LogLevel /* log_level */) { | 124 NetLog::LogLevel /* log_level */) { |
| 124 DictionaryValue* dict = new DictionaryValue(); | 125 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 125 dict->SetInteger("error_code", frame->error_code); | 126 dict->SetInteger("error_code", frame->error_code); |
| 126 dict->SetString("details", frame->error_details); | 127 dict->SetString("details", frame->error_details); |
| 127 return dict; | 128 return dict; |
| 128 } | 129 } |
| 129 | 130 |
| 130 } // namespace | 131 } // namespace |
| 131 | 132 |
| 132 QuicConnectionLogger::QuicConnectionLogger(const BoundNetLog& net_log) | 133 QuicConnectionLogger::QuicConnectionLogger(const BoundNetLog& net_log) |
| 133 : net_log_(net_log) { | 134 : net_log_(net_log) { |
| 134 } | 135 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 void QuicConnectionLogger::OnVersionNegotiationPacket( | 196 void QuicConnectionLogger::OnVersionNegotiationPacket( |
| 196 const QuicVersionNegotiationPacket& packet) { | 197 const QuicVersionNegotiationPacket& packet) { |
| 197 } | 198 } |
| 198 | 199 |
| 199 void QuicConnectionLogger::OnRevivedPacket( | 200 void QuicConnectionLogger::OnRevivedPacket( |
| 200 const QuicPacketHeader& revived_header, | 201 const QuicPacketHeader& revived_header, |
| 201 base::StringPiece payload) { | 202 base::StringPiece payload) { |
| 202 } | 203 } |
| 203 | 204 |
| 204 } // namespace net | 205 } // namespace net |
| OLD | NEW |