| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // We have ranges-of-buckets in the cumulative histogram (covering 21 packet | 33 // We have ranges-of-buckets in the cumulative histogram (covering 21 packet |
| 34 // sequences) of length 2, 3, 4, ... 22. | 34 // sequences) of length 2, 3, 4, ... 22. |
| 35 // Hence the largest sample is bounded by the sum of those numbers. | 35 // Hence the largest sample is bounded by the sum of those numbers. |
| 36 const int kBoundingSampleInCumulativeHistogram = ((2 + 22) * 21) / 2; | 36 const int kBoundingSampleInCumulativeHistogram = ((2 + 22) * 21) / 2; |
| 37 | 37 |
| 38 base::Value* NetLogQuicPacketCallback(const IPEndPoint* self_address, | 38 base::Value* NetLogQuicPacketCallback(const IPEndPoint* self_address, |
| 39 const IPEndPoint* peer_address, | 39 const IPEndPoint* peer_address, |
| 40 size_t packet_size, | 40 size_t packet_size, |
| 41 NetLog::LogLevel /* log_level */) { | 41 NetLogCaptureMode /* capture_mode */) { |
| 42 base::DictionaryValue* dict = new base::DictionaryValue(); | 42 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 43 dict->SetString("self_address", self_address->ToString()); | 43 dict->SetString("self_address", self_address->ToString()); |
| 44 dict->SetString("peer_address", peer_address->ToString()); | 44 dict->SetString("peer_address", peer_address->ToString()); |
| 45 dict->SetInteger("size", packet_size); | 45 dict->SetInteger("size", packet_size); |
| 46 return dict; | 46 return dict; |
| 47 } | 47 } |
| 48 | 48 |
| 49 base::Value* NetLogQuicPacketSentCallback( | 49 base::Value* NetLogQuicPacketSentCallback( |
| 50 const SerializedPacket& serialized_packet, | 50 const SerializedPacket& serialized_packet, |
| 51 EncryptionLevel level, | 51 EncryptionLevel level, |
| 52 TransmissionType transmission_type, | 52 TransmissionType transmission_type, |
| 53 size_t packet_size, | 53 size_t packet_size, |
| 54 QuicTime sent_time, | 54 QuicTime sent_time, |
| 55 NetLog::LogLevel /* log_level */) { | 55 NetLogCaptureMode /* capture_mode */) { |
| 56 base::DictionaryValue* dict = new base::DictionaryValue(); | 56 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 57 dict->SetInteger("encryption_level", level); | 57 dict->SetInteger("encryption_level", level); |
| 58 dict->SetInteger("transmission_type", transmission_type); | 58 dict->SetInteger("transmission_type", transmission_type); |
| 59 dict->SetString("packet_sequence_number", | 59 dict->SetString("packet_sequence_number", |
| 60 base::Uint64ToString(serialized_packet.sequence_number)); | 60 base::Uint64ToString(serialized_packet.sequence_number)); |
| 61 dict->SetInteger("size", packet_size); | 61 dict->SetInteger("size", packet_size); |
| 62 dict->SetInteger("sent_time_us", | 62 dict->SetInteger("sent_time_us", |
| 63 static_cast<int>(sent_time.ToDebuggingValue())); | 63 static_cast<int>(sent_time.ToDebuggingValue())); |
| 64 return dict; | 64 return dict; |
| 65 } | 65 } |
| 66 | 66 |
| 67 base::Value* NetLogQuicPacketRetransmittedCallback( | 67 base::Value* NetLogQuicPacketRetransmittedCallback( |
| 68 QuicPacketSequenceNumber old_sequence_number, | 68 QuicPacketSequenceNumber old_sequence_number, |
| 69 QuicPacketSequenceNumber new_sequence_number, | 69 QuicPacketSequenceNumber new_sequence_number, |
| 70 NetLog::LogLevel /* log_level */) { | 70 NetLogCaptureMode /* capture_mode */) { |
| 71 base::DictionaryValue* dict = new base::DictionaryValue(); | 71 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 72 dict->SetString("old_packet_sequence_number", | 72 dict->SetString("old_packet_sequence_number", |
| 73 base::Uint64ToString(old_sequence_number)); | 73 base::Uint64ToString(old_sequence_number)); |
| 74 dict->SetString("new_packet_sequence_number", | 74 dict->SetString("new_packet_sequence_number", |
| 75 base::Uint64ToString(new_sequence_number)); | 75 base::Uint64ToString(new_sequence_number)); |
| 76 return dict; | 76 return dict; |
| 77 } | 77 } |
| 78 | 78 |
| 79 base::Value* NetLogQuicPacketHeaderCallback(const QuicPacketHeader* header, | 79 base::Value* NetLogQuicPacketHeaderCallback( |
| 80 NetLog::LogLevel /* log_level */) { | 80 const QuicPacketHeader* header, |
| 81 NetLogCaptureMode /* capture_mode */) { |
| 81 base::DictionaryValue* dict = new base::DictionaryValue(); | 82 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 82 dict->SetString("connection_id", | 83 dict->SetString("connection_id", |
| 83 base::Uint64ToString(header->public_header.connection_id)); | 84 base::Uint64ToString(header->public_header.connection_id)); |
| 84 dict->SetInteger("reset_flag", header->public_header.reset_flag); | 85 dict->SetInteger("reset_flag", header->public_header.reset_flag); |
| 85 dict->SetInteger("version_flag", header->public_header.version_flag); | 86 dict->SetInteger("version_flag", header->public_header.version_flag); |
| 86 dict->SetString("packet_sequence_number", | 87 dict->SetString("packet_sequence_number", |
| 87 base::Uint64ToString(header->packet_sequence_number)); | 88 base::Uint64ToString(header->packet_sequence_number)); |
| 88 dict->SetInteger("entropy_flag", header->entropy_flag); | 89 dict->SetInteger("entropy_flag", header->entropy_flag); |
| 89 dict->SetInteger("fec_flag", header->fec_flag); | 90 dict->SetInteger("fec_flag", header->fec_flag); |
| 90 dict->SetInteger("fec_group", static_cast<int>(header->fec_group)); | 91 dict->SetInteger("fec_group", static_cast<int>(header->fec_group)); |
| 91 return dict; | 92 return dict; |
| 92 } | 93 } |
| 93 | 94 |
| 94 base::Value* NetLogQuicStreamFrameCallback(const QuicStreamFrame* frame, | 95 base::Value* NetLogQuicStreamFrameCallback( |
| 95 NetLog::LogLevel /* log_level */) { | 96 const QuicStreamFrame* frame, |
| 97 NetLogCaptureMode /* capture_mode */) { |
| 96 base::DictionaryValue* dict = new base::DictionaryValue(); | 98 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 97 dict->SetInteger("stream_id", frame->stream_id); | 99 dict->SetInteger("stream_id", frame->stream_id); |
| 98 dict->SetBoolean("fin", frame->fin); | 100 dict->SetBoolean("fin", frame->fin); |
| 99 dict->SetString("offset", base::Uint64ToString(frame->offset)); | 101 dict->SetString("offset", base::Uint64ToString(frame->offset)); |
| 100 dict->SetInteger("length", frame->data.TotalBufferSize()); | 102 dict->SetInteger("length", frame->data.TotalBufferSize()); |
| 101 return dict; | 103 return dict; |
| 102 } | 104 } |
| 103 | 105 |
| 104 base::Value* NetLogQuicAckFrameCallback(const QuicAckFrame* frame, | 106 base::Value* NetLogQuicAckFrameCallback(const QuicAckFrame* frame, |
| 105 NetLog::LogLevel /* log_level */) { | 107 NetLogCaptureMode /* capture_mode */) { |
| 106 base::DictionaryValue* dict = new base::DictionaryValue(); | 108 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 107 dict->SetString("largest_observed", | 109 dict->SetString("largest_observed", |
| 108 base::Uint64ToString(frame->largest_observed)); | 110 base::Uint64ToString(frame->largest_observed)); |
| 109 dict->SetInteger( | 111 dict->SetInteger( |
| 110 "delta_time_largest_observed_us", | 112 "delta_time_largest_observed_us", |
| 111 static_cast<int>(frame->delta_time_largest_observed.ToMicroseconds())); | 113 static_cast<int>(frame->delta_time_largest_observed.ToMicroseconds())); |
| 112 dict->SetInteger("entropy_hash", | 114 dict->SetInteger("entropy_hash", |
| 113 frame->entropy_hash); | 115 frame->entropy_hash); |
| 114 dict->SetBoolean("truncated", frame->is_truncated); | 116 dict->SetBoolean("truncated", frame->is_truncated); |
| 115 | 117 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 139 info->SetInteger("received", | 141 info->SetInteger("received", |
| 140 static_cast<int>(it->second.ToDebuggingValue())); | 142 static_cast<int>(it->second.ToDebuggingValue())); |
| 141 received->Append(info); | 143 received->Append(info); |
| 142 } | 144 } |
| 143 | 145 |
| 144 return dict; | 146 return dict; |
| 145 } | 147 } |
| 146 | 148 |
| 147 base::Value* NetLogQuicRstStreamFrameCallback( | 149 base::Value* NetLogQuicRstStreamFrameCallback( |
| 148 const QuicRstStreamFrame* frame, | 150 const QuicRstStreamFrame* frame, |
| 149 NetLog::LogLevel /* log_level */) { | 151 NetLogCaptureMode /* capture_mode */) { |
| 150 base::DictionaryValue* dict = new base::DictionaryValue(); | 152 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 151 dict->SetInteger("stream_id", frame->stream_id); | 153 dict->SetInteger("stream_id", frame->stream_id); |
| 152 dict->SetInteger("quic_rst_stream_error", frame->error_code); | 154 dict->SetInteger("quic_rst_stream_error", frame->error_code); |
| 153 dict->SetString("details", frame->error_details); | 155 dict->SetString("details", frame->error_details); |
| 154 return dict; | 156 return dict; |
| 155 } | 157 } |
| 156 | 158 |
| 157 base::Value* NetLogQuicConnectionCloseFrameCallback( | 159 base::Value* NetLogQuicConnectionCloseFrameCallback( |
| 158 const QuicConnectionCloseFrame* frame, | 160 const QuicConnectionCloseFrame* frame, |
| 159 NetLog::LogLevel /* log_level */) { | 161 NetLogCaptureMode /* capture_mode */) { |
| 160 base::DictionaryValue* dict = new base::DictionaryValue(); | 162 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 161 dict->SetInteger("quic_error", frame->error_code); | 163 dict->SetInteger("quic_error", frame->error_code); |
| 162 dict->SetString("details", frame->error_details); | 164 dict->SetString("details", frame->error_details); |
| 163 return dict; | 165 return dict; |
| 164 } | 166 } |
| 165 | 167 |
| 166 base::Value* NetLogQuicWindowUpdateFrameCallback( | 168 base::Value* NetLogQuicWindowUpdateFrameCallback( |
| 167 const QuicWindowUpdateFrame* frame, | 169 const QuicWindowUpdateFrame* frame, |
| 168 NetLog::LogLevel /* log_level */) { | 170 NetLogCaptureMode /* capture_mode */) { |
| 169 base::DictionaryValue* dict = new base::DictionaryValue(); | 171 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 170 dict->SetInteger("stream_id", frame->stream_id); | 172 dict->SetInteger("stream_id", frame->stream_id); |
| 171 dict->SetString("byte_offset", base::Uint64ToString(frame->byte_offset)); | 173 dict->SetString("byte_offset", base::Uint64ToString(frame->byte_offset)); |
| 172 return dict; | 174 return dict; |
| 173 } | 175 } |
| 174 | 176 |
| 175 base::Value* NetLogQuicBlockedFrameCallback( | 177 base::Value* NetLogQuicBlockedFrameCallback( |
| 176 const QuicBlockedFrame* frame, | 178 const QuicBlockedFrame* frame, |
| 177 NetLog::LogLevel /* log_level */) { | 179 NetLogCaptureMode /* capture_mode */) { |
| 178 base::DictionaryValue* dict = new base::DictionaryValue(); | 180 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 179 dict->SetInteger("stream_id", frame->stream_id); | 181 dict->SetInteger("stream_id", frame->stream_id); |
| 180 return dict; | 182 return dict; |
| 181 } | 183 } |
| 182 | 184 |
| 183 base::Value* NetLogQuicGoAwayFrameCallback( | 185 base::Value* NetLogQuicGoAwayFrameCallback( |
| 184 const QuicGoAwayFrame* frame, | 186 const QuicGoAwayFrame* frame, |
| 185 NetLog::LogLevel /* log_level */) { | 187 NetLogCaptureMode /* capture_mode */) { |
| 186 base::DictionaryValue* dict = new base::DictionaryValue(); | 188 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 187 dict->SetInteger("quic_error", frame->error_code); | 189 dict->SetInteger("quic_error", frame->error_code); |
| 188 dict->SetInteger("last_good_stream_id", frame->last_good_stream_id); | 190 dict->SetInteger("last_good_stream_id", frame->last_good_stream_id); |
| 189 dict->SetString("reason_phrase", frame->reason_phrase); | 191 dict->SetString("reason_phrase", frame->reason_phrase); |
| 190 return dict; | 192 return dict; |
| 191 } | 193 } |
| 192 | 194 |
| 193 base::Value* NetLogQuicStopWaitingFrameCallback( | 195 base::Value* NetLogQuicStopWaitingFrameCallback( |
| 194 const QuicStopWaitingFrame* frame, | 196 const QuicStopWaitingFrame* frame, |
| 195 NetLog::LogLevel /* log_level */) { | 197 NetLogCaptureMode /* capture_mode */) { |
| 196 base::DictionaryValue* dict = new base::DictionaryValue(); | 198 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 197 base::DictionaryValue* sent_info = new base::DictionaryValue(); | 199 base::DictionaryValue* sent_info = new base::DictionaryValue(); |
| 198 dict->Set("sent_info", sent_info); | 200 dict->Set("sent_info", sent_info); |
| 199 sent_info->SetString("least_unacked", | 201 sent_info->SetString("least_unacked", |
| 200 base::Uint64ToString(frame->least_unacked)); | 202 base::Uint64ToString(frame->least_unacked)); |
| 201 return dict; | 203 return dict; |
| 202 } | 204 } |
| 203 | 205 |
| 204 base::Value* NetLogQuicVersionNegotiationPacketCallback( | 206 base::Value* NetLogQuicVersionNegotiationPacketCallback( |
| 205 const QuicVersionNegotiationPacket* packet, | 207 const QuicVersionNegotiationPacket* packet, |
| 206 NetLog::LogLevel /* log_level */) { | 208 NetLogCaptureMode /* capture_mode */) { |
| 207 base::DictionaryValue* dict = new base::DictionaryValue(); | 209 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 208 base::ListValue* versions = new base::ListValue(); | 210 base::ListValue* versions = new base::ListValue(); |
| 209 dict->Set("versions", versions); | 211 dict->Set("versions", versions); |
| 210 for (QuicVersionVector::const_iterator it = packet->versions.begin(); | 212 for (QuicVersionVector::const_iterator it = packet->versions.begin(); |
| 211 it != packet->versions.end(); ++it) { | 213 it != packet->versions.end(); ++it) { |
| 212 versions->AppendString(QuicVersionToString(*it)); | 214 versions->AppendString(QuicVersionToString(*it)); |
| 213 } | 215 } |
| 214 return dict; | 216 return dict; |
| 215 } | 217 } |
| 216 | 218 |
| 217 base::Value* NetLogQuicCryptoHandshakeMessageCallback( | 219 base::Value* NetLogQuicCryptoHandshakeMessageCallback( |
| 218 const CryptoHandshakeMessage* message, | 220 const CryptoHandshakeMessage* message, |
| 219 NetLog::LogLevel /* log_level */) { | 221 NetLogCaptureMode /* capture_mode */) { |
| 220 base::DictionaryValue* dict = new base::DictionaryValue(); | 222 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 221 dict->SetString("quic_crypto_handshake_message", message->DebugString()); | 223 dict->SetString("quic_crypto_handshake_message", message->DebugString()); |
| 222 return dict; | 224 return dict; |
| 223 } | 225 } |
| 224 | 226 |
| 225 base::Value* NetLogQuicOnConnectionClosedCallback( | 227 base::Value* NetLogQuicOnConnectionClosedCallback( |
| 226 QuicErrorCode error, | 228 QuicErrorCode error, |
| 227 bool from_peer, | 229 bool from_peer, |
| 228 NetLog::LogLevel /* log_level */) { | 230 NetLogCaptureMode /* capture_mode */) { |
| 229 base::DictionaryValue* dict = new base::DictionaryValue(); | 231 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 230 dict->SetInteger("quic_error", error); | 232 dict->SetInteger("quic_error", error); |
| 231 dict->SetBoolean("from_peer", from_peer); | 233 dict->SetBoolean("from_peer", from_peer); |
| 232 return dict; | 234 return dict; |
| 233 } | 235 } |
| 234 | 236 |
| 235 base::Value* NetLogQuicCertificateVerifiedCallback( | 237 base::Value* NetLogQuicCertificateVerifiedCallback( |
| 236 scoped_refptr<X509Certificate> cert, | 238 scoped_refptr<X509Certificate> cert, |
| 237 NetLog::LogLevel /* log_level */) { | 239 NetLogCaptureMode /* capture_mode */) { |
| 238 // Only the subjects are logged so that we can investigate connection pooling. | 240 // Only the subjects are logged so that we can investigate connection pooling. |
| 239 // More fields could be logged in the future. | 241 // More fields could be logged in the future. |
| 240 std::vector<std::string> dns_names; | 242 std::vector<std::string> dns_names; |
| 241 cert->GetDNSNames(&dns_names); | 243 cert->GetDNSNames(&dns_names); |
| 242 base::DictionaryValue* dict = new base::DictionaryValue(); | 244 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 243 base::ListValue* subjects = new base::ListValue(); | 245 base::ListValue* subjects = new base::ListValue(); |
| 244 for (std::vector<std::string>::const_iterator it = dns_names.begin(); | 246 for (std::vector<std::string>::const_iterator it = dns_names.begin(); |
| 245 it != dns_names.end(); it++) { | 247 it != dns_names.end(); it++) { |
| 246 subjects->Append(new base::StringValue(*it)); | 248 subjects->Append(new base::StringValue(*it)); |
| 247 } | 249 } |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 continue; | 862 continue; |
| 861 } | 863 } |
| 862 // Record some overlapping patterns, to get a better picture, since this is | 864 // Record some overlapping patterns, to get a better picture, since this is |
| 863 // not very expensive. | 865 // not very expensive. |
| 864 if (i % 3 == 0) | 866 if (i % 3 == 0) |
| 865 six_packet_histogram->Add(recent_6_mask); | 867 six_packet_histogram->Add(recent_6_mask); |
| 866 } | 868 } |
| 867 } | 869 } |
| 868 | 870 |
| 869 } // namespace net | 871 } // namespace net |
| OLD | NEW |