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

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

Issue 1192673002: Ensure ResourceScheduler starts requests even if the tab is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 5 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
« no previous file with comments | « content/browser/loader/resource_scheduler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_scheduler_unittest.cc
diff --git a/content/browser/loader/resource_scheduler_unittest.cc b/content/browser/loader/resource_scheduler_unittest.cc
index 1ffa2b6396da4909dcb24449292d70ec078a7777..3ac956667bfdafb138962616a723766662ad8c10 100644
--- a/content/browser/loader/resource_scheduler_unittest.cc
+++ b/content/browser/loader/resource_scheduler_unittest.cc
@@ -2319,6 +2319,47 @@ TEST_F(ResourceSchedulerTest, OutstandingRequestLimitDelays) {
EXPECT_TRUE(low2->started());
}
+// Async revalidations which are not started when the tab is closed must be
+// started at some point, or they will hang around forever and prevent other
+// async revalidations to the same URL from being issued.
+TEST_F(ResourceSchedulerTest, RequestStartedAfterClientDeleted) {
+ scheduler_->OnClientCreated(kChildId2, kRouteId2, false, false);
+ scoped_ptr<TestRequest> high(NewRequestWithChildAndRoute(
+ "http://host/high", net::HIGHEST, kChildId2, kRouteId2));
+ scoped_ptr<TestRequest> lowest1(NewRequestWithChildAndRoute(
+ "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
+ scoped_ptr<TestRequest> lowest2(NewRequestWithChildAndRoute(
+ "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
+ EXPECT_FALSE(lowest2->started());
+ scheduler_->OnClientDeleted(kChildId2, kRouteId2);
+ high.reset();
+ lowest1.reset();
+ EXPECT_TRUE(lowest2->started());
+}
+
+// The ResourceScheduler::Client destructor calls
+// LoadAnyStartablePendingRequests(), which may start some pending requests.
+// This test is to verify that requests will be started at some point
+// even if they were not started by the destructor.
+TEST_F(ResourceSchedulerTest, RequestStartedAfterClientDeletedManyDelayable) {
+ scheduler_->OnClientCreated(kChildId2, kRouteId2, false, false);
+ scoped_ptr<TestRequest> high(NewRequestWithChildAndRoute(
+ "http://host/high", net::HIGHEST, kChildId2, kRouteId2));
+ const int kMaxNumDelayableRequestsPerClient = 10;
+ ScopedVector<TestRequest> delayable_requests;
+ for (int i = 0; i < kMaxNumDelayableRequestsPerClient + 1; ++i) {
+ delayable_requests.push_back(NewRequestWithChildAndRoute(
+ "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
+ }
+ scoped_ptr<TestRequest> lowest(NewRequestWithChildAndRoute(
+ "http://host/lowest", net::LOWEST, kChildId2, kRouteId2));
+ EXPECT_FALSE(lowest->started());
+ scheduler_->OnClientDeleted(kChildId2, kRouteId2);
+ high.reset();
+ delayable_requests.clear();
+ EXPECT_TRUE(lowest->started());
+}
+
} // unnamed namespace
} // namespace content
« no previous file with comments | « content/browser/loader/resource_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698