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" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
18 #include "net/cert/cert_verify_result.h" | |
19 #include "net/cert/x509_certificate.h" | |
20 #include "net/quic/crypto/crypto_handshake_message.h" | 18 #include "net/quic/crypto/crypto_handshake_message.h" |
21 #include "net/quic/crypto/crypto_protocol.h" | 19 #include "net/quic/crypto/crypto_protocol.h" |
22 #include "net/quic/quic_address_mismatch.h" | 20 #include "net/quic/quic_address_mismatch.h" |
23 #include "net/quic/quic_socket_address_coder.h" | 21 #include "net/quic/quic_socket_address_coder.h" |
24 | 22 |
25 using base::StringPiece; | 23 using base::StringPiece; |
26 using std::string; | 24 using std::string; |
27 | 25 |
28 namespace net { | 26 namespace net { |
29 | 27 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 base::Value* NetLogQuicOnConnectionClosedCallback( | 232 base::Value* NetLogQuicOnConnectionClosedCallback( |
235 QuicErrorCode error, | 233 QuicErrorCode error, |
236 bool from_peer, | 234 bool from_peer, |
237 NetLog::LogLevel /* log_level */) { | 235 NetLog::LogLevel /* log_level */) { |
238 base::DictionaryValue* dict = new base::DictionaryValue(); | 236 base::DictionaryValue* dict = new base::DictionaryValue(); |
239 dict->SetInteger("quic_error", error); | 237 dict->SetInteger("quic_error", error); |
240 dict->SetBoolean("from_peer", from_peer); | 238 dict->SetBoolean("from_peer", from_peer); |
241 return dict; | 239 return dict; |
242 } | 240 } |
243 | 241 |
244 base::Value* NetLogQuicCertificateVerifiedCallback( | |
245 scoped_refptr<X509Certificate> cert, | |
246 NetLog::LogLevel /* log_level */) { | |
247 // Only the subjects are logged so that we can investigate connection pooling. | |
248 // More fields could be logged in the future. | |
249 std::vector<std::string> dns_names; | |
250 cert->GetDNSNames(&dns_names); | |
251 base::DictionaryValue* dict = new base::DictionaryValue(); | |
252 base::ListValue* subjects = new base::ListValue(); | |
253 for (std::vector<std::string>::const_iterator it = dns_names.begin(); | |
254 it != dns_names.end(); it++) { | |
255 subjects->Append(new base::StringValue(*it)); | |
256 } | |
257 dict->Set("subjects", subjects); | |
258 return dict; | |
259 } | |
260 | |
261 void UpdatePacketGapSentHistogram(size_t num_consecutive_missing_packets) { | 242 void UpdatePacketGapSentHistogram(size_t num_consecutive_missing_packets) { |
262 UMA_HISTOGRAM_COUNTS("Net.QuicSession.PacketGapSent", | 243 UMA_HISTOGRAM_COUNTS("Net.QuicSession.PacketGapSent", |
263 num_consecutive_missing_packets); | 244 num_consecutive_missing_packets); |
264 } | 245 } |
265 | 246 |
266 void UpdatePublicResetAddressMismatchHistogram( | 247 void UpdatePublicResetAddressMismatchHistogram( |
267 const IPEndPoint& server_hello_address, | 248 const IPEndPoint& server_hello_address, |
268 const IPEndPoint& public_reset_address) { | 249 const IPEndPoint& public_reset_address) { |
269 int sample = GetAddressMismatch(server_hello_address, public_reset_address); | 250 int sample = GetAddressMismatch(server_hello_address, public_reset_address); |
270 // We are seemingly talking to an older server that does not support the | 251 // We are seemingly talking to an older server that does not support the |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 void QuicConnectionLogger::UpdateReceivedFrameCounts( | 665 void QuicConnectionLogger::UpdateReceivedFrameCounts( |
685 QuicStreamId stream_id, | 666 QuicStreamId stream_id, |
686 int num_frames_received, | 667 int num_frames_received, |
687 int num_duplicate_frames_received) { | 668 int num_duplicate_frames_received) { |
688 if (stream_id != kCryptoStreamId) { | 669 if (stream_id != kCryptoStreamId) { |
689 num_frames_received_ += num_frames_received; | 670 num_frames_received_ += num_frames_received; |
690 num_duplicate_frames_received_ += num_duplicate_frames_received; | 671 num_duplicate_frames_received_ += num_duplicate_frames_received; |
691 } | 672 } |
692 } | 673 } |
693 | 674 |
694 void QuicConnectionLogger::OnCertificateVerified( | |
695 const CertVerifyResult& result) { | |
696 net_log_.AddEvent( | |
697 NetLog::TYPE_QUIC_SESSION_CERTIFICATE_VERIFIED, | |
698 base::Bind(&NetLogQuicCertificateVerifiedCallback, result.verified_cert)); | |
699 } | |
700 | |
701 base::HistogramBase* QuicConnectionLogger::GetPacketSequenceNumberHistogram( | 675 base::HistogramBase* QuicConnectionLogger::GetPacketSequenceNumberHistogram( |
702 const char* statistic_name) const { | 676 const char* statistic_name) const { |
703 string prefix("Net.QuicSession.PacketReceived_"); | 677 string prefix("Net.QuicSession.PacketReceived_"); |
704 return base::LinearHistogram::FactoryGet( | 678 return base::LinearHistogram::FactoryGet( |
705 prefix + statistic_name + connection_description_, | 679 prefix + statistic_name + connection_description_, |
706 1, received_packets_.size(), received_packets_.size() + 1, | 680 1, received_packets_.size(), received_packets_.size() + 1, |
707 base::HistogramBase::kUmaTargetedHistogramFlag); | 681 base::HistogramBase::kUmaTargetedHistogramFlag); |
708 } | 682 } |
709 | 683 |
710 base::HistogramBase* QuicConnectionLogger::Get6PacketHistogram( | 684 base::HistogramBase* QuicConnectionLogger::Get6PacketHistogram( |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 continue; | 824 continue; |
851 } | 825 } |
852 // Record some overlapping patterns, to get a better picture, since this is | 826 // Record some overlapping patterns, to get a better picture, since this is |
853 // not very expensive. | 827 // not very expensive. |
854 if (i % 3 == 0) | 828 if (i % 3 == 0) |
855 six_packet_histogram->Add(recent_6_mask); | 829 six_packet_histogram->Add(recent_6_mask); |
856 } | 830 } |
857 } | 831 } |
858 | 832 |
859 } // namespace net | 833 } // namespace net |
OLD | NEW |