| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 host_.OnRenderViewHostCreated(filter_->child_id(), 0); | 1866 host_.OnRenderViewHostCreated(filter_->child_id(), 0); |
| 1867 | 1867 |
| 1868 // One RenderView issues a high priority request and a low priority one. Both | 1868 // One RenderView issues a high priority request and a low priority one. Both |
| 1869 // should be started. | 1869 // should be started. |
| 1870 MakeTestRequestWithPriorityAndRenderFrame(0, 10, 1, net::HIGHEST); | 1870 MakeTestRequestWithPriorityAndRenderFrame(0, 10, 1, net::HIGHEST); |
| 1871 MakeTestRequestWithPriorityAndRenderFrame(0, 11, 2, net::LOWEST); | 1871 MakeTestRequestWithPriorityAndRenderFrame(0, 11, 2, net::LOWEST); |
| 1872 KickOffRequest(); | 1872 KickOffRequest(); |
| 1873 EXPECT_EQ(2, network_delegate_.created_requests()); | 1873 EXPECT_EQ(2, network_delegate_.created_requests()); |
| 1874 EXPECT_EQ(0, network_delegate_.canceled_requests()); | 1874 EXPECT_EQ(0, network_delegate_.canceled_requests()); |
| 1875 | 1875 |
| 1876 // The same RenderView issues two more low priority requests. The | 1876 // The same RenderView issues two more low priority requests. |
| 1877 // ResourceScheduler shouldn't let them start immediately. | |
| 1878 MakeTestRequestWithPriorityAndRenderFrame(0, 10, 3, net::LOWEST); | 1877 MakeTestRequestWithPriorityAndRenderFrame(0, 10, 3, net::LOWEST); |
| 1879 MakeTestRequestWithPriorityAndRenderFrame(0, 11, 4, net::LOWEST); | 1878 MakeTestRequestWithPriorityAndRenderFrame(0, 11, 4, net::LOWEST); |
| 1880 KickOffRequest(); | 1879 KickOffRequest(); |
| 1881 EXPECT_EQ(2, network_delegate_.created_requests()); | 1880 EXPECT_EQ(4, network_delegate_.created_requests()); |
| 1882 EXPECT_EQ(0, network_delegate_.canceled_requests()); | 1881 EXPECT_EQ(0, network_delegate_.canceled_requests()); |
| 1883 | 1882 |
| 1884 // Another RenderView in the same process as the old one issues a request, | 1883 // Another RenderView in the same process as the old one issues a request. |
| 1885 // which is then started. | |
| 1886 MakeTestRequestWithPriorityAndRenderFrame(1, 12, 5, net::LOWEST); | 1884 MakeTestRequestWithPriorityAndRenderFrame(1, 12, 5, net::LOWEST); |
| 1887 KickOffRequest(); | 1885 KickOffRequest(); |
| 1888 EXPECT_EQ(3, network_delegate_.created_requests()); | 1886 EXPECT_EQ(5, network_delegate_.created_requests()); |
| 1889 EXPECT_EQ(0, network_delegate_.canceled_requests()); | 1887 EXPECT_EQ(0, network_delegate_.canceled_requests()); |
| 1890 | 1888 |
| 1891 // The first two RenderFrameHosts are destroyed. All 4 of their requests | 1889 // The first two RenderFrameHosts are destroyed. All 4 of their requests |
| 1892 // should be cancelled, and none of the two deferred requests should be | 1890 // should be cancelled. |
| 1893 // started. | |
| 1894 DeleteRenderFrame(GlobalFrameRoutingId(filter_->child_id(), 10)); | 1891 DeleteRenderFrame(GlobalFrameRoutingId(filter_->child_id(), 10)); |
| 1895 DeleteRenderFrame(GlobalFrameRoutingId(filter_->child_id(), 11)); | 1892 DeleteRenderFrame(GlobalFrameRoutingId(filter_->child_id(), 11)); |
| 1896 host_.OnRenderViewHostDeleted(filter_->child_id(), 0); | 1893 host_.OnRenderViewHostDeleted(filter_->child_id(), 0); |
| 1897 base::RunLoop().RunUntilIdle(); | 1894 base::RunLoop().RunUntilIdle(); |
| 1898 EXPECT_EQ(3, network_delegate_.created_requests()); | 1895 EXPECT_EQ(5, network_delegate_.created_requests()); |
| 1899 EXPECT_EQ(4, network_delegate_.canceled_requests()); | 1896 EXPECT_EQ(4, network_delegate_.canceled_requests()); |
| 1900 | 1897 |
| 1901 // No messages should have been sent, since none of the jobs made any | 1898 // No messages should have been sent, since none of the jobs made any |
| 1902 // progress. | 1899 // progress. |
| 1903 ResourceIPCAccumulator::ClassifiedMessages msgs; | 1900 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 1904 accum_.GetClassifiedMessages(&msgs); | 1901 accum_.GetClassifiedMessages(&msgs); |
| 1905 EXPECT_EQ(0U, msgs.size()); | 1902 EXPECT_EQ(0U, msgs.size()); |
| 1906 } | 1903 } |
| 1907 | 1904 |
| 1908 TEST_P(ResourceDispatcherHostTest, TestProcessCancelDetachedTimesOut) { | 1905 TEST_P(ResourceDispatcherHostTest, TestProcessCancelDetachedTimesOut) { |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3552 HandleScheme("http"); | 3549 HandleScheme("http"); |
| 3553 | 3550 |
| 3554 // Needed to enable scheduling for this child. | 3551 // Needed to enable scheduling for this child. |
| 3555 host_.OnRenderViewHostCreated(filter_->child_id(), // child_id | 3552 host_.OnRenderViewHostCreated(filter_->child_id(), // child_id |
| 3556 0); // route_id | 3553 0); // route_id |
| 3557 | 3554 |
| 3558 // Prevent any of these requests from completing. | 3555 // Prevent any of these requests from completing. |
| 3559 job_factory_->SetDelayedCompleteJobGeneration(true); | 3556 job_factory_->SetDelayedCompleteJobGeneration(true); |
| 3560 SetResponse("HTTP/1.1 200 OK\n\n", "<title>Dummy body</title>"); | 3557 SetResponse("HTTP/1.1 200 OK\n\n", "<title>Dummy body</title>"); |
| 3561 | 3558 |
| 3562 // Only one idle priority request will run while a high-priority request | 3559 MakeTestRequestWithPriority(0, 1, net::IDLE); |
| 3563 // exists. | |
| 3564 MakeTestRequestWithPriority(0, 1, net::HIGHEST); | |
| 3565 MakeTestRequestWithPriority(0, 2, net::IDLE); | |
| 3566 MakeTestRequestWithPriority(0, 3, net::IDLE); | |
| 3567 | |
| 3568 KickOffRequest(); | 3560 KickOffRequest(); |
| 3569 | 3561 |
| 3570 EXPECT_EQ(2, job_factory_->url_request_jobs_created_count()); | 3562 ResourceLoader* loader = host_.GetLoader(filter_->child_id(), 1); |
| 3563 EXPECT_EQ(net::IDLE, loader->request()->priority()); |
| 3571 | 3564 |
| 3572 // Increase the priority of the second idle priority request. It was | 3565 // Increase the priority of the request. Actual scheduling logic is tested |
| 3573 // scheduled later, so it is not currently running. | 3566 // in the ResourceScheduler unit tests, this only tests that the message |
| 3574 ResourceHostMsg_DidChangePriority priority_msg(3, net::MAXIMUM_PRIORITY, 0); | 3567 // is delivered and the priority of the request is changed. |
| 3568 ResourceHostMsg_DidChangePriority priority_msg(1, net::MAXIMUM_PRIORITY, 0); |
| 3575 host_.OnMessageReceived(priority_msg, filter_.get()); | 3569 host_.OnMessageReceived(priority_msg, filter_.get()); |
| 3576 base::MessageLoop::current()->RunUntilIdle(); | 3570 base::MessageLoop::current()->RunUntilIdle(); |
| 3577 | 3571 |
| 3578 EXPECT_EQ(3, job_factory_->url_request_jobs_created_count()); | 3572 EXPECT_EQ(net::MAXIMUM_PRIORITY, loader->request()->priority()); |
| 3579 | 3573 |
| 3580 // Cleanup. | 3574 // Cleanup. |
| 3581 host_.OnRenderViewHostDeleted(filter_->child_id(), // child_id | 3575 host_.OnRenderViewHostDeleted(filter_->child_id(), // child_id |
| 3582 0); // route_id | 3576 0); // route_id |
| 3583 } | 3577 } |
| 3584 | 3578 |
| 3585 // Confirm that resource response started notifications for downloads are not | 3579 // Confirm that resource response started notifications for downloads are not |
| 3586 // transmitted to the WebContents. | 3580 // transmitted to the WebContents. |
| 3587 TEST_P(ResourceDispatcherHostTest, TransferResponseStartedDownload) { | 3581 TEST_P(ResourceDispatcherHostTest, TransferResponseStartedDownload) { |
| 3588 int initial_count(web_contents_observer_->resource_response_start_count()); | 3582 int initial_count(web_contents_observer_->resource_response_start_count()); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3670 return nullptr; | 3664 return nullptr; |
| 3671 } | 3665 } |
| 3672 | 3666 |
| 3673 INSTANTIATE_TEST_CASE_P( | 3667 INSTANTIATE_TEST_CASE_P( |
| 3674 ResourceDispatcherHostTests, | 3668 ResourceDispatcherHostTests, |
| 3675 ResourceDispatcherHostTest, | 3669 ResourceDispatcherHostTest, |
| 3676 testing::Values(TestConfig::kDefault, | 3670 testing::Values(TestConfig::kDefault, |
| 3677 TestConfig::kOptimizeIPCForSmallResourceEnabled)); | 3671 TestConfig::kOptimizeIPCForSmallResourceEnabled)); |
| 3678 | 3672 |
| 3679 } // namespace content | 3673 } // namespace content |
| OLD | NEW |