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

Unified Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 1706903003: Delay resource scheduling decisions until network access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/resource_dispatcher_host_unittest.cc
diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
index 79a8f80a084ab1f0b553e5dc2c1ac527f5cb6e1c..f36aaed8ffdef27ec0629ab6226230f61534d525 100644
--- a/content/browser/loader/resource_dispatcher_host_unittest.cc
+++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
@@ -1873,29 +1873,26 @@ TEST_P(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) {
EXPECT_EQ(2, network_delegate_.created_requests());
EXPECT_EQ(0, network_delegate_.canceled_requests());
- // The same RenderView issues two more low priority requests. The
- // ResourceScheduler shouldn't let them start immediately.
+ // The same RenderView issues two more low priority requests.
MakeTestRequestWithPriorityAndRenderFrame(0, 10, 3, net::LOWEST);
MakeTestRequestWithPriorityAndRenderFrame(0, 11, 4, net::LOWEST);
KickOffRequest();
- EXPECT_EQ(2, network_delegate_.created_requests());
+ EXPECT_EQ(4, network_delegate_.created_requests());
EXPECT_EQ(0, network_delegate_.canceled_requests());
- // Another RenderView in the same process as the old one issues a request,
- // which is then started.
+ // Another RenderView in the same process as the old one issues a request.
MakeTestRequestWithPriorityAndRenderFrame(1, 12, 5, net::LOWEST);
KickOffRequest();
- EXPECT_EQ(3, network_delegate_.created_requests());
+ EXPECT_EQ(5, network_delegate_.created_requests());
EXPECT_EQ(0, network_delegate_.canceled_requests());
// The first two RenderFrameHosts are destroyed. All 4 of their requests
- // should be cancelled, and none of the two deferred requests should be
- // started.
+ // should be cancelled.
DeleteRenderFrame(GlobalFrameRoutingId(filter_->child_id(), 10));
DeleteRenderFrame(GlobalFrameRoutingId(filter_->child_id(), 11));
host_.OnRenderViewHostDeleted(filter_->child_id(), 0);
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(3, network_delegate_.created_requests());
+ EXPECT_EQ(5, network_delegate_.created_requests());
EXPECT_EQ(4, network_delegate_.canceled_requests());
// No messages should have been sent, since none of the jobs made any
@@ -3559,23 +3556,20 @@ TEST_P(ResourceDispatcherHostTest, DidChangePriority) {
job_factory_->SetDelayedCompleteJobGeneration(true);
SetResponse("HTTP/1.1 200 OK\n\n", "<title>Dummy body</title>");
- // Only one idle priority request will run while a high-priority request
- // exists.
- MakeTestRequestWithPriority(0, 1, net::HIGHEST);
- MakeTestRequestWithPriority(0, 2, net::IDLE);
- MakeTestRequestWithPriority(0, 3, net::IDLE);
-
+ MakeTestRequestWithPriority(0, 1, net::IDLE);
KickOffRequest();
- EXPECT_EQ(2, job_factory_->url_request_jobs_created_count());
+ ResourceLoader* loader = host_.GetLoader(filter_->child_id(), 1);
+ EXPECT_EQ(net::IDLE, loader->request()->priority());
- // Increase the priority of the second idle priority request. It was
- // scheduled later, so it is not currently running.
- ResourceHostMsg_DidChangePriority priority_msg(3, net::MAXIMUM_PRIORITY, 0);
+ // Increase the priority of the request. Actual scheduling logic is tested
+ // in the ResourceScheduler unit tests, this only tests that the message
+ // is delivered and the priority of the request is changed.
+ ResourceHostMsg_DidChangePriority priority_msg(1, net::MAXIMUM_PRIORITY, 0);
host_.OnMessageReceived(priority_msg, filter_.get());
base::MessageLoop::current()->RunUntilIdle();
- EXPECT_EQ(3, job_factory_->url_request_jobs_created_count());
+ EXPECT_EQ(net::MAXIMUM_PRIORITY, loader->request()->priority());
// Cleanup.
host_.OnRenderViewHostDeleted(filter_->child_id(), // child_id

Powered by Google App Engine
This is Rietveld 408576698