OLD | NEW |
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/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 EXPECT_TRUE(low_spdy->started()); | 337 EXPECT_TRUE(low_spdy->started()); |
338 | 338 |
339 scheduler()->OnWillInsertBody(kChildId, kRouteId); | 339 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
340 high.reset(); | 340 high.reset(); |
341 base::RunLoop().RunUntilIdle(); | 341 base::RunLoop().RunUntilIdle(); |
342 EXPECT_TRUE(low2->started()); | 342 EXPECT_TRUE(low2->started()); |
343 } | 343 } |
344 | 344 |
345 TEST_F(ResourceSchedulerTest, | 345 TEST_F(ResourceSchedulerTest, |
346 OneLowLoadsUntilBodyInsertedEvenSpdyWhenDelayable) { | 346 OneLowLoadsUntilBodyInsertedEvenSpdyWhenDelayable) { |
| 347 base::test::ScopedFeatureList scoped_feature_list; |
| 348 scoped_feature_list.InitFromCommandLine(kPrioritySupportedRequestsDelayable, |
| 349 ""); |
| 350 |
| 351 InitializeScheduler(); |
347 http_server_properties_.SetSupportsSpdy( | 352 http_server_properties_.SetSupportsSpdy( |
348 url::SchemeHostPort("https", "spdyhost", 443), true); | 353 url::SchemeHostPort("https", "spdyhost", 443), true); |
349 std::unique_ptr<TestRequest> high( | 354 std::unique_ptr<TestRequest> high( |
350 NewRequest("http://host/high", net::HIGHEST)); | 355 NewRequest("http://host/high", net::HIGHEST)); |
351 std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); | 356 std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); |
352 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); | 357 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); |
353 std::unique_ptr<TestRequest> low_spdy( | 358 std::unique_ptr<TestRequest> low_spdy( |
354 NewRequest("https://spdyhost/low", net::LOWEST)); | 359 NewRequest("https://spdyhost/low", net::LOWEST)); |
355 EXPECT_TRUE(high->started()); | 360 EXPECT_TRUE(high->started()); |
356 EXPECT_TRUE(low->started()); | 361 EXPECT_TRUE(low->started()); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 scheduler()->OnReceivedSpdyProxiedHttpResponse(kChildId, kRouteId); | 682 scheduler()->OnReceivedSpdyProxiedHttpResponse(kChildId, kRouteId); |
678 base::RunLoop().RunUntilIdle(); | 683 base::RunLoop().RunUntilIdle(); |
679 EXPECT_TRUE(request->started()); | 684 EXPECT_TRUE(request->started()); |
680 | 685 |
681 std::unique_ptr<TestRequest> after( | 686 std::unique_ptr<TestRequest> after( |
682 NewRequest("http://host/after", net::IDLE)); | 687 NewRequest("http://host/after", net::IDLE)); |
683 EXPECT_TRUE(after->started()); | 688 EXPECT_TRUE(after->started()); |
684 } | 689 } |
685 | 690 |
686 TEST_F(ResourceSchedulerTest, SpdyProxyDelayable) { | 691 TEST_F(ResourceSchedulerTest, SpdyProxyDelayable) { |
| 692 base::test::ScopedFeatureList scoped_feature_list; |
| 693 scoped_feature_list.InitFromCommandLine(kPrioritySupportedRequestsDelayable, |
| 694 ""); |
| 695 InitializeScheduler(); |
| 696 |
687 std::unique_ptr<TestRequest> high( | 697 std::unique_ptr<TestRequest> high( |
688 NewRequest("http://host/high", net::HIGHEST)); | 698 NewRequest("http://host/high", net::HIGHEST)); |
689 std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); | 699 std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST)); |
690 | 700 |
691 std::unique_ptr<TestRequest> request( | 701 std::unique_ptr<TestRequest> request( |
692 NewRequest("http://host/req", net::IDLE)); | 702 NewRequest("http://host/req", net::IDLE)); |
693 EXPECT_FALSE(request->started()); | 703 EXPECT_FALSE(request->started()); |
694 | 704 |
695 scheduler()->OnReceivedSpdyProxiedHttpResponse(kChildId, kRouteId); | 705 scheduler()->OnReceivedSpdyProxiedHttpResponse(kChildId, kRouteId); |
696 base::RunLoop().RunUntilIdle(); | 706 base::RunLoop().RunUntilIdle(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 EXPECT_TRUE(low2_spdy->started()); | 744 EXPECT_TRUE(low2_spdy->started()); |
735 http_server_properties_.SetSupportsSpdy( | 745 http_server_properties_.SetSupportsSpdy( |
736 url::SchemeHostPort("http", "spdyhost2", 8080), true); | 746 url::SchemeHostPort("http", "spdyhost2", 8080), true); |
737 ChangeRequestPriority(low2_spdy.get(), net::LOWEST); | 747 ChangeRequestPriority(low2_spdy.get(), net::LOWEST); |
738 base::RunLoop().RunUntilIdle(); | 748 base::RunLoop().RunUntilIdle(); |
739 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); | 749 std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST)); |
740 EXPECT_TRUE(low2->started()); | 750 EXPECT_TRUE(low2->started()); |
741 } | 751 } |
742 | 752 |
743 TEST_F(ResourceSchedulerTest, NewDelayableSpdyHostInDelayableRequests) { | 753 TEST_F(ResourceSchedulerTest, NewDelayableSpdyHostInDelayableRequests) { |
| 754 base::test::ScopedFeatureList scoped_feature_list; |
| 755 scoped_feature_list.InitFromCommandLine(kPrioritySupportedRequestsDelayable, |
| 756 ""); |
| 757 InitializeScheduler(); |
| 758 |
744 scheduler()->OnWillInsertBody(kChildId, kRouteId); | 759 scheduler()->OnWillInsertBody(kChildId, kRouteId); |
745 const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. | 760 const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc. |
746 | 761 |
747 std::unique_ptr<TestRequest> low1_spdy( | 762 std::unique_ptr<TestRequest> low1_spdy( |
748 NewRequest("http://spdyhost1:8080/low", net::LOWEST)); | 763 NewRequest("http://spdyhost1:8080/low", net::LOWEST)); |
749 // Cancel a request after we learn the server supports SPDY. | 764 // Cancel a request after we learn the server supports SPDY. |
750 ScopedVector<TestRequest> lows; | 765 ScopedVector<TestRequest> lows; |
751 for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) { | 766 for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) { |
752 string url = "http://host" + base::IntToString(i) + "/low"; | 767 string url = "http://host" + base::IntToString(i) + "/low"; |
753 lows.push_back(NewRequest(url.c_str(), net::LOWEST)); | 768 lows.push_back(NewRequest(url.c_str(), net::LOWEST)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 scheduler_->OnClientDeleted(kChildId2, kRouteId2); | 830 scheduler_->OnClientDeleted(kChildId2, kRouteId2); |
816 high.reset(); | 831 high.reset(); |
817 delayable_requests.clear(); | 832 delayable_requests.clear(); |
818 base::RunLoop().RunUntilIdle(); | 833 base::RunLoop().RunUntilIdle(); |
819 EXPECT_TRUE(lowest->started()); | 834 EXPECT_TRUE(lowest->started()); |
820 } | 835 } |
821 | 836 |
822 } // unnamed namespace | 837 } // unnamed namespace |
823 | 838 |
824 } // namespace content | 839 } // namespace content |
OLD | NEW |