Commit 7c45454f authored by yhirano's avatar yhirano Committed by Commit Bot

Set "ping" requests priority as lowest

Requests from PingLoader had the lowest priority, but I changed it
unintentionally. This CL restores the original behavior.

BUG=739161

Review-Url: https://codereview.chromium.org/2982523002
Cr-Commit-Position: refs/heads/master@{#486267}
parent f3a47f5b
...@@ -23,7 +23,7 @@ namespace { ...@@ -23,7 +23,7 @@ namespace {
class PingLocalFrameClient : public EmptyLocalFrameClient { class PingLocalFrameClient : public EmptyLocalFrameClient {
public: public:
void DispatchWillSendRequest(ResourceRequest& request) override { void DispatchWillSendRequest(ResourceRequest& request) override {
if (request.HttpContentType() == "text/ping") if (request.GetKeepalive())
ping_request_ = request; ping_request_ = request;
} }
...@@ -71,7 +71,7 @@ class PingLoaderTest : public ::testing::Test { ...@@ -71,7 +71,7 @@ class PingLoaderTest : public ::testing::Test {
return ping_request; return ping_request;
} }
private: protected:
Persistent<PingLocalFrameClient> client_; Persistent<PingLocalFrameClient> client_;
std::unique_ptr<DummyPageHolder> page_holder_; std::unique_ptr<DummyPageHolder> page_holder_;
}; };
...@@ -103,6 +103,52 @@ TEST_F(PingLoaderTest, NonHTTPPingTarget) { ...@@ -103,6 +103,52 @@ TEST_F(PingLoaderTest, NonHTTPPingTarget) {
ASSERT_TRUE(ping_request.IsNull()); ASSERT_TRUE(ping_request.IsNull());
} }
TEST_F(PingLoaderTest, LoadImagePriority) {
SetDocumentURL(KURL(kParsedURLString, "http://localhost/foo.html"));
KURL ping_url(kParsedURLString, "https://localhost/bar.html");
URLTestHelpers::RegisterMockedURLLoad(
ping_url, testing::CoreTestDataPath("bar.html"), "text/html");
PingLoader::LoadImage(&page_holder_->GetFrame(), ping_url);
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
const ResourceRequest& request = client_->PingRequest();
ASSERT_FALSE(request.IsNull());
ASSERT_EQ(request.Url(), ping_url);
EXPECT_EQ(kResourceLoadPriorityVeryLow, request.Priority());
}
TEST_F(PingLoaderTest, LinkAuditPingPriority) {
KURL destination_url(kParsedURLString, "http://navigation.destination");
SetDocumentURL(KURL(kParsedURLString, "http://localhost/foo.html"));
KURL ping_url(kParsedURLString, "https://localhost/bar.html");
URLTestHelpers::RegisterMockedURLLoad(
ping_url, testing::CoreTestDataPath("bar.html"), "text/html");
PingLoader::SendLinkAuditPing(&page_holder_->GetFrame(), ping_url,
destination_url);
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
const ResourceRequest& request = client_->PingRequest();
ASSERT_FALSE(request.IsNull());
ASSERT_EQ(request.Url(), ping_url);
EXPECT_EQ(kResourceLoadPriorityVeryLow, request.Priority());
}
TEST_F(PingLoaderTest, BeaconPriority) {
SetDocumentURL(KURL(kParsedURLString, "https://localhost/foo.html"));
KURL ping_url(kParsedURLString, "https://localhost/bar.html");
URLTestHelpers::RegisterMockedURLLoad(
ping_url, testing::CoreTestDataPath("bar.html"), "text/html");
size_t size = 0;
PingLoader::SendBeacon(&page_holder_->GetFrame(), 123, ping_url, "hello",
size);
Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
const ResourceRequest& request = client_->PingRequest();
ASSERT_FALSE(request.IsNull());
ASSERT_EQ(request.Url(), ping_url);
EXPECT_EQ(kResourceLoadPriorityVeryLow, request.Priority());
}
} // namespace } // namespace
} // namespace blink } // namespace blink
...@@ -215,6 +215,13 @@ ResourceLoadPriority ResourceFetcher::ComputeLoadPriority( ...@@ -215,6 +215,13 @@ ResourceLoadPriority ResourceFetcher::ComputeLoadPriority(
} }
} else if (FetchParameters::kLazyLoad == defer_option) { } else if (FetchParameters::kLazyLoad == defer_option) {
priority = kResourceLoadPriorityVeryLow; priority = kResourceLoadPriorityVeryLow;
} else if (resource_request.GetRequestContext() ==
WebURLRequest::kRequestContextBeacon ||
resource_request.GetRequestContext() ==
WebURLRequest::kRequestContextPing ||
resource_request.GetRequestContext() ==
WebURLRequest::kRequestContextCSPReport) {
priority = kResourceLoadPriorityVeryLow;
} }
// A manually set priority acts as a floor. This is used to ensure that // A manually set priority acts as a floor. This is used to ensure that
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment