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

Side by Side Diff: content/browser/loader/resource_scheduler_unittest.cc

Issue 1904483004: Change SupportsSpdy dict, SpdySettingsMap, ServerNetworkStatsMap, AlternativeServiceMap and disk da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format net Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/loader/resource_scheduler.h" 5 #include "content/browser/loader/resource_scheduler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 EXPECT_TRUE(lowest->started()); 330 EXPECT_TRUE(lowest->started());
331 EXPECT_FALSE(lowest2->started()); 331 EXPECT_FALSE(lowest2->started());
332 332
333 scheduler()->OnWillInsertBody(kChildId, kRouteId); 333 scheduler()->OnWillInsertBody(kChildId, kRouteId);
334 base::RunLoop().RunUntilIdle(); 334 base::RunLoop().RunUntilIdle();
335 EXPECT_TRUE(lowest2->started()); 335 EXPECT_TRUE(lowest2->started());
336 } 336 }
337 337
338 TEST_F(ResourceSchedulerTest, OneLowLoadsUntilBodyInsertedExceptSpdy) { 338 TEST_F(ResourceSchedulerTest, OneLowLoadsUntilBodyInsertedExceptSpdy) {
339 http_server_properties_.SetSupportsSpdy( 339 http_server_properties_.SetSupportsSpdy(
340 net::HostPortPair("spdyhost", 443), true); 340 url::SchemeHostPort("https", "spdyhost", 443), true);
mmenke 2016/04/21 18:52:34 include url/scheme_host_port.h
Zhongyi Shi 2016/04/21 19:44:29 Done.
341 std::unique_ptr<TestRequest> high( 341 std::unique_ptr<TestRequest> high(
342 NewRequest("http://host/high", net::HIGHEST)); 342 NewRequest("http://host/high", net::HIGHEST));
343 std::unique_ptr<TestRequest> low_spdy( 343 std::unique_ptr<TestRequest> low_spdy(
344 NewRequest("https://spdyhost/low", net::LOWEST)); 344 NewRequest("https://spdyhost/low", net::LOWEST));
345 std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); 345 std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST));
346 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); 346 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST));
347 EXPECT_TRUE(high->started()); 347 EXPECT_TRUE(high->started());
348 EXPECT_TRUE(low_spdy->started()); 348 EXPECT_TRUE(low_spdy->started());
349 EXPECT_TRUE(low->started()); 349 EXPECT_TRUE(low->started());
350 EXPECT_FALSE(low2->started()); 350 EXPECT_FALSE(low2->started());
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 NewRequest("http://spdyhost1:8080/low", net::LOWEST)); 658 NewRequest("http://spdyhost1:8080/low", net::LOWEST));
659 // Cancel a request after we learn the server supports SPDY. 659 // Cancel a request after we learn the server supports SPDY.
660 ScopedVector<TestRequest> lows; 660 ScopedVector<TestRequest> lows;
661 for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) { 661 for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) {
662 string url = "http://host" + base::IntToString(i) + "/low"; 662 string url = "http://host" + base::IntToString(i) + "/low";
663 lows.push_back(NewRequest(url.c_str(), net::LOWEST)); 663 lows.push_back(NewRequest(url.c_str(), net::LOWEST));
664 } 664 }
665 std::unique_ptr<TestRequest> low1(NewRequest("http://host/low", net::LOWEST)); 665 std::unique_ptr<TestRequest> low1(NewRequest("http://host/low", net::LOWEST));
666 EXPECT_FALSE(low1->started()); 666 EXPECT_FALSE(low1->started());
667 http_server_properties_.SetSupportsSpdy( 667 http_server_properties_.SetSupportsSpdy(
668 net::HostPortPair("spdyhost1", 8080), true); 668 url::SchemeHostPort("http", "spdyhost1", 8080), true);
669 low1_spdy.reset(); 669 low1_spdy.reset();
670 base::RunLoop().RunUntilIdle(); 670 base::RunLoop().RunUntilIdle();
671 EXPECT_TRUE(low1->started()); 671 EXPECT_TRUE(low1->started());
672 672
673 low1.reset(); 673 low1.reset();
674 base::RunLoop().RunUntilIdle(); 674 base::RunLoop().RunUntilIdle();
675 std::unique_ptr<TestRequest> low2_spdy( 675 std::unique_ptr<TestRequest> low2_spdy(
676 NewRequest("http://spdyhost2:8080/low", net::IDLE)); 676 NewRequest("http://spdyhost2:8080/low", net::IDLE));
677 // Reprioritize a request after we learn the server supports SPDY. 677 // Reprioritize a request after we learn the server supports SPDY.
678 EXPECT_TRUE(low2_spdy->started()); 678 EXPECT_TRUE(low2_spdy->started());
679 http_server_properties_.SetSupportsSpdy( 679 http_server_properties_.SetSupportsSpdy(
680 net::HostPortPair("spdyhost2", 8080), true); 680 url::SchemeHostPort("http", "spdyhost2", 8080), true);
681 ChangeRequestPriority(low2_spdy.get(), net::LOWEST); 681 ChangeRequestPriority(low2_spdy.get(), net::LOWEST);
682 base::RunLoop().RunUntilIdle(); 682 base::RunLoop().RunUntilIdle();
683 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); 683 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST));
684 EXPECT_TRUE(low2->started()); 684 EXPECT_TRUE(low2->started());
685 } 685 }
686 686
687 TEST_F(ResourceSchedulerTest, OustandingRequestLimitEnforced) { 687 TEST_F(ResourceSchedulerTest, OustandingRequestLimitEnforced) {
688 const int kRequestLimit = 3; 688 const int kRequestLimit = 3;
689 ASSERT_TRUE(InitializeFieldTrials( 689 ASSERT_TRUE(InitializeFieldTrials(
690 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/", 690 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/",
(...skipping 18 matching lines...) Expand all
709 // that support request priority. 709 // that support request priority.
710 TEST_F(ResourceSchedulerTest, 710 TEST_F(ResourceSchedulerTest,
711 OutstandingRequestsLimitsEnforcedForRequestPriority) { 711 OutstandingRequestsLimitsEnforcedForRequestPriority) {
712 const int kRequestLimit = 3; 712 const int kRequestLimit = 3;
713 ASSERT_TRUE(InitializeFieldTrials( 713 ASSERT_TRUE(InitializeFieldTrials(
714 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/", 714 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/",
715 kRequestLimit))); 715 kRequestLimit)));
716 InitializeScheduler(); 716 InitializeScheduler();
717 717
718 http_server_properties_.SetSupportsSpdy( 718 http_server_properties_.SetSupportsSpdy(
719 net::HostPortPair("spdyhost", 443), true); 719 url::SchemeHostPort("https", "spdyhost", 443), true);
720 720
721 // Throw in requests up to the above limit; make sure they are started. 721 // Throw in requests up to the above limit; make sure they are started.
722 ScopedVector<TestRequest> requests; 722 ScopedVector<TestRequest> requests;
723 for (int i = 0; i < kRequestLimit; ++i) { 723 for (int i = 0; i < kRequestLimit; ++i) {
724 string url = "http://spdyhost/medium"; 724 string url = "http://spdyhost/medium";
725 requests.push_back(NewRequest(url.c_str(), net::MEDIUM)); 725 requests.push_back(NewRequest(url.c_str(), net::MEDIUM));
726 EXPECT_TRUE(requests[i]->started()); 726 EXPECT_TRUE(requests[i]->started());
727 } 727 }
728 728
729 // Confirm that another request will indeed fail. 729 // Confirm that another request will indeed fail.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 } 1168 }
1169 1169
1170 std::unique_ptr<TestRequest> last_different_host( 1170 std::unique_ptr<TestRequest> last_different_host(
1171 NewRequest("http://host_new/last", net::LOWEST)); 1171 NewRequest("http://host_new/last", net::LOWEST));
1172 EXPECT_FALSE(last_different_host->started()); 1172 EXPECT_FALSE(last_different_host->started());
1173 } 1173 }
1174 1174
1175 } // unnamed namespace 1175 } // unnamed namespace
1176 1176
1177 } // namespace content 1177 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698