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

Side by Side Diff: net/nqe/network_quality_estimator_unittest.cc

Issue 2278823003: Change net::LOAD_MAIN_FRAME to net::LOAD_MAIN_FRAME_DEPRECATED to discourage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added deprecation flag to two recent tests. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « net/nqe/network_quality_estimator.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 117 }
118 118
119 // Runs one URL request to completion. 119 // Runs one URL request to completion.
120 void RunOneRequest() { 120 void RunOneRequest() {
121 TestDelegate test_delegate; 121 TestDelegate test_delegate;
122 TestURLRequestContext context(true); 122 TestURLRequestContext context(true);
123 context.set_network_quality_estimator(this); 123 context.set_network_quality_estimator(this);
124 context.Init(); 124 context.Init();
125 std::unique_ptr<URLRequest> request( 125 std::unique_ptr<URLRequest> request(
126 context.CreateRequest(GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 126 context.CreateRequest(GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
127 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 127 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
128 request->Start(); 128 request->Start();
129 base::RunLoop().Run(); 129 base::RunLoop().Run();
130 } 130 }
131 131
132 // Returns a GURL hosted at embedded test server. 132 // Returns a GURL hosted at embedded test server.
133 const GURL GetEchoURL() const { 133 const GURL GetEchoURL() const {
134 return embedded_test_server_.GetURL("/echo.html"); 134 return embedded_test_server_.GetURL("/echo.html");
135 } 135 }
136 136
137 void set_effective_connection_type(EffectiveConnectionType type) { 137 void set_effective_connection_type(EffectiveConnectionType type) {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); 418 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt));
419 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 419 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
420 420
421 TestDelegate test_delegate; 421 TestDelegate test_delegate;
422 TestURLRequestContext context(true); 422 TestURLRequestContext context(true);
423 context.set_network_quality_estimator(&estimator); 423 context.set_network_quality_estimator(&estimator);
424 context.Init(); 424 context.Init();
425 425
426 std::unique_ptr<URLRequest> request(context.CreateRequest( 426 std::unique_ptr<URLRequest> request(context.CreateRequest(
427 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 427 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
428 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 428 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
429 request->Start(); 429 request->Start();
430 base::RunLoop().Run(); 430 base::RunLoop().Run();
431 431
432 // Both RTT and downstream throughput should be updated. 432 // Both RTT and downstream throughput should be updated.
433 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); 433 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt));
434 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 434 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
435 EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt)); 435 EXPECT_FALSE(estimator.GetTransportRTTEstimate(&rtt));
436 436
437 // Check UMA histograms. 437 // Check UMA histograms.
438 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 0); 438 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 0);
439 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 0); 439 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 0);
440 histogram_tester.ExpectUniqueSample( 440 histogram_tester.ExpectUniqueSample(
441 "NQE.MainFrame.EffectiveConnectionType.Unknown", 441 "NQE.MainFrame.EffectiveConnectionType.Unknown",
442 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 442 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
443 443
444 std::unique_ptr<URLRequest> request2(context.CreateRequest( 444 std::unique_ptr<URLRequest> request2(context.CreateRequest(
445 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 445 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
446 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME); 446 request2->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
447 request2->Start(); 447 request2->Start();
448 base::RunLoop().Run(); 448 base::RunLoop().Run();
449 histogram_tester.ExpectTotalCount( 449 histogram_tester.ExpectTotalCount(
450 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2); 450 "NQE.MainFrame.EffectiveConnectionType.Unknown", 2);
451 451
452 estimator.SimulateNetworkChangeTo( 452 estimator.SimulateNetworkChangeTo(
453 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1"); 453 NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI, "test-1");
454 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable", 454 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable",
455 false, 2); 455 false, 2);
456 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); 456 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1);
(...skipping 25 matching lines...) Expand all
482 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable", 482 histogram_tester.ExpectUniqueSample("NQE.CachedNetworkQualityAvailable",
483 false, 3); 483 false, 3);
484 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1); 484 histogram_tester.ExpectTotalCount("NQE.PeakKbps.Unknown", 1);
485 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1); 485 histogram_tester.ExpectTotalCount("NQE.FastestRTT.Unknown", 1);
486 486
487 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt)); 487 EXPECT_FALSE(estimator.GetHttpRTTEstimate(&rtt));
488 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 488 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
489 489
490 std::unique_ptr<URLRequest> request3(context.CreateRequest( 490 std::unique_ptr<URLRequest> request3(context.CreateRequest(
491 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 491 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
492 request3->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME); 492 request3->SetLoadFlags(request2->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
493 request3->Start(); 493 request3->Start();
494 base::RunLoop().Run(); 494 base::RunLoop().Run();
495 histogram_tester.ExpectUniqueSample( 495 histogram_tester.ExpectUniqueSample(
496 "NQE.MainFrame.EffectiveConnectionType.WiFi", 496 "NQE.MainFrame.EffectiveConnectionType.WiFi",
497 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1); 497 EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 1);
498 498
499 estimator.SimulateNetworkChangeTo( 499 estimator.SimulateNetworkChangeTo(
500 NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN, "test"); 500 NetworkChangeNotifier::ConnectionType::CONNECTION_UNKNOWN, "test");
501 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", false, 501 histogram_tester.ExpectBucketCount("NQE.CachedNetworkQualityAvailable", false,
502 3); 502 3);
(...skipping 22 matching lines...) Expand all
525 TestURLRequestContext context(true); 525 TestURLRequestContext context(true);
526 context.set_network_quality_estimator(&estimator); 526 context.set_network_quality_estimator(&estimator);
527 context.Init(); 527 context.Init();
528 528
529 // Start two requests so that the network quality is added to cache store at 529 // Start two requests so that the network quality is added to cache store at
530 // the beginning of the second request from the network traffic observed from 530 // the beginning of the second request from the network traffic observed from
531 // the first request. 531 // the first request.
532 for (size_t i = 0; i < 2; ++i) { 532 for (size_t i = 0; i < 2; ++i) {
533 std::unique_ptr<URLRequest> request(context.CreateRequest( 533 std::unique_ptr<URLRequest> request(context.CreateRequest(
534 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 534 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
535 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 535 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
536 request->Start(); 536 request->Start();
537 base::RunLoop().Run(); 537 base::RunLoop().Run();
538 } 538 }
539 539
540 base::RunLoop().RunUntilIdle(); 540 base::RunLoop().RunUntilIdle();
541 541
542 // Both RTT and downstream throughput should be updated. 542 // Both RTT and downstream throughput should be updated.
543 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); 543 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt));
544 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 544 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
545 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 545 EXPECT_NE(EFFECTIVE_CONNECTION_TYPE_UNKNOWN,
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 int32_t kbps; 1533 int32_t kbps;
1534 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 1534 EXPECT_FALSE(estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
1535 1535
1536 TestDelegate test_delegate; 1536 TestDelegate test_delegate;
1537 TestURLRequestContext context(true); 1537 TestURLRequestContext context(true);
1538 context.set_network_quality_estimator(&estimator); 1538 context.set_network_quality_estimator(&estimator);
1539 context.Init(); 1539 context.Init();
1540 1540
1541 std::unique_ptr<URLRequest> request(context.CreateRequest( 1541 std::unique_ptr<URLRequest> request(context.CreateRequest(
1542 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1542 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1543 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1543 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1544 request->Start(); 1544 request->Start();
1545 base::RunLoop().Run(); 1545 base::RunLoop().Run();
1546 1546
1547 EXPECT_EQ(test.allow_small_localhost_requests, 1547 EXPECT_EQ(test.allow_small_localhost_requests,
1548 estimator.GetHttpRTTEstimate(&rtt)); 1548 estimator.GetHttpRTTEstimate(&rtt));
1549 EXPECT_EQ(test.allow_small_localhost_requests, 1549 EXPECT_EQ(test.allow_small_localhost_requests,
1550 estimator.GetDownlinkThroughputKbpsEstimate(&kbps)); 1550 estimator.GetDownlinkThroughputKbpsEstimate(&kbps));
1551 } 1551 }
1552 } 1552 }
1553 1553
(...skipping 16 matching lines...) Expand all
1570 context.set_network_quality_estimator(&estimator); 1570 context.set_network_quality_estimator(&estimator);
1571 context.Init(); 1571 context.Init();
1572 1572
1573 EXPECT_EQ(0U, observer.effective_connection_types().size()); 1573 EXPECT_EQ(0U, observer.effective_connection_types().size());
1574 1574
1575 estimator.set_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G); 1575 estimator.set_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G);
1576 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60)); 1576 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60));
1577 1577
1578 std::unique_ptr<URLRequest> request(context.CreateRequest( 1578 std::unique_ptr<URLRequest> request(context.CreateRequest(
1579 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1579 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1580 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1580 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1581 request->Start(); 1581 request->Start();
1582 base::RunLoop().Run(); 1582 base::RunLoop().Run();
1583 EXPECT_EQ(1U, observer.effective_connection_types().size()); 1583 EXPECT_EQ(1U, observer.effective_connection_types().size());
1584 histogram_tester.ExpectUniqueSample( 1584 histogram_tester.ExpectUniqueSample(
1585 "NQE.MainFrame.EffectiveConnectionType.Unknown", 1585 "NQE.MainFrame.EffectiveConnectionType.Unknown",
1586 EFFECTIVE_CONNECTION_TYPE_2G, 1); 1586 EFFECTIVE_CONNECTION_TYPE_2G, 1);
1587 1587
1588 // Next request should not trigger recomputation of effective connection type 1588 // Next request should not trigger recomputation of effective connection type
1589 // since there has been no change in the clock. 1589 // since there has been no change in the clock.
1590 std::unique_ptr<URLRequest> request2(context.CreateRequest( 1590 std::unique_ptr<URLRequest> request2(context.CreateRequest(
1591 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1591 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1592 request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1592 request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1593 request2->Start(); 1593 request2->Start();
1594 base::RunLoop().Run(); 1594 base::RunLoop().Run();
1595 EXPECT_EQ(1U, observer.effective_connection_types().size()); 1595 EXPECT_EQ(1U, observer.effective_connection_types().size());
1596 1596
1597 // Change in connection type should send out notification to the observers. 1597 // Change in connection type should send out notification to the observers.
1598 estimator.set_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_3G); 1598 estimator.set_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_3G);
1599 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI, 1599 estimator.SimulateNetworkChangeTo(NetworkChangeNotifier::CONNECTION_WIFI,
1600 "test"); 1600 "test");
1601 EXPECT_EQ(2U, observer.effective_connection_types().size()); 1601 EXPECT_EQ(2U, observer.effective_connection_types().size());
1602 1602
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 context.set_network_quality_estimator(&estimator); 1669 context.set_network_quality_estimator(&estimator);
1670 context.Init(); 1670 context.Init();
1671 1671
1672 EXPECT_EQ(0U, observer.effective_connection_types().size()); 1672 EXPECT_EQ(0U, observer.effective_connection_types().size());
1673 1673
1674 estimator.set_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G); 1674 estimator.set_effective_connection_type(EFFECTIVE_CONNECTION_TYPE_2G);
1675 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60)); 1675 tick_clock_ptr->Advance(base::TimeDelta::FromMinutes(60));
1676 1676
1677 std::unique_ptr<URLRequest> request(context.CreateRequest( 1677 std::unique_ptr<URLRequest> request(context.CreateRequest(
1678 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1678 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1679 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1679 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1680 request->Start(); 1680 request->Start();
1681 base::RunLoop().Run(); 1681 base::RunLoop().Run();
1682 EXPECT_EQ(1U, observer.effective_connection_types().size()); 1682 EXPECT_EQ(1U, observer.effective_connection_types().size());
1683 histogram_tester.ExpectUniqueSample( 1683 histogram_tester.ExpectUniqueSample(
1684 "NQE.MainFrame.EffectiveConnectionType.WiFi", 1684 "NQE.MainFrame.EffectiveConnectionType.WiFi",
1685 EFFECTIVE_CONNECTION_TYPE_2G, 1); 1685 EFFECTIVE_CONNECTION_TYPE_2G, 1);
1686 1686
1687 size_t expected_effective_connection_type_notifications = 1; 1687 size_t expected_effective_connection_type_notifications = 1;
1688 EXPECT_EQ(expected_effective_connection_type_notifications, 1688 EXPECT_EQ(expected_effective_connection_type_notifications,
1689 observer.effective_connection_types().size()); 1689 observer.effective_connection_types().size());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 TestURLRequestContext context(true); 1741 TestURLRequestContext context(true);
1742 context.set_network_quality_estimator(&estimator); 1742 context.set_network_quality_estimator(&estimator);
1743 context.Init(); 1743 context.Init();
1744 1744
1745 EXPECT_EQ(0U, rtt_observer.observations().size()); 1745 EXPECT_EQ(0U, rtt_observer.observations().size());
1746 EXPECT_EQ(0U, throughput_observer.observations().size()); 1746 EXPECT_EQ(0U, throughput_observer.observations().size());
1747 base::TimeTicks then = base::TimeTicks::Now(); 1747 base::TimeTicks then = base::TimeTicks::Now();
1748 1748
1749 std::unique_ptr<URLRequest> request(context.CreateRequest( 1749 std::unique_ptr<URLRequest> request(context.CreateRequest(
1750 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1750 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1751 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1751 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1752 request->Start(); 1752 request->Start();
1753 base::RunLoop().Run(); 1753 base::RunLoop().Run();
1754 1754
1755 std::unique_ptr<URLRequest> request2(context.CreateRequest( 1755 std::unique_ptr<URLRequest> request2(context.CreateRequest(
1756 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1756 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1757 request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1757 request2->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1758 request2->Start(); 1758 request2->Start();
1759 base::RunLoop().Run(); 1759 base::RunLoop().Run();
1760 1760
1761 // Both RTT and downstream throughput should be updated. 1761 // Both RTT and downstream throughput should be updated.
1762 base::TimeDelta rtt; 1762 base::TimeDelta rtt;
1763 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt)); 1763 EXPECT_TRUE(estimator.GetHttpRTTEstimate(&rtt));
1764 1764
1765 int32_t throughput; 1765 int32_t throughput;
1766 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&throughput)); 1766 EXPECT_TRUE(estimator.GetDownlinkThroughputKbpsEstimate(&throughput));
1767 1767
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 const size_t num_requests = 2; 1849 const size_t num_requests = 2;
1850 for (size_t i = 0; i < num_requests; ++i) { 1850 for (size_t i = 0; i < num_requests; ++i) {
1851 size_t before_count_tcp_rtt_observations = 0; 1851 size_t before_count_tcp_rtt_observations = 0;
1852 for (const auto& observation : rtt_observer.observations()) { 1852 for (const auto& observation : rtt_observer.observations()) {
1853 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) 1853 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)
1854 ++before_count_tcp_rtt_observations; 1854 ++before_count_tcp_rtt_observations;
1855 } 1855 }
1856 1856
1857 std::unique_ptr<URLRequest> request(context.CreateRequest( 1857 std::unique_ptr<URLRequest> request(context.CreateRequest(
1858 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1858 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1859 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1859 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1860 request->Start(); 1860 request->Start();
1861 base::RunLoop().Run(); 1861 base::RunLoop().Run();
1862 1862
1863 size_t after_count_tcp_rtt_observations = 0; 1863 size_t after_count_tcp_rtt_observations = 0;
1864 for (const auto& observation : rtt_observer.observations()) { 1864 for (const auto& observation : rtt_observer.observations()) {
1865 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP) 1865 if (observation.source == NETWORK_QUALITY_OBSERVATION_SOURCE_TCP)
1866 ++after_count_tcp_rtt_observations; 1866 ++after_count_tcp_rtt_observations;
1867 } 1867 }
1868 // At least one notification should be received per socket performance 1868 // At least one notification should be received per socket performance
1869 // watcher. 1869 // watcher.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 1979
1980 TestDelegate test_delegate; 1980 TestDelegate test_delegate;
1981 TestURLRequestContext context(true); 1981 TestURLRequestContext context(true);
1982 context.set_network_quality_estimator(&estimator); 1982 context.set_network_quality_estimator(&estimator);
1983 context.Init(); 1983 context.Init();
1984 1984
1985 // Start a main-frame request which should cause network quality estimator 1985 // Start a main-frame request which should cause network quality estimator
1986 // to record accuracy UMA. 1986 // to record accuracy UMA.
1987 std::unique_ptr<URLRequest> request(context.CreateRequest( 1987 std::unique_ptr<URLRequest> request(context.CreateRequest(
1988 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 1988 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
1989 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 1989 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
1990 request->Start(); 1990 request->Start();
1991 base::RunLoop().Run(); 1991 base::RunLoop().Run();
1992 1992
1993 if (accuracy_recording_delay != base::TimeDelta()) { 1993 if (accuracy_recording_delay != base::TimeDelta()) {
1994 tick_clock_ptr->Advance(accuracy_recording_delay); 1994 tick_clock_ptr->Advance(accuracy_recording_delay);
1995 1995
1996 // Sleep for some time to ensure that the delayed task is posted. 1996 // Sleep for some time to ensure that the delayed task is posted.
1997 base::PlatformThread::Sleep(accuracy_recording_delay * 2); 1997 base::PlatformThread::Sleep(accuracy_recording_delay * 2);
1998 base::RunLoop().RunUntilIdle(); 1998 base::RunLoop().RunUntilIdle();
1999 } 1999 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 2178
2179 TestDelegate test_delegate; 2179 TestDelegate test_delegate;
2180 TestURLRequestContext context(true); 2180 TestURLRequestContext context(true);
2181 context.set_network_quality_estimator(&estimator); 2181 context.set_network_quality_estimator(&estimator);
2182 context.Init(); 2182 context.Init();
2183 2183
2184 // Start a main-frame request that should cause network quality estimator to 2184 // Start a main-frame request that should cause network quality estimator to
2185 // record the network quality at the last main frame request. 2185 // record the network quality at the last main frame request.
2186 std::unique_ptr<URLRequest> request_1(context.CreateRequest( 2186 std::unique_ptr<URLRequest> request_1(context.CreateRequest(
2187 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 2187 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
2188 request_1->SetLoadFlags(request_1->load_flags() | LOAD_MAIN_FRAME); 2188 request_1->SetLoadFlags(request_1->load_flags() |
2189 LOAD_MAIN_FRAME_DEPRECATED);
2189 request_1->Start(); 2190 request_1->Start();
2190 base::RunLoop().Run(); 2191 base::RunLoop().Run();
2191 histogram_tester.ExpectTotalCount( 2192 histogram_tester.ExpectTotalCount(
2192 "NQE.Correlation.ResourceLoadTime.0Kb_128Kb", 0); 2193 "NQE.Correlation.ResourceLoadTime.0Kb_128Kb", 0);
2193 2194
2194 // Start another main-frame request which should cause network quality 2195 // Start another main-frame request which should cause network quality
2195 // estimator to record the correlation UMA. 2196 // estimator to record the correlation UMA.
2196 std::unique_ptr<URLRequest> request_2(context.CreateRequest( 2197 std::unique_ptr<URLRequest> request_2(context.CreateRequest(
2197 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 2198 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
2198 request_2->Start(); 2199 request_2->Start();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 2329
2329 TestDelegate test_delegate; 2330 TestDelegate test_delegate;
2330 TestURLRequestContext context(true); 2331 TestURLRequestContext context(true);
2331 context.set_network_quality_estimator(&estimator); 2332 context.set_network_quality_estimator(&estimator);
2332 context.Init(); 2333 context.Init();
2333 2334
2334 EXPECT_EQ(0U, observer.effective_connection_types().size()); 2335 EXPECT_EQ(0U, observer.effective_connection_types().size());
2335 2336
2336 std::unique_ptr<URLRequest> request(context.CreateRequest( 2337 std::unique_ptr<URLRequest> request(context.CreateRequest(
2337 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); 2338 estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate));
2338 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME); 2339 request->SetLoadFlags(request->load_flags() | LOAD_MAIN_FRAME_DEPRECATED);
2339 request->Start(); 2340 request->Start();
2340 base::RunLoop().Run(); 2341 base::RunLoop().Run();
2341 2342
2342 size_t expected_count = static_cast<EffectiveConnectionType>(i) == 2343 size_t expected_count = static_cast<EffectiveConnectionType>(i) ==
2343 EFFECTIVE_CONNECTION_TYPE_UNKNOWN 2344 EFFECTIVE_CONNECTION_TYPE_UNKNOWN
2344 ? 0 2345 ? 0
2345 : 1; 2346 : 1;
2346 ASSERT_EQ(expected_count, observer.effective_connection_types().size()); 2347 ASSERT_EQ(expected_count, observer.effective_connection_types().size());
2347 if (expected_count == 1) { 2348 if (expected_count == 1) {
2348 EffectiveConnectionType last_notified_type = 2349 EffectiveConnectionType last_notified_type =
2349 observer.effective_connection_types().at( 2350 observer.effective_connection_types().at(
2350 observer.effective_connection_types().size() - 1); 2351 observer.effective_connection_types().size() - 1);
2351 EXPECT_EQ(i, last_notified_type); 2352 EXPECT_EQ(i, last_notified_type);
2352 } 2353 }
2353 } 2354 }
2354 } 2355 }
2355 2356
2356 } // namespace net 2357 } // namespace net
OLDNEW
« no previous file with comments | « net/nqe/network_quality_estimator.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698