Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1306)

Unified Diff: net/quic/quic_network_transaction_unittest.cc

Issue 1672513002: Expose packet loss counts from QUIC to NetworkQualityEstimator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments, Rebased Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/quic/quic_network_transaction_unittest.cc
diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc
index b5a8d6d16a3e10182619ddc09ba06b534b9faa09..2c92442cf5eacc35f74613bd31645b2279ad522f 100644
--- a/net/quic/quic_network_transaction_unittest.cc
+++ b/net/quic/quic_network_transaction_unittest.cc
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stddef.h>
+#include <stdint.h>
+
#include <vector>
#include "base/compiler_specific.h"
@@ -10,6 +13,7 @@
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
+#include "base/time/time.h"
#include "net/base/chunked_upload_data_stream.h"
#include "net/base/network_quality_estimator.h"
#include "net/base/socket_performance_watcher.h"
@@ -182,6 +186,30 @@ class TestRTTObserver : public NetworkQualityEstimator::RTTObserver {
bool rtt_notification_received_;
};
+class TestPacketLossObserver
+ : public NetworkQualityEstimator::PacketLossObserver {
+ public:
+ TestPacketLossObserver() : notification_received_(false) {}
+
+ bool notification_received() const { return notification_received_; }
+
+ // NetworkQualityEstimator::PacketLossObserver implementation:
+ void OnPacketLossObservation(
+ size_t packets_lost,
+ size_t packets_received_in_order,
+ size_t packets_received_out_of_order,
+ const base::TimeTicks& timestamp,
+ net::NetworkQualityEstimator::ObservationSource source) override {
+ if (source != NetworkQualityEstimator::QUIC) {
+ NOTIMPLEMENTED();
+ }
+ notification_received_ = true;
+ }
+
+ private:
+ bool notification_received_;
+};
+
class QuicNetworkTransactionTest
: public PlatformTest,
public ::testing::WithParamInterface<QuicVersion> {
@@ -437,6 +465,8 @@ class QuicNetworkTransactionTest
}
test_network_quality_estimator_->AddRTTObserver(&rtt_observer_);
+ test_network_quality_estimator_->AddPacketLossObserver(
+ &packet_loss_observer_);
session_.reset(new HttpNetworkSession(params_));
session_->quic_stream_factory()->set_require_confirmation(false);
@@ -571,6 +601,7 @@ class QuicNetworkTransactionTest
scoped_ptr<CTVerifier> cert_transparency_verifier_;
scoped_ptr<TestNetworkQualityEstimator> test_network_quality_estimator_;
TestRTTObserver rtt_observer_;
+ TestPacketLossObserver packet_loss_observer_;
scoped_refptr<SSLConfigServiceDefaults> ssl_config_service_;
scoped_ptr<ProxyService> proxy_service_;
scoped_ptr<HttpAuthHandlerFactory> auth_handler_factory_;
@@ -631,8 +662,10 @@ TEST_P(QuicNetworkTransactionTest, ForceQuic) {
CreateSession();
EXPECT_FALSE(rtt_observer_.rtt_notification_received());
+ EXPECT_FALSE(packet_loss_observer_.notification_received());
SendRequestAndExpectQuicResponse("hello!");
EXPECT_TRUE(rtt_observer_.rtt_notification_received());
+ EXPECT_TRUE(packet_loss_observer_.notification_received());
// Check that the NetLog was filled reasonably.
TestNetLogEntry::List entries;
@@ -693,6 +726,7 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
mock_quic_data.AddSocketDataToFactory(&socket_factory_);
EXPECT_FALSE(rtt_observer_.rtt_notification_received());
+ EXPECT_FALSE(packet_loss_observer_.notification_received());
// There is no need to set up an alternate protocol job, because
// no attempt will be made to speak to the proxy over TCP.
@@ -703,6 +737,7 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70);
EXPECT_TRUE(rtt_observer_.rtt_notification_received());
+ EXPECT_TRUE(packet_loss_observer_.notification_received());
}
// Regression test for https://crbug.com/492458. Test that for an HTTP
@@ -2301,6 +2336,7 @@ TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) {
TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
maker_.set_hostname("www.example.org");
EXPECT_FALSE(rtt_observer_.rtt_notification_received());
+ EXPECT_FALSE(packet_loss_observer_.notification_received());
MockQuicData mock_quic_data;
mock_quic_data.AddWrite(
ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
@@ -2319,6 +2355,7 @@ TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE);
SendRequestAndExpectQuicResponse("hello!");
EXPECT_TRUE(rtt_observer_.rtt_notification_received());
+ EXPECT_TRUE(packet_loss_observer_.notification_received());
}
TEST_P(QuicNetworkTransactionTest, QuicUpload) {

Powered by Google App Engine
This is Rietveld 408576698