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