| 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/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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |