| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/nqe/network_quality_estimator.h" | 5 #include "net/nqe/network_quality_estimator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile10.Unknown", 1); | 294 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile10.Unknown", 1); |
| 295 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile50.Unknown", 1); | 295 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile50.Unknown", 1); |
| 296 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile90.Unknown", 1); | 296 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile90.Unknown", 1); |
| 297 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile100.Unknown", 1); | 297 histogram_tester.ExpectTotalCount("NQE.RTT.Percentile100.Unknown", 1); |
| 298 | 298 |
| 299 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 0); | 299 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 0); |
| 300 | 300 |
| 301 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); | 301 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); |
| 302 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); | 302 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); |
| 303 | 303 |
| 304 // Verify that metrics are logged correctly on main-frame requests. |
| 305 histogram_tester.ExpectTotalCount("NQE.MainFrame.RTT.Percentile50.Unknown", |
| 306 1); |
| 307 histogram_tester.ExpectTotalCount( |
| 308 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", 0); |
| 309 histogram_tester.ExpectTotalCount("NQE.MainFrame.Kbps.Percentile50.Unknown", |
| 310 1); |
| 304 estimator.SimulateNetworkChangeTo( | 311 estimator.SimulateNetworkChangeTo( |
| 305 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, std::string()); | 312 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, std::string()); |
| 306 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); | 313 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); |
| 307 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); | 314 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); |
| 308 | 315 |
| 309 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); | 316 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); |
| 310 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); | 317 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); |
| 311 } | 318 } |
| 312 | 319 |
| 313 TEST(NetworkQualityEstimatorTest, StoreObservations) { | 320 TEST(NetworkQualityEstimatorTest, StoreObservations) { |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 context.set_http_network_session_params(std::move(params)); | 1388 context.set_http_network_session_params(std::move(params)); |
| 1382 context.Init(); | 1389 context.Init(); |
| 1383 | 1390 |
| 1384 EXPECT_EQ(0U, rtt_observer.observations().size()); | 1391 EXPECT_EQ(0U, rtt_observer.observations().size()); |
| 1385 base::TimeDelta rtt; | 1392 base::TimeDelta rtt; |
| 1386 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); | 1393 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); |
| 1387 EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); | 1394 EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); |
| 1388 | 1395 |
| 1389 // Send two requests. Verify that the completion of each request generates at | 1396 // Send two requests. Verify that the completion of each request generates at |
| 1390 // least one TCP RTT observation. | 1397 // least one TCP RTT observation. |
| 1391 for (size_t i = 0; i < 2; ++i) { | 1398 const size_t num_requests = 2; |
| 1399 for (size_t i = 0; i < num_requests; ++i) { |
| 1392 size_t before_count_tcp_rtt_observations = 0; | 1400 size_t before_count_tcp_rtt_observations = 0; |
| 1393 for (const auto& observation : rtt_observer.observations()) { | 1401 for (const auto& observation : rtt_observer.observations()) { |
| 1394 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) | 1402 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) |
| 1395 ++before_count_tcp_rtt_observations; | 1403 ++before_count_tcp_rtt_observations; |
| 1396 } | 1404 } |
| 1397 | 1405 |
| 1398 std::unique_ptr<URLRequest> request(context.CreateRequest( | 1406 std::unique_ptr<URLRequest> request(context.CreateRequest( |
| 1399 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); | 1407 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); |
| 1408 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); |
| 1400 request->Start(); | 1409 request->Start(); |
| 1401 base::RunLoop().Run(); | 1410 base::RunLoop().Run(); |
| 1402 | 1411 |
| 1403 size_t after_count_tcp_rtt_observations = 0; | 1412 size_t after_count_tcp_rtt_observations = 0; |
| 1404 for (const auto& observation : rtt_observer.observations()) { | 1413 for (const auto& observation : rtt_observer.observations()) { |
| 1405 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) | 1414 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) |
| 1406 ++after_count_tcp_rtt_observations; | 1415 ++after_count_tcp_rtt_observations; |
| 1407 } | 1416 } |
| 1408 // At least one notification should be received per socket performance | 1417 // At least one notification should be received per socket performance |
| 1409 // watcher. | 1418 // watcher. |
| 1410 EXPECT_LE(1U, after_count_tcp_rtt_observations - | 1419 EXPECT_LE(1U, after_count_tcp_rtt_observations - |
| 1411 before_count_tcp_rtt_observations) | 1420 before_count_tcp_rtt_observations) |
| 1412 << i; | 1421 << i; |
| 1413 } | 1422 } |
| 1414 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); | 1423 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); |
| 1415 EXPECT_TRUE(estimator.GetTransportRTTEstimate(&rtt)); | 1424 EXPECT_TRUE(estimator.GetTransportRTTEstimate(&rtt)); |
| 1416 | 1425 |
| 1417 estimator.SimulateNetworkChangeTo( | 1426 estimator.SimulateNetworkChangeTo( |
| 1418 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); | 1427 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); |
| 1419 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); | 1428 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); |
| 1420 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.Unknown", | 1429 histogram_tester.ExpectBucketCount("NQE.TransportRTT.Percentile50.Unknown", |
| 1421 rtt.InMilliseconds(), 1); | 1430 rtt.InMilliseconds(), 1); |
| 1422 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.Unknown", 1); | 1431 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile10.Unknown", 1); |
| 1423 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); | 1432 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile50.Unknown", 1); |
| 1424 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.Unknown", 1); | 1433 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile90.Unknown", 1); |
| 1425 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.Unknown", | 1434 histogram_tester.ExpectTotalCount("NQE.TransportRTT.Percentile100.Unknown", |
| 1426 1); | 1435 1); |
| 1436 |
| 1437 // Verify that metrics are logged correctly on main-frame requests. |
| 1438 histogram_tester.ExpectTotalCount( |
| 1439 "NQE.MainFrame.TransportRTT.Percentile50.Unknown", num_requests); |
| 1427 } | 1440 } |
| 1428 | 1441 |
| 1429 } // namespace net | 1442 } // namespace net |
| OLD | NEW |