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

Unified Diff: net/dns/host_resolver_impl_fuzzer.cc

Issue 2116983002: Change HostResolver::Resolve() to take an std::unique_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http_stream_factory_impl_job_controller_unittest RequestHandle* to unique_ptr Created 4 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
Index: net/dns/host_resolver_impl_fuzzer.cc
diff --git a/net/dns/host_resolver_impl_fuzzer.cc b/net/dns/host_resolver_impl_fuzzer.cc
index c9c9e170649f130e5b6f76e4406593c607934b22..b4f65c59e874771637034d00747fb3edc35ba805 100644
--- a/net/dns/host_resolver_impl_fuzzer.cc
+++ b/net/dns/host_resolver_impl_fuzzer.cc
@@ -38,13 +38,9 @@ class DnsRequest {
: host_resolver_(host_resolver),
data_provider_(data_provider),
dns_requests_(dns_requests),
- handle_(nullptr),
is_running_(false) {}
- ~DnsRequest() {
- if (is_running_)
- Cancel();
- }
+ ~DnsRequest() {}
// Creates and starts a DNS request using fuzzed parameters. If the request
// doesn't complete synchronously, adds it to |dns_requests|.
@@ -97,6 +93,7 @@ class DnsRequest {
CHECK_NE(net::ERR_IO_PENDING, result);
is_running_ = false;
+ request_.reset();
// Remove |this| from |dns_requests| and take ownership of it, if it wasn't
// already removed from the vector. It may have been removed if this is in a
@@ -155,7 +152,7 @@ class DnsRequest {
info.set_allow_cached_response(data_provider_->ConsumeBool());
return host_resolver_->Resolve(
info, priority, &address_list_,
- base::Bind(&DnsRequest::OnCallback, base::Unretained(this)), &handle_,
+ base::Bind(&DnsRequest::OnCallback, base::Unretained(this)), &request_,
net::BoundNetLog());
}
@@ -166,14 +163,13 @@ class DnsRequest {
run_loop_.reset(new base::RunLoop());
run_loop_->Run();
run_loop_.reset();
- CHECK(!is_running_);
+ DCHECK(request_);
}
}
// Cancel the request, if not already completed. Otherwise, does nothing.
void Cancel() {
- if (is_running_)
- host_resolver_->CancelRequest(handle_);
+ request_.reset();
is_running_ = false;
}
@@ -181,7 +177,7 @@ class DnsRequest {
net::FuzzedDataProvider* data_provider_;
std::vector<std::unique_ptr<DnsRequest>>* dns_requests_;
- net::HostResolver::RequestHandle handle_;
+ std::unique_ptr<net::HostResolver::Request> request_;
net::AddressList address_list_;
bool is_running_;

Powered by Google App Engine
This is Rietveld 408576698