Add histogram to record changes in the network quality
Add histogram to record how frequently network quality
is detected as meaningfully changed.
Also, add DCHECKs to verify that the RTTs and throughput
values are as unexpected.
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Bug: 798488
Change-Id: Ie0bbf1f691a002a9257bff4c089e9dc8d0156b86
Reviewed-on: https://chromium-review.googlesource.com/846285
Reviewed-by: Helen Li <[email protected]>
Reviewed-by: Robert Kaplow <[email protected]>
Reviewed-by: Doug Arnett <[email protected]>
Commit-Queue: Tarun Bansal <[email protected]>
Cr-Commit-Position: refs/heads/master@{#526898}
diff --git a/net/nqe/network_quality.cc b/net/nqe/network_quality.cc
index cff98ab..d9f23182 100644
--- a/net/nqe/network_quality.cc
+++ b/net/nqe/network_quality.cc
@@ -13,7 +13,10 @@
}
NetworkQuality::NetworkQuality()
- : NetworkQuality(InvalidRTT(), InvalidRTT(), INVALID_RTT_THROUGHPUT) {}
+ : NetworkQuality(InvalidRTT(), InvalidRTT(), INVALID_RTT_THROUGHPUT) {
+ VerifyValueCorrectness();
+ DETACH_FROM_SEQUENCE(sequence_checker_);
+}
NetworkQuality::NetworkQuality(const base::TimeDelta& http_rtt,
const base::TimeDelta& transport_rtt,
@@ -21,13 +24,17 @@
: http_rtt_(http_rtt),
transport_rtt_(transport_rtt),
downstream_throughput_kbps_(downstream_throughput_kbps) {
- DCHECK_GE(downstream_throughput_kbps_, INVALID_RTT_THROUGHPUT);
+ VerifyValueCorrectness();
+ DETACH_FROM_SEQUENCE(sequence_checker_);
}
NetworkQuality::NetworkQuality(const NetworkQuality& other)
: NetworkQuality(other.http_rtt_,
other.transport_rtt_,
- other.downstream_throughput_kbps_) {}
+ other.downstream_throughput_kbps_) {
+ VerifyValueCorrectness();
+ DETACH_FROM_SEQUENCE(sequence_checker_);
+}
NetworkQuality::~NetworkQuality() = default;
@@ -35,16 +42,20 @@
http_rtt_ = other.http_rtt_;
transport_rtt_ = other.transport_rtt_;
downstream_throughput_kbps_ = other.downstream_throughput_kbps_;
+ VerifyValueCorrectness();
+ DETACH_FROM_SEQUENCE(sequence_checker_);
return *this;
}
bool NetworkQuality::operator==(const NetworkQuality& other) const {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return http_rtt_ == other.http_rtt_ &&
transport_rtt_ == other.transport_rtt_ &&
downstream_throughput_kbps_ == other.downstream_throughput_kbps_;
}
bool NetworkQuality::IsFaster(const NetworkQuality& other) const {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return (http_rtt() == InvalidRTT() || other.http_rtt() == InvalidRTT() ||
http_rtt() <= other.http_rtt()) &&
(transport_rtt() == InvalidRTT() ||
@@ -55,6 +66,13 @@
downstream_throughput_kbps() >= other.downstream_throughput_kbps());
}
+void NetworkQuality::VerifyValueCorrectness() const {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK_LE(INVALID_RTT_THROUGHPUT, http_rtt_.InMilliseconds());
+ DCHECK_LE(INVALID_RTT_THROUGHPUT, transport_rtt_.InMilliseconds());
+ DCHECK_LE(INVALID_RTT_THROUGHPUT, downstream_throughput_kbps_);
+}
+
} // namespace internal
} // namespace nqe
} // namespace net