| 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 0a5ab02d4d141b75efb0b7cc6b0a8f44ced537bb..faf317525cadbffd8b7776560fe8bd74dd6220f7 100644
|
| --- a/net/quic/quic_network_transaction_unittest.cc
|
| +++ b/net/quic/quic_network_transaction_unittest.cc
|
| @@ -11,8 +11,9 @@
|
| #include "base/stl_util.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "net/base/chunked_upload_data_stream.h"
|
| -#include "net/base/network_quality_estimator.h"
|
| +#include "net/base/network_quality_estimator_watcher_factory.h"
|
| #include "net/base/socket_performance_watcher.h"
|
| +#include "net/base/socket_performance_watcher_factory.h"
|
| #include "net/base/test_completion_callback.h"
|
| #include "net/base/test_data_directory.h"
|
| #include "net/cert/mock_cert_verifier.h"
|
| @@ -139,47 +140,38 @@ class ProxyHeadersHandler {
|
| bool was_called_;
|
| };
|
|
|
| -class TestNetworkQualityEstimator : public NetworkQualityEstimator {
|
| +class TestSocketPerformanceWatcherFactory
|
| + : public SocketPerformanceWatcherFactory {
|
| public:
|
| - TestNetworkQualityEstimator()
|
| - : NetworkQualityEstimator(scoped_ptr<net::ExternalEstimateProvider>(),
|
| - std::map<std::string, std::string>()),
|
| - watcher_count_(0) {}
|
| -
|
| - ~TestNetworkQualityEstimator() override {}
|
| + TestSocketPerformanceWatcherFactory()
|
| + : watcher_count_(0u), rtt_notification_received_(false) {}
|
| + ~TestSocketPerformanceWatcherFactory() override {}
|
|
|
| + // SocketPerformanceWatcherFactory implementation:
|
| scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher(
|
| const Protocol protocol) override {
|
| if (protocol != PROTOCOL_QUIC) {
|
| - NOTIMPLEMENTED();
|
| + return nullptr;
|
| }
|
| ++watcher_count_;
|
| - return NetworkQualityEstimator::CreateSocketPerformanceWatcher(protocol);
|
| + return scoped_ptr<SocketPerformanceWatcher>(
|
| + new SocketPerformanceWatcher(protocol, this));
|
| + }
|
| + void OnUpdatedRTTAvailable(const Protocol protocol,
|
| + const base::TimeDelta& rtt) override {
|
| + rtt_notification_received_ = true;
|
| }
|
| + void OnWatcherReset() override {}
|
|
|
| size_t watcher_count() const { return watcher_count_; }
|
|
|
| - private:
|
| - size_t watcher_count_;
|
| - DISALLOW_COPY_AND_ASSIGN(TestNetworkQualityEstimator);
|
| -};
|
| -
|
| -class TestRTTObserver : public NetworkQualityEstimator::RTTObserver {
|
| - public:
|
| - TestRTTObserver() : rtt_notification_received_(false) {}
|
| -
|
| bool rtt_notification_received() const { return rtt_notification_received_; }
|
|
|
| - // NetworkQualityEstimator::RttObserver implementation:
|
| - void OnRTTObservation(
|
| - int32_t rtt_ms,
|
| - const base::TimeTicks& timestamp,
|
| - net::NetworkQualityEstimator::ObservationSource source) override {
|
| - rtt_notification_received_ = true;
|
| - }
|
| -
|
| private:
|
| + size_t watcher_count_;
|
| bool rtt_notification_received_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestSocketPerformanceWatcherFactory);
|
| };
|
|
|
| class QuicNetworkTransactionTest
|
| @@ -190,7 +182,6 @@ class QuicNetworkTransactionTest
|
| : clock_(new MockClock),
|
| maker_(GetParam(), 0, clock_, kDefaultServerHostName),
|
| cert_transparency_verifier_(new MultiLogCTVerifier()),
|
| - test_network_quality_estimator_(new TestNetworkQualityEstimator()),
|
| ssl_config_service_(new SSLConfigServiceDefaults),
|
| proxy_service_(ProxyService::CreateDirect()),
|
| auth_handler_factory_(
|
| @@ -442,7 +433,7 @@ class QuicNetworkTransactionTest
|
| params_.transport_security_state = &transport_security_state_;
|
| params_.cert_transparency_verifier = cert_transparency_verifier_.get();
|
| params_.socket_performance_watcher_factory =
|
| - test_network_quality_estimator_.get();
|
| + &test_socket_performance_watcher_factory_;
|
| params_.proxy_service = proxy_service_.get();
|
| params_.ssl_config_service = ssl_config_service_.get();
|
| params_.http_auth_handler_factory = auth_handler_factory_.get();
|
| @@ -455,8 +446,6 @@ class QuicNetworkTransactionTest
|
| params_.quic_host_whitelist.insert(host);
|
| }
|
|
|
| - test_network_quality_estimator_->AddRTTObserver(&rtt_observer_);
|
| -
|
| session_.reset(new HttpNetworkSession(params_));
|
| session_->quic_stream_factory()->set_require_confirmation(false);
|
| ASSERT_EQ(params_.quic_socket_receive_buffer_size,
|
| @@ -588,8 +577,7 @@ class QuicNetworkTransactionTest
|
| MockCertVerifier cert_verifier_;
|
| TransportSecurityState transport_security_state_;
|
| scoped_ptr<CTVerifier> cert_transparency_verifier_;
|
| - scoped_ptr<TestNetworkQualityEstimator> test_network_quality_estimator_;
|
| - TestRTTObserver rtt_observer_;
|
| + TestSocketPerformanceWatcherFactory test_socket_performance_watcher_factory_;
|
| scoped_refptr<SSLConfigServiceDefaults> ssl_config_service_;
|
| scoped_ptr<ProxyService> proxy_service_;
|
| scoped_ptr<HttpAuthHandlerFactory> auth_handler_factory_;
|
| @@ -649,9 +637,11 @@ TEST_P(QuicNetworkTransactionTest, ForceQuic) {
|
| params_.enable_alternative_service_with_different_host = false;
|
| CreateSession();
|
|
|
| - EXPECT_FALSE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_FALSE(
|
| + test_socket_performance_watcher_factory_.rtt_notification_received());
|
| SendRequestAndExpectQuicResponse("hello!");
|
| - EXPECT_TRUE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_TRUE(
|
| + test_socket_performance_watcher_factory_.rtt_notification_received());
|
|
|
| // Check that the NetLog was filled reasonably.
|
| TestNetLogEntry::List entries;
|
| @@ -711,7 +701,8 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
|
|
|
| mock_quic_data.AddSocketDataToFactory(&socket_factory_);
|
|
|
| - EXPECT_FALSE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_FALSE(
|
| + test_socket_performance_watcher_factory_.rtt_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.
|
|
|
| @@ -721,7 +712,8 @@ TEST_P(QuicNetworkTransactionTest, QuicProxy) {
|
| CreateSession();
|
|
|
| SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70);
|
| - EXPECT_TRUE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_TRUE(
|
| + test_socket_performance_watcher_factory_.rtt_notification_received());
|
| }
|
|
|
| // Regression test for https://crbug.com/492458. Test that for an HTTP
|
| @@ -831,7 +823,7 @@ TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) {
|
| params_.enable_alternative_service_with_different_host = false;
|
| CreateSession();
|
|
|
| - EXPECT_EQ(0U, test_network_quality_estimator_->watcher_count());
|
| + EXPECT_EQ(0U, test_socket_performance_watcher_factory_.watcher_count());
|
| for (size_t i = 0; i < 2; ++i) {
|
| scoped_ptr<HttpNetworkTransaction> trans(
|
| new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get()));
|
| @@ -839,7 +831,7 @@ TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) {
|
| int rv = trans->Start(&request_, callback.callback(), net_log_.bound());
|
| EXPECT_EQ(ERR_IO_PENDING, rv);
|
| EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult());
|
| - EXPECT_EQ(1 + i, test_network_quality_estimator_->watcher_count());
|
| + EXPECT_EQ(1 + i, test_socket_performance_watcher_factory_.watcher_count());
|
| }
|
| }
|
|
|
| @@ -863,7 +855,7 @@ TEST_P(QuicNetworkTransactionTest, DoNotForceQuicForHttps) {
|
| CreateSession();
|
|
|
| SendRequestAndExpectHttpResponse("hello world");
|
| - EXPECT_EQ(0U, test_network_quality_estimator_->watcher_count());
|
| + EXPECT_EQ(0U, test_socket_performance_watcher_factory_.watcher_count());
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, UseAlternativeServiceForQuic) {
|
| @@ -2292,7 +2284,8 @@ TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) {
|
|
|
| TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
|
| maker_.set_hostname("www.example.org");
|
| - EXPECT_FALSE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_FALSE(
|
| + test_socket_performance_watcher_factory_.rtt_notification_received());
|
| MockQuicData mock_quic_data;
|
| mock_quic_data.AddWrite(
|
| ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true,
|
| @@ -2310,7 +2303,8 @@ TEST_P(QuicNetworkTransactionTest, SecureResourceOverSecureQuic) {
|
| CreateSession();
|
| AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE);
|
| SendRequestAndExpectQuicResponse("hello!");
|
| - EXPECT_TRUE(rtt_observer_.rtt_notification_received());
|
| + EXPECT_TRUE(
|
| + test_socket_performance_watcher_factory_.rtt_notification_received());
|
| }
|
|
|
| TEST_P(QuicNetworkTransactionTest, QuicUpload) {
|
|
|