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

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

Issue 1824903002: Change the AlternativeServiceMap with SchemeOriginPair key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « content/browser/loader/resource_scheduler.cc ('k') | net/base/host_port_pair.h » ('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 (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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 EXPECT_TRUE(lowest->started()); 324 EXPECT_TRUE(lowest->started());
325 EXPECT_FALSE(lowest2->started()); 325 EXPECT_FALSE(lowest2->started());
326 326
327 scheduler()->OnWillInsertBody(kChildId, kRouteId); 327 scheduler()->OnWillInsertBody(kChildId, kRouteId);
328 base::RunLoop().RunUntilIdle(); 328 base::RunLoop().RunUntilIdle();
329 EXPECT_TRUE(lowest2->started()); 329 EXPECT_TRUE(lowest2->started());
330 } 330 }
331 331
332 TEST_F(ResourceSchedulerTest, OneLowLoadsUntilBodyInsertedExceptSpdy) { 332 TEST_F(ResourceSchedulerTest, OneLowLoadsUntilBodyInsertedExceptSpdy) {
333 http_server_properties_.SetSupportsSpdy( 333 http_server_properties_.SetSupportsSpdy(
334 net::HostPortPair("spdyhost", 443), true); 334 url::SchemeHostPort("https", "spdyhost", 443), true);
335 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST)); 335 scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST));
336 scoped_ptr<TestRequest> low_spdy( 336 scoped_ptr<TestRequest> low_spdy(
337 NewRequest("https://spdyhost/low", net::LOWEST)); 337 NewRequest("https://spdyhost/low", net::LOWEST));
338 scoped_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); 338 scoped_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST));
339 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); 339 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST));
340 EXPECT_TRUE(high->started()); 340 EXPECT_TRUE(high->started());
341 EXPECT_TRUE(low_spdy->started()); 341 EXPECT_TRUE(low_spdy->started());
342 EXPECT_TRUE(low->started()); 342 EXPECT_TRUE(low->started());
343 EXPECT_FALSE(low2->started()); 343 EXPECT_FALSE(low2->started());
344 344
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 NewRequest("http://spdyhost1:8080/low", net::LOWEST)); 629 NewRequest("http://spdyhost1:8080/low", net::LOWEST));
630 // Cancel a request after we learn the server supports SPDY. 630 // Cancel a request after we learn the server supports SPDY.
631 ScopedVector<TestRequest> lows; 631 ScopedVector<TestRequest> lows;
632 for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) { 632 for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) {
633 string url = "http://host" + base::IntToString(i) + "/low"; 633 string url = "http://host" + base::IntToString(i) + "/low";
634 lows.push_back(NewRequest(url.c_str(), net::LOWEST)); 634 lows.push_back(NewRequest(url.c_str(), net::LOWEST));
635 } 635 }
636 scoped_ptr<TestRequest> low1(NewRequest("http://host/low", net::LOWEST)); 636 scoped_ptr<TestRequest> low1(NewRequest("http://host/low", net::LOWEST));
637 EXPECT_FALSE(low1->started()); 637 EXPECT_FALSE(low1->started());
638 http_server_properties_.SetSupportsSpdy( 638 http_server_properties_.SetSupportsSpdy(
639 net::HostPortPair("spdyhost1", 8080), true); 639 url::SchemeHostPort("http", "spdyhost1", 8080), true);
640 low1_spdy.reset(); 640 low1_spdy.reset();
641 base::RunLoop().RunUntilIdle(); 641 base::RunLoop().RunUntilIdle();
642 EXPECT_TRUE(low1->started()); 642 EXPECT_TRUE(low1->started());
643 643
644 low1.reset(); 644 low1.reset();
645 base::RunLoop().RunUntilIdle(); 645 base::RunLoop().RunUntilIdle();
646 scoped_ptr<TestRequest> low2_spdy( 646 scoped_ptr<TestRequest> low2_spdy(
647 NewRequest("http://spdyhost2:8080/low", net::IDLE)); 647 NewRequest("http://spdyhost2:8080/low", net::IDLE));
648 // Reprioritize a request after we learn the server supports SPDY. 648 // Reprioritize a request after we learn the server supports SPDY.
649 EXPECT_TRUE(low2_spdy->started()); 649 EXPECT_TRUE(low2_spdy->started());
650 http_server_properties_.SetSupportsSpdy( 650 http_server_properties_.SetSupportsSpdy(
651 net::HostPortPair("spdyhost2", 8080), true); 651 url::SchemeHostPort("http", "spdyhost2", 8080), true);
652 ChangeRequestPriority(low2_spdy.get(), net::LOWEST); 652 ChangeRequestPriority(low2_spdy.get(), net::LOWEST);
653 base::RunLoop().RunUntilIdle(); 653 base::RunLoop().RunUntilIdle();
654 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); 654 scoped_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST));
655 EXPECT_TRUE(low2->started()); 655 EXPECT_TRUE(low2->started());
656 } 656 }
657 657
658 TEST_F(ResourceSchedulerTest, OustandingRequestLimitEnforced) { 658 TEST_F(ResourceSchedulerTest, OustandingRequestLimitEnforced) {
659 const int kRequestLimit = 3; 659 const int kRequestLimit = 3;
660 ASSERT_TRUE(InitializeFieldTrials( 660 ASSERT_TRUE(InitializeFieldTrials(
661 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/", 661 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/",
(...skipping 18 matching lines...) Expand all
680 // that support request priority. 680 // that support request priority.
681 TEST_F(ResourceSchedulerTest, 681 TEST_F(ResourceSchedulerTest,
682 OutstandingRequestsLimitsEnforcedForRequestPriority) { 682 OutstandingRequestsLimitsEnforcedForRequestPriority) {
683 const int kRequestLimit = 3; 683 const int kRequestLimit = 3;
684 ASSERT_TRUE(InitializeFieldTrials( 684 ASSERT_TRUE(InitializeFieldTrials(
685 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/", 685 base::StringPrintf("OutstandingRequestLimiting/Limit=%d/",
686 kRequestLimit))); 686 kRequestLimit)));
687 InitializeScheduler(); 687 InitializeScheduler();
688 688
689 http_server_properties_.SetSupportsSpdy( 689 http_server_properties_.SetSupportsSpdy(
690 net::HostPortPair("spdyhost", 443), true); 690 url::SchemeHostPort("https", "spdyhost", 443), true);
691 691
692 // Throw in requests up to the above limit; make sure they are started. 692 // Throw in requests up to the above limit; make sure they are started.
693 ScopedVector<TestRequest> requests; 693 ScopedVector<TestRequest> requests;
694 for (int i = 0; i < kRequestLimit; ++i) { 694 for (int i = 0; i < kRequestLimit; ++i) {
695 string url = "http://spdyhost/medium"; 695 string url = "http://spdyhost/medium";
696 requests.push_back(NewRequest(url.c_str(), net::MEDIUM)); 696 requests.push_back(NewRequest(url.c_str(), net::MEDIUM));
697 EXPECT_TRUE(requests[i]->started()); 697 EXPECT_TRUE(requests[i]->started());
698 } 698 }
699 699
700 // Confirm that another request will indeed fail. 700 // Confirm that another request will indeed fail.
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 } 1128 }
1129 1129
1130 scoped_ptr<TestRequest> last_different_host(NewRequest("http://host_new/last", 1130 scoped_ptr<TestRequest> last_different_host(NewRequest("http://host_new/last",
1131 net::LOWEST)); 1131 net::LOWEST));
1132 EXPECT_FALSE(last_different_host->started()); 1132 EXPECT_FALSE(last_different_host->started());
1133 } 1133 }
1134 1134
1135 } // unnamed namespace 1135 } // unnamed namespace
1136 1136
1137 } // namespace content 1137 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_scheduler.cc ('k') | net/base/host_port_pair.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698