| 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/chromium/quic_connection_logger.h" | 5 #include "net/quic/chromium/quic_connection_logger.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 float num_received = largest_received_packet_number_ - num_packets_received_; | 680 float num_received = largest_received_packet_number_ - num_packets_received_; |
| 681 return num_received / largest_received_packet_number_; | 681 return num_received / largest_received_packet_number_; |
| 682 } | 682 } |
| 683 | 683 |
| 684 void QuicConnectionLogger::OnRttChanged(QuicTime::Delta rtt) const { | 684 void QuicConnectionLogger::OnRttChanged(QuicTime::Delta rtt) const { |
| 685 // Notify socket performance watcher of the updated RTT value. | 685 // Notify socket performance watcher of the updated RTT value. |
| 686 if (!socket_performance_watcher_) | 686 if (!socket_performance_watcher_) |
| 687 return; | 687 return; |
| 688 | 688 |
| 689 int64_t microseconds = rtt.ToMicroseconds(); | 689 int64_t microseconds = rtt.ToMicroseconds(); |
| 690 if (microseconds != 0) { | 690 if (microseconds != 0 && |
| 691 socket_performance_watcher_->ShouldNotifyUpdatedRTT()) { |
| 691 socket_performance_watcher_->OnUpdatedRTTAvailable( | 692 socket_performance_watcher_->OnUpdatedRTTAvailable( |
| 692 base::TimeDelta::FromMicroseconds(rtt.ToMicroseconds())); | 693 base::TimeDelta::FromMicroseconds(rtt.ToMicroseconds())); |
| 693 } | 694 } |
| 694 } | 695 } |
| 695 | 696 |
| 696 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { | 697 void QuicConnectionLogger::RecordAggregatePacketLossRate() const { |
| 697 // For short connections under 22 packets in length, we'll rely on the | 698 // For short connections under 22 packets in length, we'll rely on the |
| 698 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet | 699 // Net.QuicSession.21CumulativePacketsReceived_* histogram to indicate packet |
| 699 // loss rates. This way we avoid tremendously anomalous contributions to our | 700 // loss rates. This way we avoid tremendously anomalous contributions to our |
| 700 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise | 701 // histogram. (e.g., if we only got 5 packets, but lost 1, we'd otherwise |
| 701 // record a 20% loss in this histogram!). We may still get some strange data | 702 // record a 20% loss in this histogram!). We may still get some strange data |
| 702 // (1 loss in 22 is still high :-/). | 703 // (1 loss in 22 is still high :-/). |
| 703 if (largest_received_packet_number_ <= 21) | 704 if (largest_received_packet_number_ <= 21) |
| 704 return; | 705 return; |
| 705 | 706 |
| 706 string prefix("Net.QuicSession.PacketLossRate_"); | 707 string prefix("Net.QuicSession.PacketLossRate_"); |
| 707 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 708 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
| 708 prefix + connection_description_, 1, 1000, 75, | 709 prefix + connection_description_, 1, 1000, 75, |
| 709 base::HistogramBase::kUmaTargetedHistogramFlag); | 710 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 710 histogram->Add(static_cast<base::HistogramBase::Sample>( | 711 histogram->Add(static_cast<base::HistogramBase::Sample>( |
| 711 ReceivedPacketLossRate() * 1000)); | 712 ReceivedPacketLossRate() * 1000)); |
| 712 } | 713 } |
| 713 | 714 |
| 714 } // namespace net | 715 } // namespace net |
| OLD | NEW |