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

Unified Diff: net/dns/host_resolver_impl.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.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl.cc
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index a224b8c4e38a87d943fef29f7494c738186e1096..5559c8d460fbbed748f66146ac784f2d8e1cf9d7 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -574,6 +574,7 @@ class HostResolverImpl::Request {
}
RequestPriority priority() const { return priority_; }
+ void set_priority(RequestPriority priority) { priority_ = priority; }
base::TimeTicks request_time() const { return request_time_; }
@@ -583,8 +584,7 @@ class HostResolverImpl::Request {
// The request info that started the request.
const RequestInfo info_;
- // TODO(akalin): Support reprioritization.
- const RequestPriority priority_;
+ RequestPriority priority_;
// The resolve job that this request is dependent on.
Job* job_;
@@ -1367,6 +1367,16 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
UpdatePriority();
}
+ void ChangeRequestPriority(Request* req, RequestPriority priority) {
+ DCHECK_EQ(key_.hostname, req->info().hostname());
+ DCHECK(!req->was_canceled());
+
+ priority_tracker_.Remove(req->priority());
+ req->set_priority(priority);
+ priority_tracker_.Add(req->priority());
+ UpdatePriority();
+ }
+
// Marks |req| as cancelled. If it was the last active Request, also finishes
// this Job, marking it as cancelled, and deletes it.
void CancelRequest(Request* req) {
@@ -1474,6 +1484,12 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
DCHECK_EQ(1u, num_occupied_job_slots_);
}
+ AddressList MakeAddressListForRequest(const AddressList& list) const {
+ if (requests_.empty())
+ return list;
+ return AddressList::CopyWithPort(list, requests_.front()->info().port());
+ }
+
void UpdatePriority() {
if (is_queued()) {
if (priority() != static_cast<RequestPriority>(handle_.priority()))
@@ -1482,12 +1498,6 @@ class HostResolverImpl::Job : public PrioritizedDispatcher::Job,
}
}
- AddressList MakeAddressListForRequest(const AddressList& list) const {
- if (requests_.empty())
- return list;
- return AddressList::CopyWithPort(list, requests_.front()->info().port());
- }
-
// PriorityDispatch::Job:
void Start() override {
DCHECK_LE(num_occupied_job_slots_, 1u);
@@ -2045,6 +2055,16 @@ int HostResolverImpl::ResolveFromCache(const RequestInfo& info,
return rv;
}
+void HostResolverImpl::ChangeRequestPriority(RequestHandle req_handle,
+ RequestPriority priority) {
+ DCHECK(CalledOnValidThread());
+ Request* req = reinterpret_cast<Request*>(req_handle);
+ DCHECK(req);
+ Job* job = req->job();
+ DCHECK(job);
+ job->ChangeRequestPriority(req, priority);
+}
+
void HostResolverImpl::CancelRequest(RequestHandle req_handle) {
DCHECK(CalledOnValidThread());
Request* req = reinterpret_cast<Request*>(req_handle);
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698