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

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

Issue 2435743002: [ResourceScheduler] Throttle H2/QUIC requests just like we do for 1.1 (Closed)
Patch Set: Nit Created 4 years, 2 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 51b8a47b68e39fad5f1628ccc68021bf93c199c0..90d6d47c921b9650906a55d4756ba8a1915ca35d 100644
--- a/content/browser/loader/resource_scheduler_unittest.cc
+++ b/content/browser/loader/resource_scheduler_unittest.cc
@@ -11,6 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
+#include "base/test/scoped_feature_list.h"
#include "base/timer/mock_timer.h"
#include "base/timer/timer.h"
#include "content/browser/browser_thread_impl.h"
@@ -46,6 +47,9 @@ const int kRouteId2 = 67;
const int kBackgroundChildId = 35;
const int kBackgroundRouteId = 43;
+const char kPrioritySupportedRequestsDelayable[] =
+ "PrioritySupportedRequestsDelayable";
+
class TestRequest : public ResourceController {
public:
TestRequest(std::unique_ptr<net::URLRequest> url_request,
@@ -314,6 +318,11 @@ TEST_F(ResourceSchedulerTest, MediumDoesNotBlockCriticalComplete) {
}
TEST_F(ResourceSchedulerTest, OneLowLoadsUntilBodyInsertedExceptSpdy) {
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitFromCommandLine("",
+ kPrioritySupportedRequestsDelayable);
+ InitializeScheduler();
+
http_server_properties_.SetSupportsSpdy(
url::SchemeHostPort("https", "spdyhost", 443), true);
std::unique_ptr<TestRequest> high(
@@ -333,6 +342,27 @@ TEST_F(ResourceSchedulerTest, OneLowLoadsUntilBodyInsertedExceptSpdy) {
EXPECT_TRUE(low2->started());
}
+TEST_F(ResourceSchedulerTest,
+ OneLowLoadsUntilBodyInsertedEvenSpdyWhenDelayable) {
+ http_server_properties_.SetSupportsSpdy(
+ url::SchemeHostPort("https", "spdyhost", 443), true);
+ std::unique_ptr<TestRequest> high(
+ NewRequest("http://host/high", net::HIGHEST));
+ std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST));
+ std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST));
+ std::unique_ptr<TestRequest> low_spdy(
+ NewRequest("https://spdyhost/low", net::LOWEST));
+ EXPECT_TRUE(high->started());
+ EXPECT_TRUE(low->started());
+ EXPECT_FALSE(low2->started());
+ EXPECT_FALSE(low_spdy->started());
+
+ scheduler()->OnWillInsertBody(kChildId, kRouteId);
+ high.reset();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(low2->started());
+}
+
TEST_F(ResourceSchedulerTest, SpdyLowBlocksOtherLowUntilBodyInserted) {
http_server_properties_.SetSupportsSpdy(
url::SchemeHostPort("https", "spdyhost", 443), true);
@@ -631,6 +661,11 @@ TEST_F(ResourceSchedulerTest, NonHTTPSchedulesImmediately) {
}
TEST_F(ResourceSchedulerTest, SpdyProxySchedulesImmediately) {
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitFromCommandLine("",
+ kPrioritySupportedRequestsDelayable);
+ InitializeScheduler();
+
std::unique_ptr<TestRequest> high(
NewRequest("http://host/high", net::HIGHEST));
std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST));
@@ -648,7 +683,30 @@ TEST_F(ResourceSchedulerTest, SpdyProxySchedulesImmediately) {
EXPECT_TRUE(after->started());
}
+TEST_F(ResourceSchedulerTest, SpdyProxyDelayable) {
+ std::unique_ptr<TestRequest> high(
+ NewRequest("http://host/high", net::HIGHEST));
+ std::unique_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST));
+
+ std::unique_ptr<TestRequest> request(
+ NewRequest("http://host/req", net::IDLE));
+ EXPECT_FALSE(request->started());
+
+ scheduler()->OnReceivedSpdyProxiedHttpResponse(kChildId, kRouteId);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(request->started());
+
+ std::unique_ptr<TestRequest> after(
+ NewRequest("http://host/after", net::IDLE));
+ EXPECT_FALSE(after->started());
+}
+
TEST_F(ResourceSchedulerTest, NewSpdyHostInDelayableRequests) {
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitFromCommandLine("",
+ kPrioritySupportedRequestsDelayable);
+ InitializeScheduler();
+
scheduler()->OnWillInsertBody(kChildId, kRouteId);
const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc.
@@ -682,6 +740,40 @@ TEST_F(ResourceSchedulerTest, NewSpdyHostInDelayableRequests) {
EXPECT_TRUE(low2->started());
}
+TEST_F(ResourceSchedulerTest, NewDelayableSpdyHostInDelayableRequests) {
+ scheduler()->OnWillInsertBody(kChildId, kRouteId);
+ const int kMaxNumDelayableRequestsPerClient = 10; // Should match the .cc.
+
+ std::unique_ptr<TestRequest> low1_spdy(
+ NewRequest("http://spdyhost1:8080/low", net::LOWEST));
+ // Cancel a request after we learn the server supports SPDY.
+ ScopedVector<TestRequest> lows;
+ for (int i = 0; i < kMaxNumDelayableRequestsPerClient - 1; ++i) {
+ string url = "http://host" + base::IntToString(i) + "/low";
+ lows.push_back(NewRequest(url.c_str(), net::LOWEST));
+ }
+ std::unique_ptr<TestRequest> low1(NewRequest("http://host/low", net::LOWEST));
+ EXPECT_FALSE(low1->started());
+ http_server_properties_.SetSupportsSpdy(
+ url::SchemeHostPort("http", "spdyhost1", 8080), true);
+ low1_spdy.reset();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(low1->started());
+
+ low1.reset();
+ base::RunLoop().RunUntilIdle();
+ std::unique_ptr<TestRequest> low2_spdy(
+ NewRequest("http://spdyhost2:8080/low", net::IDLE));
+ // Reprioritize a request after we learn the server supports SPDY.
+ EXPECT_TRUE(low2_spdy->started());
+ http_server_properties_.SetSupportsSpdy(
+ url::SchemeHostPort("http", "spdyhost2", 8080), true);
+ ChangeRequestPriority(low2_spdy.get(), net::LOWEST);
+ base::RunLoop().RunUntilIdle();
+ std::unique_ptr<TestRequest> low2(NewRequest("http://host/low", net::LOWEST));
+ EXPECT_FALSE(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.
« 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