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

Unified Diff: net/dns/host_resolver_impl_unittest.cc

Issue 1928743003: DNS: Support reprioritization of requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make a couple of comment changes Created 4 years, 7 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 | « net/dns/host_resolver_impl.cc ('k') | net/dns/host_resolver_mojo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl_unittest.cc
diff --git a/net/dns/host_resolver_impl_unittest.cc b/net/dns/host_resolver_impl_unittest.cc
index c5c047a66a5e7ac97509f592ab73686f793e9a82..8c75a460977198c418a0635c5a4dcf6ab51f1b9d 100644
--- a/net/dns/host_resolver_impl_unittest.cc
+++ b/net/dns/host_resolver_impl_unittest.cc
@@ -244,6 +244,13 @@ class Request {
return resolver_->ResolveFromCache(info_, &list_, BoundNetLog());
}
+ void ChangePriority(RequestPriority priority) {
+ DCHECK(resolver_);
+ DCHECK(handle_);
+ resolver_->ChangeRequestPriority(handle_, priority);
+ priority_ = priority;
+ }
+
void Cancel() {
DCHECK(resolver_);
DCHECK(handle_);
@@ -1191,6 +1198,41 @@ TEST_F(HostResolverImplTest, HigherPriorityRequestsStartedFirst) {
EXPECT_EQ("req6", capture_list[6].hostname);
}
+// Test that changing a job's priority affects the dequeueing order.
+TEST_F(HostResolverImplTest, ChangePriority) {
+ CreateSerialResolver();
+
+ CreateRequest("req0", 80, MEDIUM);
+ CreateRequest("req1", 80, LOW);
+ CreateRequest("req2", 80, LOWEST);
+
+ ASSERT_EQ(3u, requests_.size());
+
+ // req0 starts immediately; without ChangePriority, req1 and then req2 should
+ // run.
+ EXPECT_EQ(ERR_IO_PENDING, requests_[0]->Resolve());
+ EXPECT_EQ(ERR_IO_PENDING, requests_[1]->Resolve());
+ EXPECT_EQ(ERR_IO_PENDING, requests_[2]->Resolve());
+
+ // Changing req2 to HIGH should make it run before req1.
+ // (It can't run before req0, since req0 started immediately.)
+ requests_[2]->ChangePriority(HIGHEST);
+
+ // Let all 3 requests finish.
+ proc_->SignalMultiple(3u);
+
+ EXPECT_EQ(OK, requests_[0]->WaitForResult());
+ EXPECT_EQ(OK, requests_[1]->WaitForResult());
+ EXPECT_EQ(OK, requests_[2]->WaitForResult());
+
+ MockHostResolverProc::CaptureList capture_list = proc_->GetCaptureList();
+ ASSERT_EQ(3u, capture_list.size());
+
+ EXPECT_EQ("req0", capture_list[0].hostname);
+ EXPECT_EQ("req2", capture_list[1].hostname);
+ EXPECT_EQ("req1", capture_list[2].hostname);
+}
+
// Try cancelling a job which has not started yet.
TEST_F(HostResolverImplTest, CancelPendingRequest) {
CreateSerialResolver();
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/dns/host_resolver_mojo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698